: 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.