Nginx Access PHP files file not found error handling, two cases

Source: Internet
Author: User
Tags fpm

Nginx Access PHP files file not found error handling, two cases

This error is common, there are two of the following

1. PHP-FPM could not find PHP files executed in Script_filename

2. PHP-FPM cannot access the PHP that is being executed, that is, the permissions issue

First case

It can be added to your location PHP to return 404 when the file does not exist, instead of handing it over to PHP-FPM.

Location ~ \.php$
{
...
#文件不存在转404
Try_files$uri = 404;
...
}

Then, in your configuration file, find the following paragraph

Fastcgi_param Script_filename/scripts$fastcgi_script_name;

Replace with the following Fastcgi_param script_filename $document _root$fastcgi_script_name;

Then reload the Nginx configuration file

Systemctl Restart Nginx
The second case

Two workarounds:
The first is to set your root folder to be allowed by other users
Second, find your php-fpm configuration file, find the following section, and replace Apache with the user group you want


; Rpm:apache choosed to being able to access some dir as httpd
user = Apache
; Rpm:keep a group allowed to write in log dir.
Group = Apache

Nginx Access PHP files file not found error handling, two cases

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.