I’ve decided to switch off the www portion of my website. Following in the no-www.org spirit I implemented the code to force redirects to the non-www version a couple of days back.
Here’s the code that they recommend on their website.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

However, there’s a problem with that code. If some of your URL’s have query strings after them (page.php?this=that&number=200) the parameters won’t be passed over to the new URL. Here’s the correct code to use as is running here.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.sdjl\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://sdjl.co.uk/$1 [QSA,L,R=301]

The only difference being the QSA option at the end of the last line. Simple!


Litespeed LogoI decided to take the plunge and get rid of Apache for something with a smaller footprint and twice the power: Litespeed.
I got a little tired of having to constantly monitor apache as it frequently took up too much memory and affected other services. Sometimes this resulted in my VPS having services killed off for too much memory usage by Virtuozzo.

As I write this, Litespeed is currently running at 14.4MB RAM usage and 0.1% CPU usage. Compare that to Apache swallowing a whopping 80MB+ or RAM, not to mention CPU time you can probably see why switching over to Litespeed is a good idea!
The main selling point of Litespeed for me was the easy replacement of Apache on a WHM/cPanel server. It’s very easy to configure Litespeed to utilise the Apache configuration files that WHM/cPanel writes to. This has the benefit of being fully integrated into the custom tools that WHM and cPanel use in their respective control panels.

Here’s a very quick guide on how to install it.

wget http://litespeedtech.com/packages/3.0/lsws-3.3-std-i386-linux.tar.gz
tar -xvfz lsws-3.3-std-i386-linux.tar.gz
cd lsws*
./install.sh

Once you’ve run through the configuration interface you can now setup Litespeed to load the Apache configuration file. Login through the new administration interface and click Configuration -> Server. Change the following.

Load Apache Configuration => Yes
Auto Reload On Changes    => Yes
Apache Configuration File => /usr/local/apache/conf/httpd.conf
Apache Port Offset  => 2000

You do have the option to enable PHP suEXEC for additional security, although if you enable this you won’t be able to use an opcode cache like APC.

Once you’ve made sure that Litespeed is functioning correctly, you can go back to the above configuration and change the Apache Port Offset to 0 and then disable Apache.
For more thorough guides on how to setup Litespeed and a custom PHP install, I’d suggest visiting Litespeed Install and Litespeed custom PHP.


I’ve lost count how many times I’ve needed to recompile a new version of APC for PHP on my server, so this mainly serves as a reminder on how to do it for next time.

  1. Go to http://pecl.php.net/package/APC and find the latest download link at the time.
  2. Login via SSH and go into root login via
    su -
  3. Navigate to the source folder:
    cd /usr/local/src
  4. wget the latest download from the PHP pecl link above. (i.e. wget http://pecl.php.net/get/APC-3.0.15.tgz)
  5. Unzip the archive like so:
    gunzip -c APC-3.0.15.tgz | tar xf -
  6. Navigate to the APC folder:
    cd APC-3.0.15
  7. phpize the APC folder to make the correct configuration file: /usr/bin/phpize
  8. Make the configuration file:
    ./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/bin/php-config
  9. Start the compile:
    make
  10. Finish and install:
    make install
  11. Edit the php.ini file to enable the APC module based on the location provided from the previous command:
    pico -w /usr/lib/php.ini
  12. Finally restart apache to see the changes:
    service httpd restart

The important bits you need to put inside php.ini are the extension call like so:

extension = "apc.so"

You then also need to enable and configure APC to your liking. Here’s my setup:

apc.enabled = 1
apc.shm_size = 64
apc.ttl = 3600
apc.user_ttl = 3600
apc.optimization = 0
apc.filters = "-Gallery.*\.class, wp-cache-config, -mint.php"
apc.include_once_override=1
apc.write_lock=1

Other things you need to take into account is your PHP extension_dir setting. This needs to be set right to be able to load the module correctly above.
You should also bear in mind that /usr/bin/phpize and /usr/bin/php-config could be different for your system setup.


I installed the latest version of Apache last night and enabled a new module that wasn’t previously available under Apache 1.3; mod_deflate. This gives the following speed and size improvements over generally every page hosted here.

Size Improvements

By adding the following code to httpd.conf once mod_deflate is compiled into apache you too can achieve similar results.

SetOutputFilter DEFLATE
DeflateFilterNote ratio
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

I had a bit of a problem earlier on with my server. Exim, the bit that handles email, decided to eat up resources, which caused the Virtuozzo operating system to kick into action and start killing off processes that were eating up too much RAM. This left my server with just Apache and MySQL running.

Read the rest of this entry »

lotsa emails this way!