Tag: httpd
Updating Apache to the latest version
by admin on Sep.08, 2009, under DirectAdmin
You can check the current version of apache by running
httpd -v
If you wish to update your 1.3 version of apache to the most recent, run the following:
cd /usr/local/directadmin/customapache
./build clean
./build update
./build apache_mod_ssl
If you’re using apache 2.x, use "./build apache_2" instead of apache_mod_ssl.
This should update both the configure options and the version of apache to the most recent version. Once the update has completed, you’ll need to restart apache:
RedHat:
/sbin/service httpd restart
FreeBSD:
/usr/local/etc/rc.d/httpd restart
How to setup per-domain Aliases
by admin on Sep.07, 2009, under DirectAdmin
If you want to disable /webmail for just one domain (for example), one way to do that is to change the Aliases to be within the VirtualHosts instead of 1 global Alias.
To do that, we’ll need to use the virtual_host2.conf template (for apache 2) and use the custom httpd config settings, found in the Admin Level. This guide assumes you’re using apache 2 with custombuild.
1) Setup the custom template so it’s safe from DA updates:
cd /usr/local/directadmin/data/templates/custom
cp ../virtual_host2.conf .
2) Edit the copied virtual_host2.conf file, and insert the following at the top of the file:
|?WEBMAIL=ON|
Then just below the token that says |CUSTOM| (in the same file) add:
|*if WEBMAIL="ON"|
Alias /webmail /var/www/html/webmail/
|*endif|
3) Go to:
Admin Level -> Custom httpd config -> domain.com
In the textarea at the top, insert this one line:
|?WEBMAIL=OFF|
which will shut off webmail for just that one domain.
4) Remove the global Alias from the /etc/httpd/conf/extra/httpd-aliases.conf file.
5) Issue a full user httpd.conf rewrite, then restart apache.
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq d
/etc/init.d/httpd restart
How do I change the DocumentRoot of only one of my subdomains?
by admin on Sep.07, 2009, under DirectAdmin
1) If you wish to change just 1 subdomain path, you’d use this guide as a starting point:
http://help.directadmin.com/item.php?id=3
and insert the following code
|*if SUB="subname"|
|?DOCROOT=/the/new/path/you/want|
|*endif|
This will do a check on the subdomain name.
Change subname to the name of the subdomain you want to set the path for.
Also change the path to the path you’d like.
Failing to use the if statement on the subdomain will cause the main domain and all subdomains to use this new path, which isn’t always as desired.
2) Going into more detail, the DocumentRoot for a subdomain will always have the "sub" name appended to the end. If this is not the desired effect, then the templates would have to be modified to get rid of the bit on the end, while still allowing subdomain paths for normal subdomains to be valid. To do that, first copy the templates to the custom folder
cd /usr/local/directadmin/data/templates/custom
cp ../virtual_host2*_sub.conf
Then edit both of the virtual_host2_sub.conf and virtual_host2_secure_sub.conf files. Find the following line:
|?DOCROOT=`HOME`/domains/`DOMAIN`/public_html|
and change it to be:
|?DOCROOT=`HOME`/domains/`DOMAIN`/public_html/`SUB`|
Same thing for this line:
|?CGI=ScriptAlias /cgi-bin/ `DOCROOT`/`SUB`/cgi-bin/|
change it to be:
|?CGI=ScriptAlias /cgi-bin/ `DOCROOT`/cgi-bin/|
and one last time for a 3rd line, change:
<Directory |DOCROOT|/|SUB|>
to be:
<Directory |DOCROOT|>
Save the 2 virtual_host2*_sub.conf with these 3 changes, then proceed with step 1 normally, and the path will be what you’re looking for. All existing subdomains will also remain unaffected, since we just moved the SUB part from the bottom, and moved it to the top.
3)Similarly, if you only which to change the path of the domain and not any subdomains, you can use
|*if !SUB|
|?DOCROOT=/the/new/path/you/want|
|*endif|
so that only if there is no subdomain name, then the path will be altered.
Change apache to do graceful restarts
by admin on Sep.07, 2009, under DirectAdmin
If you want to avoid download interruptions during apache restarts, apache has to be changed to restart gracefully.
To do that, you’ll need to change your httpd boot script.
The path for your script will vary depending on your OS.
For FreeBsd it’s:
/usr/local/etc/rc.d/httpd
For all other OS’s, it’s:
/etc/init.d/httpd
As for the actual change, you’ll edit the httpd boot script for your system, find this code:
restart)
stop
waitforexit "httpd" 20
start
;;
and change it to read:
restart)
kill -USR1 `cat $PIDFILE`
;;
Note, this is not tested as much, so you’ll need to keep an eye on things until you’re satisfied that it’s stable.
An apache restart will no longer start apache if it’s stopped. You must "start" it, as the graceful restart only works on already running processes.
How to update to php 5
by admin on Sep.07, 2009, under DirectAdmin
Note: If you want the latest version of php and apache, it’s recommended you use custombuild:
http://files.directadmin.com/services/custombuild/1.1
The following guide is only to be used if if you still want to use the old apache versions… basically, only if you still need FrontPage.
To update to php5, the build script will still work. All that you need to do is swap out the version, compile normally and make a few modifications to your /etc/httpd/conf/httpd.conf file.
1) download the php-5.2.4.tar.gz from php.net into your customapache directory:
cd /usr/local/directadmin/customapache
wget http://files.directadmin.com/services/customapache/php-5.2.4.tar.gz
2) change your build script for the new version:
nano build
change: PHP_VER=4.4.4
to: PHP_VER=5.2.4
3) build php normally:
./build clean
./build php n
If you’re using apache 2.x, use
./build clean
./build php_ap2 n
instead.
4) edit /etc/httpd/conf/httpd.conf
Remove any referce of:
LoadModule php4_module modules/libphp4.so
and make sure they’re replaced with:
LoadModule php5_module modules/libphp5.so
Remove any reference of:
AddModule mod_php4.c
and replace with:
AddModule mod_php5.c
5) find this piece of code:
<IfModule mod_dir.c>
DirectoryIndex index.html index.htm index.shtml index.php index.php4 index.php3 index.phtml index.cgi
</IfModule>
replace with:
<IfModule mod_dir.c>
DirectoryIndex index.html index.htm index.shtml index.php index.php4 index.php5 index.php3 index.phtml index.cgi
</IfModule>
Find this:
<IfModule mod_php4.c>
AddType application/x-httpd-php .inc .php .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps
</IfModule>
(it might have AddHandler instead of AddType)
replace with:
<IfModule mod_php5.c>
AddHandler application/x-httpd-php .inc .php .php5 .php4 .php3 .phtml
AddHandler application/x-httpd-php-source .phps
</IfModule>
Then restart apache.
If you get the following error while compiling php:
checking whether to enable LIBXML support… yes
checking libxml2 install dir… no
checking for xml2-config path…
configure: error: xml2-config not found. Please check your libxml2
installation.
*** There was an error while trying to configure php. Check the configure.php file
Then edit the configure.php file (or configure.php_ap2 if you’re using apache 2), and change:
–with-xml \
to:
–disable-libxml \
–disable-dom \
–disable-xml \
–disable-simplexml \
–disable-xmlreader \
–disable-xmlwriter \
or else install the missing rpms/packages for xml. (libxml2-dev and libxml2-utils on debian). Redhats:
yum -y install libxml2-devel libxslt-devel
FreeBSD:
pkg_add -r libxml2
pkg_add -r libxslt
On debian systems if using apt-get to install libxml2-dev and libxml2-utils doesn’t work, then install from source:
wget http://files.directadmin.com/services/customapache/libxml2-2.6.30.tar.gz
tar xvzf libxml2-2.6.30.tar.gz
cd libxml2-2.6.30
./configure
make && make install
then recompile php as usual.
