Google PageSpeed Apache and Ubuntu - Chasing Ghosts
Yes this really is off one of my WordPress sites 🙂

I must say that as an Ubuntu server operator Running Apache 2.4, MySQL and a bunch of WordPress sites, making sure my server is always running optimally is a big priority … and so it should be. But there can come a time when we find ourselves fiddling with default settings in Apache, MySQL and Ubuntu itself with no reason other than trying to get that 99% or 100% pagespeed from the mighty Google.

Now let me begin by saying, I have been such an operator. A 97% pagespeed ranking just wasn’t quite 99% and hence the fiddling with settings began and in all vain …. to absolutely no bloody no avail.

90% of my sites sit in the 90-97% range on Pagespeed and only about 3 sites of mine score about 88% but that has always been something that has made me chase the higher results and quite honestly it was a waste of time.

Make no mistake, testing your web sites against various web site speed tests like GTMetrix, PageSpeed Insights, and Pingdom is a very good thing to do and most certainly there are issues you can sort out on your sites, especially WordPress sites, that will be identified by running such tests. So yes yes yes …. you must test your web sites and server performance by running these tests and running them frequently in the beginning to know how to fine tune your server.

The problem comes in when you start Googling for how to optimize Apache, how to Optimize MySQL and all sorts of other Google queries you may come up with and soon you will find yourself finding lots of advice that actually does not apply to you.

Google PageSpeed Apache and Ubuntu - Chasing Ghosts
Perfectly beautiful results, even some very heavy web sites in this list. This overview prompted me to write this article and to stop chasing the PageSpeed dream or Ghosts.

You see in most cases an Ubuntu server with Apache and MySQL running with default settings should actually give you pretty good performance out of the box, assuming you know the basics of setting those up which is not what this article is about.

When you start Googling for advice on optimizing Apache and MySQL you will often find people recommending settings which are designed for high end servers running hundreds or thousands of web sites where every Mb of memory and resources counts. Those solutions do not apply to you nor did they apply to me but it did not stop me fiddling anyway.

Hopefully I can save you some time and a lot of frustration.

Start off with a stock Apache and MySQL server, use it and test your WordPress or Joomla sites for a few days or weeks using the above online testing tools.

If then you want to start fiddling with anything my only advice is the following:

A) Make sure that in /etc/apache2/apache2.conf you have HostNameLookups Off

B) Switch from the default mpm_Prefork module to the mpm_event module. If you don’t know what this means then you shouldn’t be reading this anyway. The mpm_Event module is a threaded module for serving Apache requests it is super fast and eliminates many bottlenecks in the worker and prefork modules. If I switch between the two modules I can see a difference so I know mpm_event is faster. It is also less susceptible to crashing or freezing which used to happen lots with the other modules, especially when the server was being hammered by DDOS attacks. I have never had the mpm_event module lock up yet whereas in the past I would often have Apache go down when I was on the Prefork module. To switch to the mpm_event module do the following.

sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
sudo service apache2 restart

That’s it, your Apache server is now running with the threaded mpm_event module. (also read this)

C) As far as WordPress goes, do not use a bunch of plugins you do not need, I highly advise using only plugins you do need and you do absolutely need. A slow plugin can cause serious page loading issues for your site. If you ever have a slow WordPress site, disable each and every single plugin and then test with the online test tools listed higher in this article. If you see a difference, then enable them one at a time doing a test each time until you find the culprit.

As far as anything else goes I really would not fiddle. The default settings in the mpm_event.conf file are more than adequate, I can guarantee you they are. I changed mine to some suggested settings which had no effect at all on performance. Those settings did not decrease performance at all they just did ZERO and ZIP to improve them. Even I have since switched back to the default settings in mpm_event.conf and I am soon to review any MySQL settings I fiddled with in the past to make sure there is also no unnecessary bloated or inappropriate settings.

So if there’s a lesson here for all of you it’s don’t fiddle unless you know what you are fiddling for. If your server is running fine then simply don’t mess with it. Hopefully you can learn from my past mistakes and better spend your time doing something much more useful.

And one parting thought, Google does not know everything. Google is run by human beings just like you and mean although they have been elevated to God Status by the internet world and be serious with yourself, they are not God nor do they claim to be. Use Google PageSpeed as a guide, don’t let it dominate your entire existence because while you fret away, Google and all their employees won’t lose a wink of sleep.

This article is intended to be a real basic guide of NOT-TO-DO’s with an Ubuntu, Apache and MySQL server. By no means is this the defacto guide to all guides and there are many security specific steps not mentioned in this article. I will post many more articles showing you how to secure your Apache server and how to protect yourself from online attacks but I will save that for another day. Keep a regular watch on Ubuntu101.

For Now …. it’s time to say adieu ….. it’s time for my couch, my hubby and my telly !!!!!

Happy Nixing !!!


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.