Archive for February, 2010

mod_security & mod_deflate

By Mark Davidson on February 24th, 2010

Recently with having mod_security running on this server I noticed some errors in the mod_security logs in relation to content encoding

[22/Feb/2010:20:41:06 +0000] [][rid#7f5543ef1228][/wp-admin/load-styles.php][2] Warning. Operator EQ matched 0 at GLOBAL. [file "/etc/apache2/conf.d/modsecurity/modsecurity_crs_30_http_policy.conf"] [line "120"] [id "960903"] [msg "ModSecurity does not support content encodings"] [severity "WARNING"]

I did a bit of research into the error and found a good post on Klaubert’s Blog – modsecurity vs content compression he suggests a mod_deflate config. He also mentions gmane Mail Archive Rule 960903 – content encodings post where the orignal config is from.

The config file seems to work perfectly but I just thought I would make this post to add a bit of a step by step to making this configuration file work under a standard Ubuntu 9.04 install running mod_security as it is likely that all the required modules will not be enabled by default.

First enable the following modules

sudo a2enmod ext_filter
sudo a2enmod headers
sudo a2enmod filter

Next using your favourite editor start editing /etc/apache2/mods-enabled/deflate.conf and comment out the existing content then add the following.

<IfModule mod_deflate.c>
 ExtFilterDefine nodeflate mode=output cmd=/bin/true \

 SetOutputFilter DEFLATE

 # Netscape 4.x has some problems¦
 BrowserMatch ^Mozilla/4 gzip-only-text/html
 # Netscape 4.06-4.08 have some more problems
 BrowserMatch ^Mozilla/4\.0[678] no-gzip
 # IE is ok, but looked like Netscape, so we reset it
 BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

 SetEnvIfNoCase Accept-Encoding gzip force-gzip
 SetEnvIfNoCase TE gzip force-gzip

 RequestHeader unset Accept-Encoding
 RequestHeader unset TE

 # Skip images based on extension
 SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|zip|exe|swf|mp?eg|mp3|tgz|tar.gz|avi|ico|gz)$ no-gzip dont-vary

 # Make sure caching still works
 Header append Vary User-Agent env=!dont-vary

 <IfModule mod_security2.c>
 FilterDeclare modsec CONTENT_SET
 FilterProvider modsec modsecurity_out env=modsec-ignore !=1

 FilterDeclare compress CONTENT_SET
 FilterProvider compress deflate env=force-gzip =1
 #FilterProvider compress inflate Content-Type $image/jpeg
 #FilterProvider compress inflate Content-Type $image/gif
 #FilterProvider compress inflate Content-Type $image/png

 FilterProtocol compress "change=yes"
 <IfModule mod_security2.c>
 FilterChain modsec compress

 <IfModule !mod_security2.c>
 FilterChain compress

Lastly restart apache

sudo apache2ctl graceful

and thats it done this should allow for mod_security & mod_deflate to run on the server together without erroring.

WordPress Auto Backup & Upgrade

By Mark Davidson on February 20th, 2010

As everyone I am sure knows to well upgrading wordpress can be a bit of a pain, so based on a couple of other scripts I found around the net I created this script for automatically backing up and then upgrading a wordpress install.

What it basically does is if you give it the full path of a wordpress install it will automatically reads the config file and get the DB details, then perform a backup of the db, then a backup of the wordpress files and then finally an upgrade of the wordpress install.

To run just use `bash wpUpgrader /var/www/wordpress/`

Download the Script Here

# Linux WordPress Upgrader Script
# Mark Davidson | [email protected] |

