Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+6 votes
5.0k views
in Q2A Core by
Same as subject.

4 Answers

+1 vote
by
If you can get nginx up and running with PHP and MySQL, it shouldn't be an issue.

Try this Google search for starters: http://www.google.com/search?q=nginx+php+mysql
+3 votes
by
edited by

it works for default URLs like

/index.php?qa=123&qa_1=why-do-birds-sing

For SEO optimized urls like this /123/why-do-birds-sing you need to set rewrite rule in nginx config

if (!-e $fastcgi_script_name) {
    rewrite ^/(.+)?$ /index.php?qa-rewrite=$1 last;
}

or if your question2answer root directory is q2a

rewrite ^/q2a/(.+)?$ /q2a/index.php?qa-rewrite=$1 last;

it works fine for me

by
try_files $uri $uri/ /index.php?qa-rewrite=$uri&$args;
by
This answer went perfect in my server.

Thanks.
–1 vote
by
edited by

For SEO optimized url & if root directory is different, below is the correct script

if (!-e $fastcgi_script_name) {
    rewrite ^/q2a/([a-z\/]+)(\?.+)?$ /q2a/index.php?qa-rewrite=$1&$args last;
}
by
This would not work at present where the q&a take the URL form /q2a/12/some-question as the number after q2a is not captured by your regex.

Also categories with symbols in URL will not work with this regex. For example Computers & IT category will become computers-%26-it in SEO friendly URL which will return a 404 for this regex you have given.

The regex in the answer above you by BubkaBob will work fine and is correct.
by
not work this        

and this work

 location /qa {
                index index.php index.html index.htm;
                 if (!-e $fastcgi_script_name) {
                rewrite ^/qa/(.+)?$ /qa/index.php?qa-rewrite=$1 last;
         }

}

-------------------------------------------------------------------------------------------------------------------------------
nginx -t
 service nginx restart
+3 votes
by

The other answers lead to 404's on all images etc for me. The one that worked for me was:

http://www.question2answer.org/qa/43081/the-correct-rule-of-rewrite-for-nginx

location / {
    index index.php index.html index.htm;
    if (!-e $request_filename) {
       rewrite ^/(.+)?$ /index.php?qa-rewrite=$1 last;
    }
}

by
This worked for me after a long period of try and error
...