I am trying to set up PHP on my server running nginx as reverse proxy. I have the following directive in the configuration file:
location ~ \.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
}
On opening any php script on the browser it says 500 Internal server error . If I completely comment out this directive, the browser throws a dialog box giving an option to download the php script. All other files like image files etc. in the same directory as the php scripts are accessible. Where can there be a problem?
EDIT: The configuration file
upstream the_server {
server localhost:8000;
}
server {
root /var/www/linux-dash-master;
listen 80;
client_max_body_size 4G;
keepalive_timeout 5;
log_format timed_combined '$sent_http_x_username - $remote_addr - [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" - '
'$request_time $upstream_response_time $pipe';
access_log /var/log/nginx/named.access.log timed_combined;
error_log /var/log/nginx/named.error.log debug;
location /linux-dash-master {
alias /var/www/linux-dash-master;
index index.html index.php;
}
# Pass PHP requests on to PHP-FPM using sockets
location ~ /linux-dash-master/.*\.php(/|$) {
alias /var/www/linux-dash-master;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_intercept_errors on;
if ($fastcgi_script_name ~ /linux-dash-master(/.*\.php)$) {
set $valid_fastcgi_script_name $1;
}
fastcgi_param SCRIPT_FILENAME /var/www/linux-dash-master$valid_fastcgi_script_name;
#fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
try_files $uri $uri/ /index.php?$args;
#include fastcgi_params;
}
location /static/ {
alias /path/to/staticfiles/;
}
location / {
proxy_pass http://the_server;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Remote-User-Name $remote_user;
}
}
Check /etc/php5/fpm/pool.d/www.conf
does it exist?
If so check inside it, look for a line that starts with listen
, does it point for a file or a port ?
Note that lines starting with ;
don't count
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.