A few years ago I was converted; I stopped using Apache, and started loving NGINX (engine-ex). In terms of system resources, there is a major advantage. Also, in terms of administering virtual hosts, there are a number of tuning options that offer an advantage for unique workloads via PHP-FPM (which is used to serve PHP requests to NGINX).
Unlike Apache, which loads PHP within each instance of it’s server, NGINX instead routes dynamic PHP requests to PHP-FPM. FPM can then spin up additional instances depending on the scale of it’s requests. So can NGINX. Vanilla Apache does not scale like that, instead runs at full load all the time.
In this tutorial I’m going to walk through my setup for serving WordPress with NGINX and Ubuntu 14.04. We’re not going to get into advanced configuration, just get setup for a basic server, which would be comfortable for your average developer or basic WordPress site.
If I spin-up a VPS (Digital Ocean, Amazon Web Services, Rackspace, Dreamhost), I will usually pick Ubuntu 14.04 (if I can) or Debian, otherwise we’re likely hosting on a virtual machine or physical hardware. Physical hardware setup is a lot like VM, so I’ll refer to them both as VM. Local VMs will need a source ISO, for which I will use Ubuntu mini iso to build out 14.04 and gather dependencies from the internet during install. VPS providers likely provide a full Ubuntu server or Debian install with things like Open SSH Server already installed. Ubuntu mini does ask which packages you’d like to install, with the following screen.
Select the top two, “Basic Ubuntu Server” & “OpenSSH Server”. Click the space bar to check the boxes, enter to commit. If you can’t SSH into your box, you need to install SSH, with the following command. Additional SSH tutorials can be found
here at a later date.
NGINX & WordPress Dependencies
During install you will be asked to provide a MySQL password, about twice. Make sure to use the same password. If your box is dedicated for development, there isn’t a glaring reason to have a password (it can be blank).