SMF on nginx.

Started by viulian, November 19, 2007, 02:35:51 AM

Previous topic - Next topic

viulian

Hi guys!

I have installed SMF on nginx. The trickiest part was getting PrettyURL SEO module to work (as the rewrite rules must be changed).

Here are the new rules that work for me:


location /smf/ {
                index index.php;
                rewrite ^(/smf)/([-_!~*'()$a-zA-Z0-9]+)/[0-9]?/?$ $1/index.php?pretty%3Bboard=$2.0 last;
                rewrite ^(/smf)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/[0-9]?/?$ $1/index.php?pretty%3Bboard=$2.$3 last;

                rewrite ^(/smf)/([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/[0-9]?/?$ $1/index.php?pretty%3Bboard=$2%3Btopic=$3.0 last;
                rewrite ^(/smf)/([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/[0-9]?/?$ $1/index.php?pretty%3Bboard=$2%3Btopic=$3.$4 last;
        }


Installation is otherwise simple, it works by default :)

nginx is a lightweight and stable web server, with low memory footprint. Works great (I have managed to install it into an Ubuntu 6.06 image running inside coLinux with 256Mb RAM - goal was to find how the system behaves in low memory conditions). I am looking for a VPS and seems that price goes up exponentially with the memory you need :)

I hope nginx to solve the issue with Apache + mod_php eating a lot of memory.

I also have Wordpress MU integrated with SMF, the rules for that I don't have yet, but I'm working on that.
You can visit my site here, where I'll post more info about the issue..

Anyway, SMF is impressive. It works like a charm!
Thank you SMF team!

Nao 尚

Sounds interesting... :) Apart from your feedback on installing PrettyURLs on your server, can you share how easy/difficult it is to install nginx as opposed to Apache? And is there anything to remember when setting up a SMF install?
I will not make any deals with you. I've resigned. I will not be pushed, filed, stamped, indexed, briefed, debriefed or numbered.

Aeva Media rocks your life.

H

viulian, thanks for posting these :)

I normally use lighttpd as my webserver but I've noticed that the English nginx docs are getting better now so I might give it a try :)
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

viulian

Thank you for the feedback :)

Apart from compiling (plus downloading the dependencies), and setting up PHP to run as fast-cgi server, there's one think you should remember:

export PHP_FCGI_CHILDREN=2
export PHP_FCGI_MAX_REQUESTS=1000

If you do not set these variables before invoking php-cgi, your php-cgi process will die very soon without any error message. By default (I didn't check in detail though, and by default I mean without them set), php-cgi runs without any children, and it doesn't restart itself after handling a certain number of requests. And so it will die after a while.

I will post an nginx installation tutorial soon and will let you know..

Here's the forum URL (most if it is in Romanian, check it for speed and Pretty URL links).
Please remember that Blogs in the upper right doesn't work yet - I have to make the WPMU rewrite rules and I didn't have time this week.

Something like that

I *just* moved my forums over to a dedicated server. But I couldn't just do that! I had to play with new stuff ;)

I also have SMF running on nginx, and I also compiled APC into PHP. Lets just say things are screaming fast :D

Nao 尚

I will not make any deals with you. I've resigned. I will not be pushed, filed, stamped, indexed, briefed, debriefed or numbered.

Aeva Media rocks your life.

viulian

Nice :)

Have you activated nginx-stats ?

What I like though about nginx.. is that I completed the install a month ago, and ever since the memory stays at 182Mb (I am running inside a virtual private server / open vz ) along with DJBDNS and qmail. Zero memory leaks. Impressive :)

Something like that

Quote from: viulian on December 26, 2007, 02:18:26 AM
Nice :)

Have you activated nginx-stats ?

I wasn't aware of it. I'll look into it!

QuoteWhat I like though about nginx.. is that I completed the install a month ago, and ever since the memory stays at 182Mb (I am running inside a virtual private server / open vz ) along with DJBDNS and qmail. Zero memory leaks. Impressive :)

Yeah, unlike lighttpd. My nginx is using about 3 MB of RAM. The PHP processes leak a little, but it's only a few MB before the 10,000 hit limit kills the process. I'm still running email on another host, but I'll change that later...

viulian

More than one year or so has passed since I run SMF (and gallery2 on that matter) on nginx ..

Small review: everything is almost perfect :) minus a small inconvenience related to the fcgi wrapper (php-cgi processes).

Somehow when the machine is heavily loaded, they fail and do not timeout - so I need to kill all the processes and restart. And then it works, even if the machine is still with more than 3.00 load.

However, this has only happened like 5-6 times so far.. in more than 1 year so no biggie..

