Arch Linux

LEMP setup (Linux/Nginx/MySQL/PHP)

I've moved this website (and a few other websites) to a Linode VPS. (Just before you ask, here's a Linode referral code --I get $20 in credit if you get to be their client :-P)

First I set it up as a LAMP server, but then I got several crashes once the load increased, as the httpd process was eating all available memory and was killed by the kernel... and mysqld was killed as well. So I decided to move it all to use Nginx instead of Apache.

I'm pretty impressed with Nginx performance! Now that I finally am getting to grips with it all, there's hardly any CPU usage and the disk IO graph is pretty quiet (before, the swap was used constantly, quite a nightmare).

Following are my notes on how I set up things--just in case I have to reinstall something in the future, though I hope that's not the case!

MySQL and PHP

MySQL was already installed and working correctly.

I had to install the CGI version of PHP


sudo pacman -S php-cgi

Spawn-CGI-PHP

Tried using simple php-cgi spawner but couldn't really set up an rc.d script equivalent to the popular init.d scripts. So I'm using Spawn meanwhile.

In rc.conf

Ensure the services are added to the list of things to be started!

mysqld spawn nginx # correct this list as I'm writing from memory

WordPress

The most annoying part has been WordPress which is as resource hungry as it can be.

Even with APC cache it is still super expensive to render a WP page, so the use of WP-SuperCache becomes a necessity rather than a preference. Otherwise CPU usage spiked as high as 90%. NOT NICE.


pear install pecl.php.net/apc

(might need to install pear first!)

Have a look at the source of pages when NOT logged in and ensure there's no error message at the footer. WP-Supercache places there its status messages.

Server monitoring on the cheapo


top -p $(pgrep -d',' php),$(pgrep -d',' mysql),$(pgrep -d',' nginx)

Various links