Setup VPS for Linux Noobs!




new password?
login
X
nginx wordpress logos image

For the blog platform WordPress to work properly with Nginx we need to tweak the web server configuration. This tutorial will enable both caching – integrating the WP Super Cache plugin – and activate pretty permalinks (FURLs, CURLs, all that!) with some simple rewrite rules.

OK, so you’re a WordPress blogger wanting Nginx-juice? Then keep it here.

Because seeing as I’m all loved up on WordPress, and apparently so is the world and her sister, and because the almighty WP needs a little TLC to live happily with the Nginx server, I’ll spell out what’s required.

Setup Unmanaged VPS: The Ubuntu-Nginx Guide

Take your virtual private server from zero to hero

  .. from blank box to cute-as server ..  

with this easy-to-follow copy/paste guide.

22+ parts with video, here’s the index.

Why bother with the WP Super Cache?

‘Cos it handles heavy traffic and speeds up your site, buster! For more on that, see here. Essentially:-

  • to Digg-proof your blog

As for permalinks?

To convert URI’s like www.xyz.com/r/default.asp?iID=HFJJLH&iPostID=JMMGD to www.xyz.com/pretty-please. Essentially:-

  • for usability
  • for SEO

Lovely.

WordPress Plugin WP Super Cache & Permalinks Bundle

If you want ONLY the permalinks, not the caching, skip to here.

Create a new file:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

And in there, paste:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Save and quit – CTRL-X and Enter.

WordPress Permalinks Without WP Super Cache

If you’ve added the file above, ignore this section.

Create a file:


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

And paste this within:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Save and quit (CTRL-X, ‘y’ to confirm, then Enter).

Configure Nginx for WordPress Permalinks & WP Super Cache

We’ll link to either of those files now, from the virtual host file we created in Serve Multiple Sites & Blogs with Virtual Hosts. If you have more than one standalone blog, as explained in that tutorial, you’ll have a vhost file for each, and must edit each of them.

Open the vhost file for each WP blog. For instance, for my site waywiderweb, which I’ve been exampling in this series:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

If you want BOTH the WP Super Cache and the friendly URLs

After the line index index.php index.html;, so before the }, paste this:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

If you want ONLY the friendly URLs

After the line index index.php index.html;, so before the }, paste this:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Restart Nginx:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Or, if you didn’t follow Edit bashrc for User-Friendly Linux, type:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Done. Check your site in a web browser.

I’d like to thank Matt Stevens and Gleb Esman for the Nginx integration.

Next Up, Installing WordPress & Other Platforms with Subversion.

That’s it for pretty URIs, friendly URLs, FURLs, CURLs, permalinks or whatever else they’re called. As for the caching, you’ll enable that you install the WP Super Cache plugin. First, we’d best install WordPress itself in the how-to guide WordPress Setup & Updates from the Command Line. That’ll be using super-duper Subversion to simplify the WordPress installation process.

.. Damn, I’m good to you ;)   Guess what …

Setup Unmanaged VPS: The Ubuntu-Nginx Guide

Take your virtual private server from zero to hero

with this easy-to-follow copy/paste guide.

“My local PC runs Windows” Show me for Linux/Mac

22+ parts with video, here’s the index ..

Manage Unmanaged VPS: Ubuntu-Nginx Administration

Already set it up? We’d best maintain it then.

Toggle to the ..  Ubuntu-Nginx Admin Index

Manage Unmanaged VPS: Ubuntu-Nginx Administration

Maintain your virtual private server with ..

.. cheatsheets, tutorials, tips & guides.

Head back to the ..  Ubuntu-Nginx Installation Index

Nginx Admin: In the Works ..

This lot’s marked for addition already:-

  • Setup or Edit DNS using Bind
  • Network Tools Troubleshooting Guide
  • The Comprehensive Permissions Guide
  • Configuring Nginx Rewrites
  • Custom Website Error Page
  • Setting up Cron Jobs
  • Rsync for Incremental Remote-to-Local Backup
  • Cron & Rsync for Automatic Backup
  • Cron & mysqldump for Auto DB Backup
  • Safeguard Bandwidth with Hotlink Protection
  • Block Access with Nginx’ IP Deny



Got a Question? Want to Comment?

This site has no comments system. We've got a better system!

Please use the link at the top of the post and goto this topic's forum thread:-

  • to help build community
  • for a superior knowledge base
  • to keep info in one place, not diluted between forum & comments.

For those posts ported from Guvnr.com (pre-Feb/2010), archive comments remain.

Handy info from these comments is in the process of being ported to the forum and attributed to the original author.

If you think this idea sucks, let me know.