function wpExtract {
	echo $(grep -o "define('$1', '\([^']*\)');" $WP/wp-config.php | cut -f 2 -d ' ' | awk '{ print substr($0, 2, length($0) - 4) }')


if [ $# = "1" ]; then
	# need to either force full path input or create canconical version
	# Validate that this directory is valid and contains wordpress files 
	BACKUP_DIR=$PWD/backups/wp/$(date +%s)
	echo "Creating Backup Directory"
	mkdir -p $BACKUP_DIR
	echo "Backup Directroy Created " $BACKUP_DIR

	echo "Backing up wordpress database"
	result=`mysqldump -u $(wpExtract DB_USER) -p$(wpExtract DB_PASSWORD) --database $(wpExtract DB_NAME) 2>&1 > blog.sql` 
	if [ -n "$result" ]; then 
		echo $result
		echo "Taring DB Backup"
		result=`tar -cf db.tar.gz blog.sql 2>&1`
		if [ -n "$result" ]; then
			echo "DB backup could not tared be created exiting"
			echo "DB backup tared"
			rm blog.sql

			echo "Creating Backup of WordPress Files"
			tar -Pzcf blog.tar.gz $WP

			echo "Checking Backup Integrity"
			result=`tar -dPf blog.tar.gz $WP`
			if [ -n "$result" ]; then
				echo "Integrity check failed"
				echo $result
				echo "Downloading Latest WordPress"
				wget -O $TEMP/latest.tar.gz
				tar -zxf $TEMP/latest.tar.gz

				result=`tar -ztf $TEMP/latest.tar.gz | grep wordpress/index.php | wc -l` # Really basic chek that file is intact proberly a better way to do this
				if [ "$result" = 1 ]; then
					echo "File OK"

					echo "Extracting WordPress"
					result=`tar -C $TEMP -xf $TEMP/latest.tar.gz` #TODO: Validate extraction
					echo $result

					cd $WP
					result=`cp -avr $TEMP/wordpress/* .`

					echo $result

					rm -rf $TEMP/wordpress $TEMP/latest.tar.gz

					echo "New files copied vist to complete the upgrade"
					echo "File Corrupt or missing"
	echo "Incorrect Number of Arguments"

I based this script off a few others I suggested checking them out

Upgrade wordpress quickly in 3 easy steps from UNIX shell prompt
wordpress update script
WordPress Auto-Update Script For A Linux Server
WordPress Upgrade Script 8 Month Review

By Mark Davidson on February 12th, 2010

Hi all I have now been using now for about 8 months and thought I would do a  small review to give a run down of my experiences over the months.

Why I Initially Choose

For 2 years I had a VPS with Tektonic but as I wanted more from my VPS, so I started to look around for another provider.
Your spoiled for choice if you do not mind where your hosting is located, but I decided that it would be best to select a provider located in the UK (Where I Live) or in Europe.

After looking around I narrowed my list of choices down to three different providers, Linode and
The Good

  • Good Specification on Hardware
  • UK Based
  • Hardware Firewall Protected
  • Load Balancing Available
  • Good Price if You Pay Yearly

The Bad

  • Considerably More to Pay Monthly
  • Big Steps Between the Pricing Plans
  • Limitied Distro Choice – CentOS, RedHat, Debian and Ubuntu.
    Since I am not a fan of RedHat based distros this does not give much of a choice.

The Good

  • Good Distro range including gentoo :)
  • IP Failover Support
  • HA and Clustering Support

The Bad

  • Not in the UK ( This was at the time Linode have now expanded and can provide Linodes in London)
  • Limited number of Linodes per data center
  • Big leaps when getting up to the higher end Linodes
The Good

  • Good pricing getting cheaper as you grow
  • Really good choice of distros including Gentoo :)
  • Scalable and really easy to upgrade due to node system
  • UK Based

The Bad

After checking out the three providers I had narrowed down and coming up with the good and bad points shown above, was the clear choice since I really could not find anything bad at that point.

My Experiences with a Single VPS running on a Single Node.

I started off with a single VPS using a single node. I decided to run Ubuntu 8.04 LTS on this and then upgraded to 9.04 on the VPS I was running about 8 or 9 low volume sites and it worked perfectly fine.
I didn’t have any issues what so ever with getting it installed but if I did for instance lock my self out of SSH offer a Console interface through he control panel which allows you to fix almost everything.

From One to Two Nodes

