Search K
Appearance
Appearance
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
systemdTo 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.nginxEdit the custom/nginx/configure.nginx file, add --with-http_sub_module\, and build Nginx:
da build nginxRegular 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.confEdit the custom/ap2/conf/extra/httpd-mpm.conf file as desired and then apply changes with:
da build rewrite_confsMore in relevant sections for services you need.
CustomBuild lets you overwrite any call and execute pre/post hooks etc.
You can now:
mkdir -p /usr/local/directadmin/custombuild/custom/hooks/examplecommand/pre/
cd /usr/local/directadmin/custombuild/custom/hooks/examplecommand/preAdd the following contents to examplescript.sh (name it whatever you prefer):
#!/bin/bash
echo "Testing if the pre hook script works"
exit 4Note the "exit" entry. Without it the build script would continue functioning as normal and give unnecessary output.
Run the build script to test if it works:
/usr/local/directadmin/custombuild/build examplecommandYou should get similar output:
Executing '/usr/local/directadmin/custombuild/custom/hooks/examplecommand/pre/examplescript.sh'...
Testing if the pre hook script works
Hook exited with error code: 4. Exiting...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). To modify an already existing command ("versions" in this example), try adding custom/hooks/versions/pre/test.sh with the following content:
#!/bin/bash
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 4If 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.shAnd add your code like:
#!/bin/bash
echo "This is a post openlitespeed script"The pre-scripts are always executed while post-scripts depends on if build finished successfully or not.
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 file.
cd /usr/local/directadmin/custombuild
mkdir customecho "billing=billing_system" >> custom/webapps.listda build rewrite_confsThese 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_link from the directadmin.conf (possibly an internal default), so if you wish to change where /webmail goes, use the webmail_link feature to change it, and issue the config rewrite demonstrated in step 3.
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|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=yesThen you can use the token:
|CUSTOM_DOMAIN_ITEM_banana|in the virtual_host2.conf templates (and subdomains, and pointers).
Note that this token will only be available if:
banana=anythingis 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|Token will be |PACKAGE| which might be the package name, 'custom' or possibly blank in rare cases.
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_htmlwhere "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:
The one of the public_html and private_html values are optional, in case you wanted to override one part, but not the other.