Nginx multiple php sites

B.R. reallfqq-nginx at yahoo.fr
Tue Jul 15 16:15:22 UTC 2014


I also think CodeIgniter needs the PATH_INFO environment variable set.

Moreover, there is a potential security breach in your current configuration
<https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/>
.
The recommended way (when using the same machine for front-end and back-end
services) it to use try_files to check for the existence of the invoked PHP
script. However, since using try_files with fastcgi_split_pathinfo wreaks
havoc (that *won't fix*, not a bug... oO)
<http://trac.nginx.org/nginx/ticket/321>, I would recommend patching you
PHP location like the following:

location ~^ \.php$ {
#    root  /var/www/example/; # You should follow Anoop piece of advice
    index  index.php;
    fastcgi_pass 127.0.0.1:9000;

    fastcgi_split_path_info ^(.+\.php)(/.*?)$;
#  $fastcgi_script_name is a system path to a file,
#  while $uri is... an URI which might not always correspond to a file
    try_files $fastcgi_script_name =404; # Checking PHP script existence

#  A trick to go beyond the bug/'feature' using try_files with
fastcgi_split_pathinfo
    set $path_info $fastcgi_path_info
    fastcgi_param PATH_INFO $path_info;

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}


Hope I helped,
---
*B. R.*


On Tue, Jul 15, 2014 at 4:31 PM, Anoop Alias <anoopalias01 at gmail.com> wrote:

> Perhaps this didnt work for you because you have
>
> root  /var/www/example/;
>
> in the php location . Move up the root in location / to the server {}
>  level and delete the root from php location . This is also the best
> approach as per nginX docs
>
>
>
> --
> *Anoop P Alias*
> GNUSYS <http://gnusys.net>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20140715/54e8236a/attachment.html>


More information about the nginx mailing list