CustomBuild custom configuration

CustomBuild is an extremely progressive tool that manages software but also provides an elegant way to customize everything. Referencing to /usr/local/directadmin/custombuild as the working directory - the configure/ directory contains default configs:

ap2
clamav
curl
custombuild
dovecot
fastcgi
fpm
libxml2
libxslt
litespeed
modsecurity
nginx
nginx_reverse
opcache
openlitespeed
php
phpmyadmin
proftpd
pureftpd
rspamd
spamassassin
suhosin
suphp
systemd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

To build a software with a custom flags or options, you have to create a custom/ directory (and structure), copy the existing software's config, and modify it in custom/ .

For example, rebuilding Nginx with "--with-http_sub_module" compilation flag:

cd /usr/local/directadmin/custombuild
mkdir -p custom/nginx/
cp -fp configure/nginx/configure.nginx custom/nginx/configure.nginx
1
2
3

Edit the custom/nginx/configure.nginx file, add --with-http_sub_module\, and build Nginx:

./build nginx
1

Regular configuration files have to be customized in the same way. For example, Apache MPM settings:

cd /usr/local/directadmin/custombuild
mkdir -p custom/ap2/conf/extra/
cp -fp configure/ap2/conf/extra/httpd-mpm.conf custom/ap2/conf/extra/httpd-mpm.conf
1
2
3

Edit the custom/ap2/conf/extra/httpd-mpm.conf file as desired and then apply changes with:

./build rewrite_confs
1

More in relevant sections for services you need.

Starting from version 2369, the pre/post hooks were implemented.

CustomBuild lets you overwrite any call and execute pre/post hooks etc. For example, you could now:

  1. Create ./build varnish or just overwrite the regular ./build apache call with whatever you want by using pre-call hook and 'exiting' at the end

  2. Execute anything before/after the CustomBuild command. For example, after update_versions, you could mail yourself/server-owner a message that updates have been applied.

All CustomBuild variables are reachable via 'hooks'. The structure is /usr/local/directadmin/custombuild/custom/hooks/command/pre/anything.sh (pre could be post as well). For example, you could try custom/hooks/versions/pre/test.sh with the following content:

#!/bin/sh
echo "Oh yeah! My PHP version is ${PHP1_RELEASE_OPT}, and I'm just exiting with a strange error code instead of listing the version updates...."
exit 4
1
2
3

If you'd like to just finish the function, "return" instead of "exit" could be used.

To run something after OpenLitespeed is built, you would need:

cd /usr/local/directadmin/custombuild/
mkdir -p custom/hooks/openlitespeed/post
vi custom/hooks/openlitespeed/post/myscript.sh
1
2
3

And add your code like:

#!/bin/sh
echo "This is a post openlitespeed script"
1
2

The pre-scripts are always executed while post-scripts depends on if build finished successfully or not.

I wish to add my own webapps Alias pointing to /var/www/html

If you have your own alias which you need to add, let's call it /billing, and you wish to point it to

/var/www/html/

then you can add it as a location Alias for all domains using the custom/webapps.list fileopen in new window.

  1. To set it up, run the following:
cd /usr/local/directadmin/custombuild
mkdir custom
1
2
  1. Then add the custom values to the file:
echo "billing=billing_system" >> custom/webapps.list
1
  1. Lastly, rewrite the configs for Apache or Nginx:
./build rewrite_confs
1

These changes should show up in one of these files, depending on if you're using Apache or Nginx:

/etc/httpd/conf/extra/httpd-alias.conf
/etc/nginx/webapps.conf

NOTE CustomBuild will always set the "webmail" Alias to the currently selected webmail_linkopen in new window from the directadmin.conf (possibly an internal default), so if you wish to change where /webmail goes, use the webmail_link featureopen in new window to change it, and issue the config rewrite demonstrated in step 3.

Custom items value in virtualhost template

The custom_domain_items feature lets you set custom per-domain variables.

This change allows those variables which are set in the domain's config file: /usr/local/directadmin/data/users/username/domains/domain.com.conf

to be available as a token in the User's httpd.conf templates with the token syntax:

|CUSTOM_DOMAIN_ITEM_%s|
1

where %s is swapped with the custom item name, and that whole token, when used in the templates, will be swapped with the value from the domain.com.conf.

For example, if you have this file /usr/local/directadmin/data/admin/custom_domain_items.conf, loaded with:

banana=type=checkbox&string=Custom 1&desc=Yellow&checked1=yes
1

Then you can use the token:

|CUSTOM_DOMAIN_ITEM_banana|
1

in the virtual_host2.conf templates (and subdomains, and pointers).

Note that this token will only be available if:

banana=anything
1

is actually set in the domain.com.conf file.

If it's unset (name does not exist), then the token will not be set.

An sample (invalid) example usage of the token might be:

|*if CUSTOM_DOMAIN_ITEM_banana="ON"|
	Options +banana
|*endif|
1
2
3

The Custom Package Items is also available in the templates.

Token will be |PACKAGE| which might be the package name, 'custom' or possibly blank in rare cases.

Subdomain DocumentRoot override

To change a document root for a subdomain, you can log into DirectAdmin as the user that owns the subdomain, and then navigate as follows:

Dashboard > Sub-Domains Setup > Document Root Override

Upon clicking Sub-Domains Setup, you should see an option to edit the document root (an edit icon that resembles a pencil), and upon clicking this option, will be taken to the Document Root Override path noted above.

You will also have the option within this interface to change the subdomain's PHP version, too (feature implemented in DirectAdmin Version Version 1.60.4).

The new optional file was implemented in DirectAdmin Version 1.59.5 (the aforementioned GUI implemented in DirectAdmin Version 1.61.0):

/usr/local/directadmin/data/users/USERNAME/domains/DOMAIN.COM.subdomains.docroot.override

where the file might show this for sub.DOMAIN.COM :

sub=public_html=/domains/DOMAIN.COM/public_html&private_html=/domains/DOMAIN.COM/private_html
1

where "sub" is the index on the left, matching up with the subdomain in question.

While writing the VirtualHost for a subdomain, if the file exist, "sub" exist, and the given public_html or private_html variable exist for that VH, DA will use the listed path as an override, relative to the User's home directory.

In the above example, the DocumentRoot would end up being:

  • ServerName www.sub.DOMAIN.COM
  • DocumentRoot /home/USERNAME/domains/DOMAIN.COM/public_html

The one of the public_html and private_html values are optional, in case you wanted to override one part, but not the other.

Last Updated: 6/23/2021, 9:36:08 PM