x64Architecture

Optimized WordPress Setup Guide (LEMP)

Updated: August 24th 2014

First off I am going tell you the specs of the VPS I am going to be doing this on: RAM: 1024MB OS: Debian Wheezy

MariaDB Install and Configuration:

First we are going to grab the signing key Then we are going to add the repo by issuing the following commands:

$ sudo apt-get install python-software-properties
$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
$ sudo add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/10.0/debian wheezy main'

Then to update the apt-get cache run the following command:

$ sudo apt-get update

And then run this command to install MariaDB:

$ sudo apt-get install mariadb-server

Now enter MariaDB by typing:

$ mysql -u root -p

When prompted enter your password for MariaDB and then issue the following commands(in order):

$ CREATE DATABASE wordpress;
$ GRANT ALL PRIVILEGES ON wordpress.* TO "wp_user"@"localhost" IDENTIFIED BY "INSERT_A_PASSWORD";
$ FLUSH PRIVILEGES;
$ EXIT

Now we are finished with the MySQL configuration and are going on to the PHP Install and Configuration.

PHP Install and Configuration

To install PHP and the PHP-FPM you have to issue the following command in order:

$ sudo apt-get install php5-fpm php-pear php5-common php5-mysql php-apcu php5-gd

Edit /etc/php5/fpm/pool.d/www.conf

Replace:

listen =

with:

listen = /dev/shm/php-fpm-www.sock

below that insert the following three lines:

listen.owner = nginx
listen.group = nginx
listen.mode = 0660

then replace:

user = www-data
group = www-data

with:

user = nginx
group = nginx

And then save the file, don’t worry about restarting PHP-FPM until we install nginx.

Nginx Install And Configuration

First we have to fetch the nginx signature.

$ wget -qO - http://nginx.org/keys/nginx_signing.key | sudo apt-key add -

Now we are going to add the APT source:

$ sudo add-apt-repository 'deb http://nginx.org/packages/debian/ wheezy nginx'

Now to Download and install nginx issue the following commands:

$ apt-get update
$ apt-get install nginx

Once the install completes we have to configure nginx for wordpress:

Next, create a new file, /etc/nginx/conf.d/etc with the contents of the etc file from Github

Then, replace /etc/nginx/conf.d/default.conf with the contents of the default.conf file from Github changing all entries for localhost to your own domain name.

to make a directory, /var/www/ and set the ownership run the following commands:

$ sudo mkdir -p /var/www/
$ sudo /usr/sbin/groupadd nginx
$ sudo /usr/sbin/useradd -g nginx -s /bin/false nginx
$ sudo chown nginx:nginx /var/www
$ sudo /usr/sbin/usermod -G nginx www-data
$ sudo chown nginx:nginx /var/www/
$ sudo chmod 775 /var/www

Now, were ready to install WordPress!

This is simple, run:

$ cd /tmp
$ wget http://wordpress.org/latest.tar.gz
$ tar zxvf latest.tar.gz
$ cd wordpress
$ sudo mv * /var/www/
$ sudo chown -R nginx:nginx /var/www

Now go in your web browser enter your host-name and set-up WordPress

Now once you’ve setup WordPress edit the permalink settings and press custom structure and put this or what ever structure you like:

/%postname%/ And now change all of your W3 Total Cache settings to your liking

And now save all the settings and you have successively set up an optimized WordPress LEMP server.