Nginx multiple php sites

devsathish nginx-forum at
Tue Jul 15 13:15:51 UTC 2014

I've been searching (last two days) to find how to setup multiple php sites
using nginx. Couldn't find any documentation around it, hence writing it
I've two codeignetor (php framework) in two different folders and served
from same domain. For an example,  => /var/www/example/index.php  => /var/www/example/blog/index.php

I made the first one to work using the following code. Can someone help me
to modify this config to fit the second requirement?!
(the configurations I tried doesn't pass the query strings - hence pasting
the working version)

server {
    listen       80;

    location / {
        root   /var/www/example/;
        try_files  $uri  $uri/ /index.php?$args;
        index index.php index.html index.htm;

    location ~^ \.php$ {
        root  /var/www/example/;
        index  index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

Thanks in advance.

Posted at Nginx Forum:,251802,251802#msg-251802

More information about the nginx mailing list