1. In the configuration of php. ini (/usr/local/php/etc/php. ini), find
Cgi. fix_pathinfo = 0
Change it
Cgi. fix_pathinfo = 1
2. Note the following in the nginx configuration file/etc/nginx/conf/nginx. conf:
The code is as follows: |
Copy code |
Location ~ . Php $ { Fastcgi_pass 127.0.0.1: 9000; Fastcgi_index index. php; Fastcgi_param SCRIPT_FILENAME/home/www/blog $ fastcgi_script_name; Include fastcgi_params; }
|
The red path must be set based on your host's main directory.
After configuring the preceding sections, restart nginx and php-fpm. The problem is successful.
In addition, it may be related to the path or permission, or the SCRIPT_FILENAME variable is not correctly set (this is the most common reason for nginx)
1) If the error 404 occurs in html, the document root settings are incorrect.
2) Check the permissions of the script file. PHP or web server may not be able to read it.
3) incorrect SCRIPT_FILENAME settings
Solution:
If the SCRIPT_FILENAME setting error is ruled out, the problem occurs in the access to directory folders and files. Reset the permissions of the www user group to immediately access the background. Here, I would like to express my special thanks to Ku Tong shoes.
The SSH command used to set permissions is
The code is as follows: |
Copy code |
Chown-vR www: www/folder |
Supplement: set parameters for my SCRIPT_FILENAME
Fcvim GI. conf (SCRIPT_FILENAME directory)
The code is as follows: |
Copy code |
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name; Fastcgi_param SCRIPT_NAME $ fastcgi_script_name; Fastcgi_param REQUEST_URI $ request_uri; Fastcgi_param DOCUMENT_URI $ document_uri; Fastcgi_param DOCUMENT_ROOT $ document_root; Fastcgi_param SERVER_PROTOCOL $ server_protocol; |
The corresponding document_root permission must be the same as that of nginx. conf and fcgi. conf.