Nginx multiple php sites

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


Hi,
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
here.
I've two codeignetor (php framework) in two different folders and served
from same domain. For an example,

example.com  => /var/www/example/index.php
example.com/blog  => /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;
    server_name  example.com;

    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/;
        fastcgi_pass 127.0.0.1:9000;
        index  index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Thanks in advance.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,251802,251802#msg-251802



More information about the nginx mailing list