Italiano (Change) 
Per la piattaforma blog WordPress per funzionare correttamente con Nginx abbiamo bisogno di modificare la configurazione del server web. Questo tutorial consentirà ad entrambe le cache - integrando il plugin WP Super Cache - e attivare permalink pretty (FURL s, CURL s, tutto questo!) Con alcune semplici regole di riscrittura.
OK, allora sei un blogger Wordpress. Se non siete, agire rapidamente su. In caso contrario, e si desidera Nginx-succhi di frutta, tenerlo qui.
Perché visto che io sono tutti amati su WordPress, ea quanto pare è così il mondo e di sua sorella, e perché l'Onnipotente WP ha bisogno di un po 'TLC a vivere felicemente con il server Nginx, I'll precisare ciò che è necessario.
In 20 copia / incolla passi .. da zero a hero, vuota la casella di cute, come server Linux.
Scorrere verso il basso per l'indice completo della serie.
Così, hey, rimessa condivisi e viva virtuale! Hope it helps. The_guv
'Cos che gestisce il traffico pesante e accelera il vostro sito, Buster! Per maggiori informazioni su questo, vedere qui. In sostanza: --
Per convertire URI come www.xyz.com/r/default.asp?iID=HFJJLH&iPostID=JMMGD a www.xyz.com / pretty-please. In sostanza: --
Adorabile.
Se si desidera che solo i permalink, non il caching, skip a qui.
Creare un nuovo file: --
sudo nano /usr/local/nginx/conf/wordpress_params.super_cache
And in there, paste:-
# if the requested file exists, return it immediately
if (-f $request_filename) {
break;
}
set $supercache_file '';
set $supercache_uri $request_uri;
if ($request_method = POST) {
set $supercache_uri '';
}
# Using pretty permalinks, so bypass the cache for any query string
if ($query_string) {
set $supercache_uri '';
}
if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
set $supercache_uri '';
}
# if we haven't bypassed the cache, specify our supercache file
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
}
# only rewrite to the supercache file if it actually exists
if (-f $document_root$supercache_file) {
rewrite ^(.*)$ $supercache_file break;
}
# all other requests go to Wordpress
if (!-e $request_filename) {
rewrite . /index.php last;
}
Save and quit - CTRL-X and Enter.
If you've added the file above, ignore this section.
Create a file:
sudo nano /usr/local/nginx/conf/wordpress_params.regular
And paste this within:-
# WordPress pretty URLs: (as per dominiek.com)
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
rewrite ^(.+)$ /index.php?q=$1 last;
# Enable nice permalinks for WordPress: (as per Yawn.it)
error_page 404 = //index.php?q=$uri;
Save and quit (CTRL-X, 'y' to confirm, then Enter).
We'll link to either of those files now, from the virtual host file we created in Part 13: Serve Multiple Sites & Blogs with Virtual Hosts . If you have more than one standalone blog, as per Part 13, 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:-
sudo nano /usr/local/nginx/sites-available/waywiderweb.com
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:-
# Wordpress WP Super Cache plugin and permalinks. include /usr/local/nginx/conf/wordpress_params.super_cache;
If you want ONLY the friendly URLs
After the line index index.php index.html; , so before the } , paste this:-
# Wordpress permalinks. include /usr/local/nginx/conf/wordpress_params.regular;
Restart Nginx:-
n2r
Or, if you didn't follow Part 7: Edit bashrc for User-Friendly Linux , type:-
sudo /etc/init.d/nginx restart
Done. Check your site in a web browser.
I'd like to thank Matt Stevens and Gleb Esman for the Nginx integration.
That's it for pretty URIs, friendly URLs, FURLs, CURLs, permalinks or whatever else they're called. And we'll enable the caching when we install the WP Super Cache plugin. Talking of which, in the next how-to guide in this series, we do just that, using super-duper Subversion, with which we'll also simplify the WordPress installation process.
.. Damn, I'm good to you
Guess what ...
Serve multi sites & blogs on a budget .. at the fastest possible speed .. with the least downtime .. in the most secure environment .. and future-proofed for easy admin.
That's what the VPS Bible is about, stepped out in simple copy & paste guides.
From high traffic WordPress blogs to startup web hosts, here's what you need.
Set it up? Click here for the 21 part follow-up .. V-P-S Admin
» 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 [...]
sudo nano /usr/local/nginx/conf/wordpress_params.super_cache
- Intro: Set Up an Unmanaged VPS (4 Newbies) .. The V-P-S Bible
- VPS (Virtual Private Server) vs Shared vs Dedicated
- Set Up a VPS Linux Distribution *
- Set Up the Command Line Interface (CLI) using PuTTY *
- Create a Linux User & Set Permissions *
- Encrypt Data with OpenSSH & Auto-Login with PuTTY *
- Harden the Secure Shell (SSH) & Create a Firewall *
- Edit bashrc for User-Friendly Linux, plus System Updates *
- PHP5, MySQL, Xcache, Subversion (for Platforms like WordPress) *
- Add a Domain Zone to Your VPS *
- Prepare Linux Server for Email with Postfix *
- Nginx (better than Apache) Web Server *
- Setup FileZilla for Secure FTP (SFTP) *
- Serve Multiple Sites & Blogs with Virtual Hosts *
- Set up WordPress on Nginx with Pretty URLs & WP Super Cache *
- WordPress Setup & Updates from the Command Line *
- Nginx Control Panel
- Nginx Control Panel Workarounds
- Google Apps for Domain-Specific Email *
- Moving Day! How to Move Your Blog or Site
- Blogroll, Links, Credits, Resources
- * Includes video tutorial.
- Not linked = not published. Won't be long. Fix a feed for updates.
-
Create additional sites & blogs quickly & easily. After creating the DNS entries, just add a vhost file, its symlink, restart Nginx and go play.
OK. So I did this guide already, already! But as this is one [...]
-
Create sub-sites or prefixed WordPress blogs quickly & easily. Just create an A record, add a vhost file & symlink and restart Nginx.
This is very similar to adding a domain, which is detailed here and [...]
-
This how-to guide uses Subversion to download & install standalone WordPress blogs & their plugins, quickly and easily from your Linux command line interface, with simple updates thereafter. It also [...]
-
Welcome to the_guv's 20 part VPS how-to bible, complete with video tutorials.
If you are outgrowing your shared host, are paying big bucks for a managed VPS or want to rightsize from an old dedicated plan, this [...]
-
Bolt on PHP5 for server-side web applications, Xcache to speed things up and MySQL to handle our databases. And tweak that lot for optimum performance of platforms from WordPress to Drupal.
From the first seven [...]
-
Easily restrict access to hide sensitive data, admin areas & other web pages using the Nginx web server's Auth_Basic security module & the htpasswd password creation tool.
What we're gonna do, essentially, is to [...]
And in there, paste:-
# if the requested file exists, return it immediately if (-f $request_filename) { break; } set $supercache_file ''; set $supercache_uri $request_uri; if ($request_method = POST) { set $supercache_uri ''; } # Using pretty permalinks, so bypass the cache for any query string if ($query_string) { set $supercache_uri ''; } if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) { set $supercache_uri ''; } # if we haven't bypassed the cache, specify our supercache file if ($supercache_uri ~ ^(.+)$) { set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html; } # only rewrite to the supercache file if it actually exists if (-f $document_root$supercache_file) { rewrite ^(.*)$ $supercache_file break; } # all other requests go to Wordpress if (!-e $request_filename) { rewrite . /index.php last; }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:
And paste this within:-
# WordPress pretty URLs: (as per dominiek.com) if (-f $request_filename) { break; } if (-d $request_filename) { break; } rewrite ^(.+)$ /index.php?q=$1 last; # Enable nice permalinks for WordPress: (as per Yawn.it) error_page 404 = //index.php?q=$uri;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 Part 13: Serve Multiple Sites & Blogs with Virtual Hosts . If you have more than one standalone blog, as per Part 13, 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:-
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:-
If you want ONLY the friendly URLs
After the line index index.php index.html; , so before the } , paste this:-
Restart Nginx:-
Or, if you didn't follow Part 7: Edit bashrc for User-Friendly Linux , type:-
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. And we'll enable the caching when we install the WP Super Cache plugin. Talking of which, in the next how-to guide in this series, we do just that, using super-duper Subversion, with which we'll also simplify the WordPress installation process.
.. Damn, I'm good to you
Guess what ...
SETUP an Unmanaged VPS (4 Newbies) .. The V-P-S Bible
Serve multi sites & blogs on a budget .. at the fastest possible speed .. with the least downtime .. in the most secure environment .. and future-proofed for easy admin.
That's what the VPS Bible is about, stepped out in simple copy & paste guides.
From high traffic WordPress blogs to startup web hosts, here's what you need.
Set it up? Click here for the 21 part follow-up .. V-P-S Admin
If you liked that ...
Maintain Unmanaged VPS - Part 1: Add Web Sites Nginx Cheatsheet
Maintain Unmanaged VPS - Part 2: Adding Sub-Sites with Nginx
Set Up Unmanaged VPS (4 Newbies) - Part 15: WordPress Setup & Updates from the Command Line
Set Up Unmanaged VPS (4 Newbies) .. The V-P-S Bible
Set Up Unmanaged VPS (4 Newbies) - Part 8: PHP5, MySQL and Xcache (for Platforms like WordPress)
Maintain Unmanaged VPS - Part 13: Restrict Access to Nginx Web Files with Auth_Basic
... maybe you'll like these?
THE_GUV NEEDS YOU!!
.. to improve this post ..
Please clue me in. What's wrong or missing?
Or, hey, just pile on the praise ;) Ah, yup, and fix a feed, fella.
Or link the page to your social network!
thank you, thanx, tx, ta, t, tsst, twaddle, cheek, cheers, cheerio
» 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
)
... 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.