This article describes the content of Nginx + php-fpm File not found. Problem solving records, with a certain reference value, now share to everyone, have the need for friends can refer to
Confirmation of the phenomenon:
Open the browser's developer tool to view the request information
http/1.1 404 Not Found
server:nginx/1.11.10
Date:fri, Apr 2018 08:10:13 GMT
content-type:text/html; charset=utf-8
Transfer-encoding:chunked
Connection:keep-alive
x-powered-by:php/5.6.30
Indicates that the result was returned by FASTCGI.
Cause of the problem:
The estimate is related to authority.
the same configuration, using the following two:
/opt/local/share/nginx/html /opt/local/share/nginx/html/php
Directories are available, but use:
/users/xxx/downloads/workforder
The directory is not available.
Viewing permissions through Ls-l, the difference is that
/users/xxx/downloads/workforder
The files in the directory do not have an extended attribute, that is, there is no @ symbol.
Then modify the nginx static file root directory to:
/users/xxx/downloads/workforder
Access appears:
403 Forbidden Error
Look at Nginx 403, find the cause of the problem, you need to modify the configuration file in the user and group.
The format of Nginx is:
User name/root owner, for example: User root owner;
PHP-FPM the respective modifications:
user = Rootgroup = Owner
and then restart.
PHP-FPM itself does not have the command to restart, compare pits! Can only kill the process.
Configuration file:
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /users/xxx /downloads/workforder; # root /opt/local/share/nginx/html/php; Fastcgi_pass 127.0.0.1:9000; Fastcgi_index index.php; Include fastcgi.conf; }
This shows only the parts that are relevant to PHP. When I join in the configuration
Try_files $uri = 404;
, you will see the returned by Nginx:
When you access a PHP file, you may see an error such as the following:
That is because FastCGI does not start and needs to be started:
sudo php-fpm- D
And if both Nginx and PHP point to the same directory, you will still see:
File not found