Thank you.

  • » Setup bWordPress/b on NGINX (FURLs amp; Cache) - VPS Bible Pt 13 - GUVNR Wordpress UK: Wordpress UK, taking it further… June 2nd, 2009 at 8:08 pm

    [...] Read the rest here: Setup bWordPress/b on NGINX (FURLs amp; Cache) – VPS Bible Pt 13 – GUVNR [...]

  • Setup WordPress on NGINX (FURLs & Cache) - VPS Bible Pt 13 - GUVNR | Bloggers Tools June 2nd, 2009 at 8:14 pm

    [...] here to read the rest: Setup WordPress on NGINX (FURLs & Cache) – VPS Bible Pt 13 – GUVNR You May Like Linking To UsHello and welcome to our blog, you may consider linking to us, because [...]

  • kajdo June 2nd, 2009 at 11:22 pm

    nice one again

  • the_guv June 3rd, 2009 at 1:53 am

    cheers kajdo… pleased you like it, Sir.

  • Fartzilla June 5th, 2009 at 6:39 pm

    You know, over the years I have tried many different tutorials for many things and have always spent countless hours trying to work out why something didn’t work out only to find that it was because the author missed a “.” here, or a “/” there, or some other minor mistake which meant that I did not get the same result as the author.

    I am incredibly happy that I followed along your tutorials to date and there hasn’t been a single error, everything has happened just the way you explained. Thanks heaps, you are doing a great job!

  • the_guv June 5th, 2009 at 8:08 pm

    Wow! Fartzilla (God’s teeth, what kind of a name is that :P )
    … I don’t think I’ve before received such praise. You might have used a larger font!
    I am honoured, thank you.
    Darn kind, and I’m really rather chuffed it’s working out so well for you.

  • eric June 6th, 2009 at 8:01 pm

    hi nice vps bible, other than when i am trying to run the way you have instructed i keep getting this error

    2009/06/06 18:00:04 [error] 30448#0: *4 rewrite or internal redirection cycle while processing “/index.php”,

  • the_guv June 7th, 2009 at 8:06 pm

    tx eric .. sorry to hear you’ve got a problem. surely a rewrite issue.

    assuming you’ve done everything literally code for code, it will work. it’s 100% tested.

    there’s a discrepancy between what I say and what you’ve done, most likely in either Part 13 or here.

    …try again, retracing your steps carefully.

    if that doesn’t work, or you already have tried – let me know exactly what you want to achieve, if anything, with your rewrite ruleset and any even seemingly insignificant discrepancies (ie vps provider and linux distro) and maybe i or someone here can advise.

    best of luck

  • Install/Upgrade WORDPRESS with SUBVERSION - VPS Bible #15 - GUVNR June 11th, 2009 at 12:56 pm

    [...] Part 14: * Set up WordPress on Nginx with Pretty URLs & WP Super Cache [...]

  • custard July 14th, 2009 at 2:45 pm

    Great stuff. thanks guv.

  • the_guv July 14th, 2009 at 3:59 pm

    @custard .. big cheers.

  • Otto July 17th, 2009 at 5:47 pm

    Simpler rule for pretty permalinks (no super-cache):

    try_files $uri $uri/ /wordpress/index.php;

    That’s it. Easy. Works fine.

  • the_guv July 19th, 2009 at 11:17 am

    @Otto .. nice tip, thank you. Will try that.

  • LnddMiles July 21st, 2009 at 6:48 pm

    Pretty cool post. I just stumbled upon your blog and wanted to say
    that I have really liked reading your blog posts. Anyway
    I’ll be subscribing to your blog and I hope you post again soon!

  • the_guv July 25th, 2009 at 11:30 am

    @LnddMiles .. you are clearly a wise and sensible person! thank you.

  • Elena August 4th, 2009 at 5:33 pm

    thanks very helpful

  • trav 19 August 6th, 2009 at 7:08 pm

    Good morning, guvnr,
    I’m trying to install WordPress Mu but I’m a little apprehensive about using the conf we made along with the supercache referenced in it.

    on the page below this link, there’s a portion for the rewrite to be used in nginx servers:
    http://codex.wordpress.org/Installing_WPMU

    should i follow that? Do I delete everything in the one we made? Have you tried installing Mu with BuddyPress with the same conf + supercache?

    I found this one but it doesn’t have supercache :(
    http://buddypress.org/forums/topic/nginx-re-write-rules

    should i use that?

    This one has supercache…
    http://mu.wordpress.org/forums/topic/11705

    Will that work? I’m not sure which one to delete, add, combine or what not. Thank you for your time, sir!

  • the_guv August 6th, 2009 at 9:00 pm

    Howdy Trav 19,

    I’ve set up MU + BP but haven’t had a chance to play with it properly yet. Maybe too late for you, it’ll be a few weeks before I crack out my findings.

    That looks to be a top guide at WP. Their rewrite rule should just need to go in your vhost file, in the server block. Follow the other steps they set out too though, DNS and so on.

    Try it, and let me know, I’m curious, and lots of other folks will be too.

  • Martonic August 26th, 2009 at 4:15 pm

    Damn, that sound’s so easy if you think about it.

  • nick September 19th, 2009 at 4:40 am

    how do you get wordpress running with wp-ecommerce and able to add a product to your shopping cart on nginx?

  • the_guv September 23rd, 2009 at 10:12 am

    @Martonic .. I must tighten up my spam filter ;)

    @Nick .. now come on, get it together! I mean, that’s kind of like asking, what’s the best way to cook up spuds?

    tell me what you want to achieve, what factors to expect and then maybe i can give you some idea.

  • Alan aka Hyperdude October 16th, 2009 at 1:23 pm

    @Nick.. I too have had a few problems with the wp-ecommerce plugin. I have feeling that it may be something to do with the permissions settings. Not sure if the authors of the plugin have ever tested with nginx? But I can’t imagine that nginx is the cause of the problem.

  • the_guv October 16th, 2009 at 2:07 pm

    ah, @Nick .. that’s a plugin is it?! Probably best if I try to read a comment before replying, hmmn. Er, no idea about that though, sorry.

  • Jean October 25th, 2009 at 5:41 pm

    Hi Guv, i’ve been following your tutorials with much thanks. I have a question as pretty permalinks don’t work for my WP (It’s always a 404 except if default is chosen in my WP permalinks settings) If my wp blog were at domain.com/blog instead, do I have to change the location of the vhost file ? (sudo nano /usr/local/nginx/sites-available/domain.com)?

    I’m sorry if this is a really stupid question, I’m really, really new to CLI & VPS/linode. Thank you so much!

  • Test of URL Rewrite without .htaccess | Economatix October 27th, 2009 at 8:11 am

    [...] guvnr.com [...]

  • the_guv October 28th, 2009 at 7:16 pm

    @Jean .. yes, you are on the right track, a little tweaking of that vhost will do the trick .. post it up and I’ll take a look.

  • 10 Tips To Make WordPress Hack-Proof. The Ultimate Guide. - GUVNR November 2nd, 2009 at 12:05 am

    [...] Set Up Unmanaged VPS BIBLE (4 Newbies) – Part 14: Tweak Nginx for WordPress – Pretty URLs & WP… For the blog platform WordPress to work properly with Nginx we need to tweak the web server configuration. This tutorial will enable both caching – integrating the WP Super Cache plugin – and activate pretty [...] [...]

  • thanh November 9th, 2009 at 5:05 pm

    I followed these instructions and everything works. One question remains, is it possible to make the backend of wordpress allow installing plugins without asking for FTP login/password. I use to be able to install wordpress plugins via the wordpress backend on my on Cpanel host. Just was wondering if it’s possible with nginx.

  • the_guv November 11th, 2009 at 3:11 pm

    @thanh, good to hear. sure is possible .. just use the Add New option in the Plugins panel of your WordPress Dashboard .. that’s what I tend to do and it’s a great WP feature, giving an array of suggested plugins when you input a specific plugin name or keywords .. but then of course there is also Subversion which is darned handy, for instance, when you relocate a blog or set up one anew, and have a generic list of plugins that you want to install as a plugin ‘base’.

    That subversion method is covered in WordPress Setup & Updates from the Command Line. Installing subversion is covered in PHP5, MySQL, Xcache, Subversion (for Platforms like WordPress).

    .. i never use that ftp login/pass method. i guess some folks like it.

  • Moses December 14th, 2009 at 11:15 am

    Thanks for these great guides Guvnr, loving it so far.

    Could I suggest at the end of this one you mention the way to check that the cache is working is to view the last line of your pages’ source code and see the created time. Then refresh the page and check that it’s served the prior page.

    Cheers,
    Moses.

  • PREVENT DOWNTIME! Seamless Site/Blog Move: VPS BIBLE - vpsBible February 10th, 2010 at 5:00 pm

    [...] For WordPress, you best also check out Set up WordPress on Nginx with Pretty URLs & WP Super Cache. [...]

  • Configure Nginx with Your Content Management System - vpsBible March 10th, 2010 at 6:17 pm

    [...] Set up WordPress on Nginx with Pretty URLs & WP Super Cache [...]