If you own a Direactadmin server, most probably you would like to add something to default virtualhost settings, when a new user is created. You might need any specific php settings, or anything related to Apache – this doesn’t really matter. Let’s see where we can modify these settings; you will need SSH access to your server as we will edit a configuration file.
We need to go to the directory, where configuration templates are located. It is /usr/local/directadmin/data/templates. There are lots of files, but we need virtual_host.conf to make the necessary changes to default virtualhost settings.
A default file should look like this (this is the original version):
|?DOCROOT=`HOME`/domains/`DOMAIN`/public_html|
|?OPEN_BASEDIR_PATH=`HOME`/:/tmp:/usr/local/lib/php/|
<VirtualHost |IP|:80>
|CUSTOM|
|?CGI=ScriptAlias /cgi-bin/ `DOCROOT`/cgi-bin/|
ServerName www.|DOMAIN|
ServerAlias www.|DOMAIN| |DOMAIN| |SERVER_ALIASES|
ServerAdmin |ADMIN|
DocumentRoot |DOCROOT|
|CGI||USECANONICALNAME|
User |USER|
Group |GROUP|
CustomLog /var/log/httpd/domains/|DOMAIN|.bytes bytes
CustomLog /var/log/httpd/domains/|DOMAIN|.log combined
ErrorLog /var/log/httpd/domains/|DOMAIN|.error.log<Directory |DOCROOT|>
Options +Includes -Indexes
|*if CLI=”1″|
php_admin_flag engine |PHP|
<IfModule !mod_php6.c>
php_admin_flag safe_mode |SAFE_MODE|
</IfModule>
php_admin_value sendmail_path ‘/usr/sbin/sendmail -t -i -f |USER|@|DOMAIN|’
|*endif|
|*if OPEN_BASEDIR=”ON”|
php_admin_value open_basedir |OPEN_BASEDIR_PATH|
|*endif|
|*if SUPHP=”1″|
suPHP_Engine |PHP|
suPHP_UserGroup |USER| |GROUP|
|*endif|
</Directory>
|HANDLERS|
|MIMETYPES|</VirtualHost>
For example, we need to have a common include directory for PHP scripts, operated by many users. Certainly it is possible to go to /usr/local/directadmin/data/users and change include settings one by one. You can also edit php.ini, but this is the most unsecure solution.
In order to add a directory for common inclusion, we need to add it to the following string:
|?OPEN_BASEDIR_PATH=`HOME`/:/tmp:/usr/local/lib/php/:/YOUR_DIRECTORY|
This file is easy to understand so if you need to have some specific settings, it is quite easy to apply them. For example, if you need to use wildcard subdomains, you will need the following string:
ServerAlias *.|DOMAIN| |DOMAIN| |SERVER_ALIASES|
Any changes related to default Directadmin virtualhost should be made in this file.
If you need to apply changes to existing users, the glue is to run the following command via SSH:
echo “action=rewrite&value=httpd” >> /usr/local/directadmin/data/task.queue /usr/local/directadmin/dataskq d
This will apply the canges made to all users. All virtualhosts will be rewritten, so triple check the configuration before applying this command – in case of any error your sites may stop working.