One of the best things about is how easy it is to upgrade a VPS. All you have to do to perform an upgrade is get some extra nodes each of which gives you 400Mhz CPU, 256MB RAM, 10GB Storage and 250GB Bandwidth. Once you have the nodes associated to your account you add them to a VPS, the VPS will restart and the added capacity will be added.

My Second VPS

My next VPS I set up was for development purposes and for this I wanted to run Gentoo. This was as easy as getting another node and then creating a new VPS. is one of only a few VPS providers that actually offer Gentoo and I really appreciate that they made the effort to support it.
I had a few issues getting the Kernel upgraded to the new version but the forum had the answer to my issue.

From Two to Three Nodes

Once again an easy process to perform the upgrade. I needed to do this to cope for a new high volume client with a lot of image processing it working really well. The server has held up well and I think using for client websites is really beneficial as its so easy to upgrade compared with other hosting providers.

My Third VPS

My latest VPS which I only setup two weeks ago to host this blog and a few other websites. I got it setup in like 10 minutes and that included installing Apache, PHP and MySQL manually.
It is great with the fact that the more nodes you have the cheaper it gets.

My Experience with Support

In the 8 months of using I have filled 10 support tickets most of them getting a response in under 10 minutes and I think the longer I waited was 30 minutes. Now that is the sort of support time that I appreciate.


In the time I have been with there has been maybe four bits of significant down time (significant being more than 10 minutes). If I remember right 2 of these times where due to DOS attacks and nothing could be done to prevent them but it got mitigated and steps have been taken to help prevent them in the future.
The other two times have been SAN issues as improve their architecture and when they get SAN V3 in place these issues should become less frequent.

To make sure to cover all my experiences there was a few days where I did experience really bad Disc IO but support looked into it and it is greatly improved now. Once SAN V3 is in place users will be limited to there Disc IO which should mean it will get better for everyone.

It is important to mention that are doing a lot of new and revolutionary stuff and there are bound to be problems. But I believe that with every day they get better and their services improve.

The Community has an excellent community there is lots of activity on the forum and people are always happy to help with issues. Its really good as there are quite a few members of the team who are really active on there and they can usually answer most questions if one of the other users does not get there first.

Always Improving

As I mentioned early I believe that one of the strongest points of is how they are improving and growing on almost a daily basis. Here are just a few features that have been added since I started using them which I think are really good.

  • Daily Nodes
    Need a quick boost of your VPS’s performance. Daily nodes are really handy if you just need a boost for a short period.
  • DNS Templates
    Most of the time when you set up DNS records there usually the same deal. Luckily community voices where heard and you can now create templates for your DNS records make it really easy to set up the appropriate DNS records for stuff like Google Apps.
  • New Images / Distro Support
    24 Turn Key Images
    20+ Optimized Images
  • Templates
    This is a really useful feature once you’ve got a server set up how you like it you can replicate the image and use it again for another VPS.
  • Forged Relationships have forged relationships with lots of different service providers. By doing this they can bring new services such as the monitoring provided by Server Density at a reduced cost.
  • Storage Nodes
    Although the node based architecture works really well some times you just need storage for instance if you’re wanting to run a backup server, a media server or something else.


So time for a quick summary. The good and the bad

The Good

  • Flexible
  • Support
  • Price

The Bad

  • Slight Teething Issues

So here is my last word I believe that if you’re looking for a good VPS provider in the UK is the way to go. Once they get other the teething issues the services will be almost perfect.
If you want to try them out use this discount code `AV408K` to get 25% off for the first month, also if you don’t mind please use this link which has my affiliate id associated to it which will get me a referral bonus another great feature of That’s it for now if you have any questions relating to or anything else I have mentioned here please leave a comment or email me and I’ll be happy to answer if I can.

Other reviews

The above has been my opinions but don’t just take my word for it check out these other reviews

Jake Gissing – VPS.NET after 4 month
Beyond Coding – Cloud Hosting: Slicehost, and Media Temple Comparison Review Review and discount code