Memory usage has slowly increased, probably due to the mysql databases which keep getting bigger and bigger and mysql trying to accomodate.
I am now at 200Mb compared to 170Mb a year or so ago - so I bow in respect for nginx, qmail, dropbear, djbdns, mysql and SMF. Setup is the kind of configure and forget.

The only weak link in it is php-cgi, but on the other hand I might need to upgrade it..

Something like that

I've been using Nginx for almost two years now, and I'll never go back. It's so much faster, lighter, and solid.

Schokobecher

I know this is quite old, but a new thread would be a waste.

I'm running SMF 2.0 RC3 and the 1.0 PrettyURLs Module.

My problem is that if I activate the rewrite rule for boards, the action rewrites won't work. They just redirect to the index.php.
If I comment that line out all is fine.

My rules:

#rewrite ^/([-_!~*'()$a-zA-Z0-9]+)/[0-9]?$ "/index.php?pretty;board=$1.0" last;
rewrite ^/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/[0-9]?/?$ "/index.php?pretty;board=$1.$2" last;
rewrite ^/([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/[0-9]?/?$ "/index.php?pretty;board=$1;topic=$2.0" last;
rewrite ^/([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/[0-9]?/?$ "/index.php?pretty;board=$1;topic=$2.$3" last;



rewrite ^/(activate|admin|announce|ban|boardrecount|buddy|calendar|cleanperms)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(collapse|convertentities|convertutf8|coppa|deletemsg|detailedversion|display|dlattach)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(dumpdb|editpoll|editpoll2|featuresettings|featuresettings2|findmember|help|helpadmin)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(im|jsoption|jsmodify|lock|lockVoting|login|login2|logout)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(maintain|manageattachments|manageboards|managecalendar|managesearch|markasread|membergroups|mergetopics)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(mlist|modifycat|modifykarma|modlog|movetopic|movetopic2|news|notify)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(notifyboard|optimizetables|packageget|packages|permissions|pgdownload|pm|post)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(post2|postsettings|printpage|profile|profile2|quotefast|quickmod|quickmod2)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(recent|regcenter|register|register2|reminder|removetopic2|removeoldtopics2|removepoll)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(repairboards|reporttm|reports|requestmembers|search|search2|sendtopic|serversettings)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(serversettings2|smileys|smstats|spellcheck|splittopics|stats|sticky|theme|moderate)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(trackip|about:mozilla|about:unknown|unread|unreadreplies|viewErrorLog|viewmembers|viewprofile)/?$ "/index.php?pretty;action=$1" last;
rewrite ^/(verificationcode|vote|viewquery|who|\.xml)/?$ "/index.php?pretty;action=$1" last;



I'm also trying to ge the profile rewrite to work.
The original is the following:

'rule' => 'RewriteRule ^profile/([^/]+)/?$ ./index.php?pretty;action=profile;user=$1 [L,QSA]',

So I tried:

rewrite ^/(profile)/?$ "index.php?pretty;action=profile;user=$1" last;

but it results in a 404 Error.

Any clues on that?

Something like that

I've personally never used quotes in my Nginx rewrites. Is it just the first 4 lines that aren't working for you?


For your profile rewrite, you didn't put the / in front of index.php.

Something like that

Quote from: Schokobecher on June 29, 2010, 05:59:56 PM
My problem is that if I activate the rewrite rule for boards, the action rewrites won't work. They just redirect to the index.php.
If I comment that line out all is fine.

My rules:

#rewrite ^/([-_!~*'()$a-zA-Z0-9]+)/[0-9]?$ "/index.php?pretty;board=$1.0" last;


I suspect you the problem is not escaping the regular expression control characters from the string you wish to capture. Try this:


rewrite ^/([\-\_\!\~\*\'\(\)\$a-zA-Z0-9]+)/[0-9]?$ "/index.php?pretty;board=$1.0" last;

Schokobecher

The missing / was a typo.
Now it always stays on the index.php

The Forum Rewrite still breaks the action rewrites.
I'm so puzzled.

viulian

I have the same issue - but is not bothering me - I live happily with a very old PrettyURL.
First, the module is for search engine optimization. I want to be ranked by the content and not by profile/management/etc keywords. So I left them all off.

nginx has a 'debug_connection' directive, which you can activate for your IP in the 'events' section of nginx.conf.
It will show why it doesn't match the URLs and what is attempting to do - hopefully it can help (I mean it helped me a lot when debugging those first 4 lines...)

Kill Em All

Schokobecher, I'm going to mark this as solved, if you have any further problems please start your own topic.

@viulian, very glad your happy with it.


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

Advertisement: