s9y + nginx

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
the lobster
Regular
Posts: 5
Joined: Sun Oct 21, 2007 11:13 am

s9y + nginx

Post by the lobster »

Hi there,

I've got s9y running nicely with nginx and php/FCGI, with the only remaining issue being that I haven't yet converted the mod_rewrite RewriteRules to nginx rewrite directives.

Before I do this, has anybody already done it?

Cheers,
lobster
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

I had never heard of NGinx before your thread, but we have a lot of experts who visit here from time to time, unfortunately, most of them are unlikely to see your thread. It might be better to post a duplicate of this in the s9y mailing list at sourceforge. I'm not sure of its address but a quick search in these forums or on the wiki will probably find it.
the lobster
Regular
Posts: 5
Joined: Sun Oct 21, 2007 11:13 am

Post by the lobster »

Thank you Carl, I'll have a look.
the lobster
Regular
Posts: 5
Joined: Sun Oct 21, 2007 11:13 am

Post by the lobster »

Hey folks - couldn't find anything at all on the mailing list archives so I'll post a Q up there, but just bumping this in case it catches anyone's eye

Cheers
the lobster
Regular
Posts: 5
Joined: Sun Oct 21, 2007 11:13 am

Post by the lobster »

Well, couldn't find anything so did it myself and the conversion was way easier than I thought - the only issue causing a config error was the need to escape semicolons in character classes as nginx config format relies on semicolons.

So for anyone who wants to run s9y on nginx & php/FCGI (mmm, nginx is lovely), here's what I've found to work, just use this in place of the .htaccess file generated when you set "URL Rewriting" to "Use Apache mod_rewrite" with the default permalink structure:

Code: Select all

rewrite ^(/archives/[0-9]+-[0-9a-zA-Z\.\_\!\;,\+\-\%]+\.html/?)$    /index.php?arg=$1   last;
rewrite ^(/authors/([0-9]+)-[0-9a-z\.\_!\;,\+\-\%]+) /index.php?/$1 last;
rewrite ^(/feeds/categories/([0-9\;]+)-[0-9a-z\.\_!\;,\+\-\%]+\.rss) /index.php?/$1 last;
rewrite ^(/feeds/authors/([0-9]+)-[0-9a-z\.\_!\;,\+\-\%]+\.rss) /index.php?/$1  last;
rewrite ^(/categories/([0-9\;]+)-[0-9a-z\.\_!\;,\+\-\%]+) /index.php?/$1    last;
rewrite ^/archives([/A-Za-z0-9]+)\.html /index.php?url=/archives/$1.html    last;
rewrite ^/([0-9]+)[_\-][0-9a-z_\-]*\.html /index.php?url=$1-article.html    last;
rewrite ^/feeds/(.*) /index.php?url=/feeds/$1   last;
rewrite ^/unsubscribe/(.*)/([0-9]+) /index.php?url=/unsubscribe/$1/$2   last;
rewrite ^/approve/(.*)/(.*)/([0-9]+) /index.php?url=approve/$1/$2/$3    last;
rewrite ^/delete/(.*)/(.*)/([0-9]+) /index.php?url=delete/$1/$2/$3  last;
rewrite ^/(admin|entries)(/.+)? /index.php?url=admin/   last;
rewrite ^/archive/? /index.php?url=/archive last;
rewrite ^/(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml) rss.php?file=$1&ext=$2;
rewrite ^/(plugin|plugin)/(.*) /index.php?url=$1/$2 last;
rewrite ^/search/(.*) /index.php?url=/search/$1 last;
rewrite ^/comments/(.*) /index.php?url=/comments/$1 last;
rewrite ^/(serendipity\.css|serendipity_admin\.css) /index.php?url=/$1  last;
rewrite ^/index\.(html?|php.+) /index.php?url=index.html    last;
rewrite ^/htmlarea/(.*) htmlarea/$1 last;
rewrite (.*\.html?) /index.php?url=/$1  last;
Chuck that in, and off you go. Let me know if you find anything broken in it.

Do try nginx, seriously - it easily matches Apache in raw speed on static resource, and when the load goes up, Apache starts to cry, while nginx sings sweetly. The PHP performance obviously has to take a hit on the FCGI conversations but the overall effect is of great speed, stability, and small memory and CPU usage. Give it a go if you've had enough of Apache eating your machines.
chickens
Regular
Posts: 192
Joined: Wed Dec 06, 2006 12:15 am
Location: Vegas
Contact:

Post by chickens »

I've got a new server that is going to be provisioned within in 30min (according to the host). I am going to give nginx a try because everything I've read about it sounds amazing.
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

Hmmm, good to see you figured it out. Are you going to writeup a guide for other nginx users that explains the complete procedure? If so, could you post the URL so the rest of us can take a look. Now, how do I test nginx on my mac?
chickens
Regular
Posts: 192
Joined: Wed Dec 06, 2006 12:15 am
Location: Vegas
Contact:

Post by chickens »

carl_galloway wrote:Now, how do I test nginx on my mac?
Give me about 12 hours and I will give it a go on my laptop. I don't see any reasons for it not to install on OS X as it is *NIX based. There might be some dependency issues, but darwin ports should resolve that.
the lobster
Regular
Posts: 5
Joined: Sun Oct 21, 2007 11:13 am

Post by the lobster »

carl_galloway wrote:Hmmm, good to see you figured it out. Are you going to writeup a guide for other nginx users that explains the complete procedure?
I thought I just did!

Seriously though, the complete procedure just consists of "install s9y in your nginx document root, add these rewrites to your config file in the location section dealing with the location where you installed s9y, restart nginx".
chickens wrote:
carl_galloway wrote:Now, how do I test nginx on my mac?
Give me about 12 hours and I will give it a go on my laptop. I don't see any reasons for it not to install on OS X as it is *NIX based. There might be some dependency issues, but darwin ports should resolve that.
I don't know if it's in ports or fink or the like, as I don't use those, but it's a very straightforward build; the only hard dependency is a PCRE library, and you can use the PCRE library from www.pcre.org. Install Developer Tools, download nginx & PCRE (or maybe ports/fink will sort this out for you as "chickens" says, though if I recall correctly, worth noting is that the configure option to tell nginx where to find PCRE refers to the PCRE source, not an installation), compile, run. Documentation at http://wiki.codemongers.com/Main

It's just fine on Macs - I run it on Linux in production, but also use it on several Macs in the studio as it's an extremely good front end for routing variously to Apache 1/2 installations, PHP/FCGI, Rails/Mongrel, other stuff if you like, and it serves flat content itself, fast. It's a piece of cake to get going, it's straightforward to get more into once you find your feet, it's fast and flexible, it's got good virtual host support, it's got web and mail proxies built in, and it's written by a very clever Russian guy. What more could you want? ;-)
chickens
Regular
Posts: 192
Joined: Wed Dec 06, 2006 12:15 am
Location: Vegas
Contact:

Post by chickens »

on my home system (OS X) I just did the following to get it working

./configure
make
sudo make install
sudo /usr/local/nginx/sbin/nginx

done.

My system has a TON of devel stuff on it, so most dependencies are probably met there. I am now seeing a page that says "Welcome to nginx!" and its time to play with it locally.

My new host isnt giving me the root password for my new server, so I guess I've gotta play locally.
Post Reply