NGINX/PHP-FPM access to PHP files without running the direct download

Source: Internet
Author: User

When you encounter this problem, first confirm that you are in the Web server configuration. PHP is not assigned to FASTCGI server processing:

Location ~ . php$ {    127.0.  0.1:9000;}

If configured, it may be caused by an incorrect path to the Fastcgi_script_name access script.

Especially with subdirectories, for example, for YII frameworks, the path is usually project/web

Then if you access/project/index.php in the URL, then the script_name in the Nginx configuration will be the full path: project/index.php

If the code in your configuration is as follows:

Fastcgi_param script_filename $document _root$fastcgi_script_name;

Then the actual access to the file is/var/site_root/project/web/project/index.php, which is obviously not the result we want, we want to visit is/project/web/index.php.

These errors can be traced by looking at the Php-fpm.log (error log).

The workaround is to modify the appropriate path configuration.

Note: Multiple sites use subdirectory configuration to refer to:

https://rtcamp.com/wordpress-nginx/tutorials/multisite/subdirectories/in-a-subdirectory/

NGINX/PHP-FPM access to PHP files without running the direct download

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.