Home >Backend Development >PHP Tutorial >Nginx+php fastcgi Access Denied occurs
Nginx+php fastcgi Access Denied
2014-06-10 18:10 4901 people readComments (0)CollectReport
Cause analysis:
PHP officially added a configuration "security.limit_extensions" (/usr/local/php/etc/php-fpm.conf) starting from 5.3.9. By default, only files with the extension ".php" are allowed to be executed. This caused the problem that other types of files were not supported.
If the address you request is a resource like css js png, it will be rejected by php. If you request http://localhost/user (implying http://localhost/user/index.php), it will not work either.
Solution
1. Some people modify the php configuration file to add allowed extensions such as security.limit_extensi .html .js .css .jpg .jpeg .gif .png .htm#
But this is actually It’s bad because static resources should not be processed by php fast-cgi
2, (recommended) use nginx’s rewrite
location ~ .(js|css|gif|jpg|jpeg|png)$ {
root D :/tmp;
}
location ~ .php$ {
root using using use with using using using through out through out through out through out out through out out through out together’sole together outce out out out out out out out off ’ s ’ ‐ ‐ ‐ ‐ down ‐ to / {
, SCRIPT_FILENAME D:/tmp/film/$fastcgi_script_name;
include $1/index.php;
}
This can better solve the problem. The first location filter type may not be enough, you can add it according to your own needs
The above has introduced Access Denied in Nginx+php fastcgi, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.