Nginx/php-fpm access php files for direct download without running

Source: Internet
Author: User
: This article mainly introduces how nginxphp-fpm can directly Download PHP files without running them. if you are interested in PHP tutorials, refer to it. This problem is usually caused by incorrect fastcgi_script_name access script path.

Especially when there are subdirectories. for example, for the Yii Framework, the path is usually project/web

If you access/project/index. php in the URL, 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;

The actually accessed file is/var/site_root/project/web/project/index. php. this is obviously not the result we want. what we want to access is/project/web/index. php.

These errors can be tracked by looking at the php-fpm.log (error log.

The solution is to modify the corresponding path configuration.

Note: To configure sub-directories for multiple sites, refer:

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

The above introduces nginx/php-fpm to access PHP files for direct download without running, including some content, hope to be helpful to friends who are interested in php tutorials.

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.