I\'ve set up Nginx as my main web server and have two Mochiweb based servers behind it. Certain requests are reverse-proxied to these two servers. now, I want to access php
I struggled with this for hours now and none of the solutions discussed above worked to my case (since i needed to run index.php, index.php with arguments, and other php scripts than index.php), but finally reached the working configurations as the following:
location /php-app {
passenger_enabled off;
alias /path/to/php-app/$1;
index index.php index.html;
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/php-app(.*)$ /index.php?q=$1 last;
}
location ~ \.php$ {
alias /path/to/php-app/$1;
rewrite ^/php-app(.*)$ $1 last;
passenger_enabled off;
fastcgi_pass unix:/tmp/php-fpm.socket;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /path/to/php-app$fastcgi_script_name;
fastcgi_intercept_errors on;
}