Page 6 WordPress via svn and setting up W3 Total Cache
The server is ready to install WordPress

Create your database

mysql  -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5340 to server version: 3.23.54
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> CREATE DATABASE databasename;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON databasename.* TO "user_name"@"localhost"
    -> IDENTIFIED BY "password";
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
mysql> EXIT

Install WordPress via SVN

cd /srv/www/yourdomain/public
svn co .

Add your database info to wp-config.php and install by visiting

Use the Compatibility Check in W3 Total Cache to make sure everything is set up right. Yours will look similar to this one.

Set page cache and minify to disk enhanced. Object and database to APC. You can experiment with page cache via APC but with Nginx disk enhanced will most likely be faster.

Final thoughts
If your doing this for the first time set up a test install to get the hang of if before you rely on this for a production set up or client site. Using Debian and the apt-get repos it’s pretty easy to manage your own dedicated server or VPS and you can lose the cPanel training wheels. Not only will your page load times drop you will have a good feeling of accomplishment.

To maintain your packages run apt-get update and apt-get upgrade every once in a while and you can follow @dotdeb on Twitter to stay up to date with upgrades.

Feel free to leave a comment or question. I would love to hear how this set up works for you.

Resources and further reading

23 Comments (Add Yours)

  1. just checking one thing: the w3 total cache rewrite rules are only needed if using disk cache, right?

    • Yes you really only need the W3 rules for disc cache. They just add a finer level of control for the browser cache rules. I just updated the server file to show a full example of the W3 Rules using disk enhanced page cache and disk minify.

  2. Hi,

    Great post, thanks a lot for the information. From the title I got the impression, you were going into the details of multiple wp installs with one ngnix or via multiple xen installs.

    Do you have any best practices about this? Or even some up to date ressources?

    Thanks again for the great post.

  3. I’ve got a noob question about SSH keys. If I’ve installed the SSH key on the server it means that I can only login to it from my computer right? What if I don’t have my computer with me and have an emergency and need to SSH into the server?

    • Using SSH keys you will only be able to login if your computer contains a private key that matches a public key installed on the server. I prefer the added added security they provide but if you often need to access your server away from your computer then maybe a really strong password would be better for you.

      If your using password authentication you can change the ssh port to prevent a majority of the brute force attempts. Also some VPS and dedicated server hosts have a java console you can use to access your server without having to use your ssh keys.

  4. Just a note that “you are” is shortened to “you’re”, not “your”.

    Otherwise, thanks for the great write up!

  5. Hey Guys:

    Awesome tutorial — my first foray into nginx w/ wordpress.

    A couple things I got snagged on in the tutorial & the fixes:

    > When installing everything the first ‘php5-mysql’ should be ‘mysql-server’ instead since there is already a php5-mysql package a little later in the command

    > There’s a missing closing ‘}’ at the end of the file in the sites conf

    > Upon trying to install wordpress I got “Your PHP installation appears to be missing the MySQL extension which is required by WordPress.” Fixed this by editing the php.ini inside the php-fpm dir.
    >> I un-commented ‘’ as well as uncommenting ‘extention_dir = “./”‘ and changing ‘./’ to /usr/lib/php5/20090626+lfs and all was well.

    Thanks again guys! Loving nginx so far!

  6. Hi

    Great guide thank you, I have one question about file ownerships/permissions.

    Presumably everything in my site’s public folder needs to be owned by www-data and in the www-data group?

    If so, how can I then upload and/or edit files when logged in as a non-root user? Do I just need to add my user to the www-data group?

    Any advice much appreciated, I find this bit quite confusing!

  7. Any recommendations for creating init scripts to ensure all the services start automatically after a reboot?

  8. -location ~ \.php {
    +location ~ \.php$ {

    -location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
    +location ~* \.(ico|css|js|gif|jpe?g|png)$ {

    -rewrite ^.*/files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
    +rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;

  9. Hi,

    Thanks for your tutorial, I finally get my wordpress working on LEMP stack.

    However, if any of your reader need the easy way to install wordpress, you can use
    Which is based on this tutorial.

    It assumes you’ve installed nginx, php-fpm, and mysql, and need multipe WordPress installed on multiple domains.

  10. For anyone else that finds this page, you may want to compare this install with as the lowendbox config gets rid of things that are not needed for installs on small vps accounts.


  11. Hi,
    Images in the post are not loading. Can you please rectify this? Thanks for the tutorial.

  12. Hi, using your guide to try and become a sys admin :) . Anyway, got stuck on the security bit. Have a windows machine so I used puttygen to make keys, got it moved over to the right spot, changed the things in the sshd_config I thought I was supposed to but can’t get in (using pageant).. Any thoughts?

    • Woohoo, figured it out… The file that puttygen created had some extra stuff in it. I nano’d in in the terminal you so wisely told us to keep open. deleted the contents, then pasted the actual code from the puttygen window and BAM. It’s working :)

  13. Great tutorial. I have a couple of questions though, hope you can help:
    1. I plan to have multiple WP sites, one of which will be multisite with subdomains. Which nginx.conf should I use?

    2. Curious to know how much memory this tutorial assumes.

    Thanks so much!!

  14. Great piece. One correct. SoftLayer is NOT “formerly ThePlanet”. SoftLayer was a fantastic host long before they *acquired* ThePlanet.

  15. Also, to add: “there is no need for Apache” is not true for most production environments. When Nginx gets real rewrite functionality, the ability to have mod_security equivalents etc, *without* a gazillion “IF” conditions in the config file (which according to Nginx itself slows down the server considerably) that’s when Nginx can survive on its own. Until then, sure there are websites running only Nginx with PHP-FPM, but they have sacrificed a lot of production quality stuff.

  16. For putty users on windows, here’s a tutorial on how to configure auto login.

Add Your Comment (Get a Gravatar)

Get a Gravatar! Your Name

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