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

不言
Release: 2023-03-24 18:16:01
Original
10628 people have browsed it

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


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.


Cause of the problem:


It is probably related to permissions


The same configuration, using the following two:

/opt/local/share/nginx/html  
/opt/local/share/nginx/html/php
Copy after login

directory is OK, but using:

/Users/xxx/Downloads/workForder
Copy after login
Copy after login
Copy after login

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
Copy after login
Copy after login
Copy after login

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
Copy after login
Copy after login
Copy after login

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;
Copy after login
## Modify #PHP-fpm respectively:

user = root
group = owner
Copy after login
<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;

         }
Copy after login
Only the parts related to PHP are shown here. When I add

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

<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
Copy after login
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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template