Updating, recompiling, VirtualHost templates, customizations,  php safemode … Updating Apache to the latest version

Updating, recompiling, VirtualHost templates, customizations,  php safemode … Updating Apache to the latest version

For the Current version of apache You can check the following  by running

/usr/sbin/httpd -v

 

 



CustomBuild – current

Custombuild If you’re using(as most of new boxes are), So run the following

 

 

 



CustomApache – end-of-life

Customapache

If you are using with the 1.3 version of apache Then the most recent, You can run the following:

 

 

 

 

 Apache 2.x If you’re using, use “./build apache_2” instead of apache_mod_ssl.
both the configure options should be update  and the version of apache to the most recent version.  you’ll need to restart Apache, Once the update has completed:


RedHat:

/sbin/service httpd restart


FreeBSD:

/usr/local/etc/rc.d/httpd restart

Using a custom Virtual-Host for the template

The setup of the Virtual-Hosts for all domains If you wish to change, you can do so by creating your own custom templates.

cd /usr/local/directadmin/data/templates
cp virtual_host2*.conf custom
cd custom

Even if you’ve copied the 4 VirtualHost files (or just those ones you want) to the custom directory, you can then edit all the new files you’ve just copied.

 DirectAdmin will always check for the custom file before going to the default ones.

Failure to copy the virtual_host2*.conf files to the custom directory before modifying them will result in a loss of all changes when DirectAdmin updates itself (the files are overwritten).

Note that there are actually 8 virtual_host files, but you only need to worry about the 4 that apply to you.   The files with the 2 in them are for apache 2.x.  The ones without the 2 in them are for apache 1.3.

for the virtual_host*.conf Inside these files , you’ll find a code that is similar to httpd.conf code, so that it contains what are known as tokens.

  For each domain created These tokens are what will be replaces with specific user data.

Available tokens
DOMAIN the name of the domain. eg: domain.com
IP the IP address associated with that domain. eg: 192.168.3.4
HOME The users home directory. eg: /home/gary
ADMIN The email address of the server admin.  webmaster@domain.com
HOSTNAME The hostname of the server. eg: server.domain.com
SAFE_MODE ON or OFF if php safe_mode is enabled or not

PHP

ON or OFF if php is enabled or not

CGI The whole httpd.conf line used to add the Script-Alias
HANDLERS httpd.conf code holding all apache handlers
MIMETYPE httpd.conf code holding all apache mime types
USER the username
GROUP the users group name (99% of the time, it’s the same as the USER)
DOCROOT The DocumentRoot of the VirtualHost.  This is the path that apache will use to access the data when the ServerName (domain.com) is requested
SUB for the virtual_host_*sub.conf file, the subdomain name. eg: sub
CUSTOM custom httpd.conf code to be inserted if the domain.com.cust_httpd file exists. (See Adding custom httpd.conf code the VirtualHost of one domain)
CAROOT The whole httpd.conf line used to load in the SSLCACertificateFile directive
CERT The path of the certificate to be used for the domain
CREATOR The username of the account that created the User account who owns this domain
KEY The path of the certificate to be used for the domain

All The top of these templates should contain |?CGI=…| and |?DOCROOT=…|.  These lines are those where the data for the CGI and DOCROOT tokens will be set.  If the cgi is not enabled, this line will be ignored and the CGI token will be empty.  If there the domain is suspended, the DOCROOT will fill the the path of the suspend page.  The CAROOT token will get empty unless the User has added a valid CARootCertificate through DA.

You can use any tokens when assigning a value to CGI or DOCROOT,  for just use `TOKEN` instead of |TOKEN|.

Though you are happy with your new virtual_host*.conf files they will need to be in use in the real httpd.conf files.  You can align with DirectAdmin to rewrite all User httpd.conf files by running:

echo “action=rewrite&value=httpd” >> /usr/local/directadmin/data/task.queue

That command will be add the the task queue which is under checking once per minute, then it may be a few minutes before all httpd.conf files to be rewritten.

*Note: the main /etc/httpd/conf/httpd.conf will be never overwritten (unless DirectAdmin is reinstalled) so any changes you make will be safe.

Note, that you can even use if-then-else statements if you won’t want all settings to be global.

For Example, say you want a custom item to be add, only for 1 domain:

|*if DOMAIN=”domain.com“|
#custom item for just this domain
|*endif|

Leave a Reply

Your email address will not be published. Required fields are marked *