Home  >  Article  >  Backend Development  >  Nginx + PHP-fpm File not found. Problem solving record

Nginx + PHP-fpm File not found. Problem solving record

不言
不言Original
2018-04-23 17:22:5010514browse

The content of this article is about Nginx PHP-fpm File not found. Problem solving record, which has certain reference value. Now I share it with you. Friends in need can refer to it

Phenomenon confirmation:

Open the browser's developer tools and view the request information

<br>

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.

<br>

Cause of the problem:

<br>

It is probably related to permissions

<br>

The same configuration, using the following two:

/opt/local/share/nginx/html  
/opt/local/share/nginx/html/php

directory is OK, but using:

/Users/xxx/Downloads/workForder

directory is not .

Check the permissions through ls -l and find that the difference is that the files in the

<br>

/Users/xxx/Downloads/workForder

directory do not have extended attributes, that is, there is no @ symbol.

<br>

Later, the static file root directory of Nginx was modified to:

<br>

/Users/xxx/Downloads/workForder

Access 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: <br>

user 你的用户名/root owner;
比如:
user root owner;
## Modify #PHP-fpm respectively:

user = root
group = owner
<br> and then restart.

PHP-fpm itself does not have a restart command, which is quite confusing! The only way is to kill the process.

<br>

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 parts related to PHP are shown here. When I add

<br>
try_files $uri =404;
 后,就会看到由Nginx返回的:

<br>

## to the configuration, you may see an error like the following:<br>

That’s because FastCGI has not been started and needs to be started: <br>

sudo php-fpm  -D

And if Nginx and PHP both point to the same directory, then they will still see To:

File not found

The above is the detailed content of Nginx + PHP-fpm File not found. Problem solving record. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn