Phenomenon confirmation:
Open your browser's developer tools to view the request information
HTTP/1.1 404 Not Found
Server: nginx/1.11.10
Date: Fri, 20 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
Explain that the result is returned by FastCGI.
problem causes:
I guess it has something to do with permissions
The same configuration, using the following two:
/opt/local/share/nginx/html /opt/local/share/nginx/html/php
Directories are fine, but use:
/Users/xxx/Downloads/workForder
Directory does not.
Check the permissions through ls -l and find that the difference is
/Users/xxx/Downloads/workForder
The files in the directory have no extended attributes, that is, no @ sign.
Later, modify Nginx's static file root directory to:
/Users/xxx/Downloads/workForderAccess appears:
403 forbidden error
Look at nginx 403 again and find the cause of the problem. You need to modify the user and group in the configuration file.
The format of nginx is:
user your username/root owner; for example: user root owner;Respective modification of PHP-fpm:
user = root group = owner
Then reboot.
PHP-fpm itself has no restart command, which is quite pitiful! Just 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; }
Only the part related to PHP is shown here. when i add in the config
try_files $uri =404;
After that, you will see what is returned by Nginx:
When accessing PHP files, you may see errors like the following:
That's because FastCGI is not started 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