server {root /srv/www;location / { index index.html index.htm; }location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /src/www$fastcgi_script_name; include fastcgi_params; }}
In the directory/srv/www there are index.html index.php two files, Access localhost/index.html, localhost to display the normal/srv/www/ Index.html the contents of the page, but accessing the index.php file does not Found, do you know what's going on? In this case, is not nginx should be sent to the/srv/www/index.php file to listen to the PHP parser in 127.0.0.1:9000, and then through its parsing to return the contents of the parser to the client? I do not know where the problem, I hope to help answer the next
Reply content:
server {root /srv/www;location / { index index.html index.htm; }location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /src/www$fastcgi_script_name; include fastcgi_params; }}
In the directory/srv/www there are index.html index.php two files, Access localhost/index.html, localhost to display the normal/srv/www/ Index.html the contents of the page, but accessing the index.php file does not Found, do you know what's going on? In this case, is not nginx should be sent to the/srv/www/index.php file to listen to the PHP parser in 127.0.0.1:9000, and then through its parsing to return the contents of the parser to the client? I do not know where the problem, I hope to help answer the next
Estimated to be your nginx fpm configuration problem.
My side of this, has been used a number of sites:
server { listen 80; ## listen for ipv4; this line is default and implied root /www/web; index index.html index.htm index.php; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.html; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; }}
Look at the FPM error log and locate the problem in minutes!
location / { index index.php index.html index.htm;}
The first file needs to be identified with index.php in index
Here's the problem:
server {root /srv/www;#srv目录location / { index index.html index.htm; }location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /src/www$fastcgi_script_name; #src目录 include fastcgi_params; }}
Other than that:
The following section is best written in this way:
location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000;# fastcgi_pass unix:/var/run/php5-fpm.sock;#这行和上面一行二选一。 fastcgi_index index.php; include fastcgi_params;}