nginx禁止运行php的设置方法:首先找到server配置段;然后在server配置段中增加配置“location ~* ^/uploads/.*\\.(php|php5)${deny all;}”即可。
衡山网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站等网站项目制作,到程序开发,运营维护。创新互联公司2013年成立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联。
推荐:《PHP视频教程》
Nginx下禁止指定目录运行PHP脚本
Nginx更简单,直接通过location条件匹配定位后进行权限禁止。
在server配置段中增加如下的配置
如果是单个目录
location ~* ^/uploads/.*\\.(php|php5)$
{
deny all;
}如果是多个目录
location ~* ^/(attachments|uploads)/.*\\.(php|php5)$
{
deny all;
}注意:这段配置文件一定要放在下面配置的前面才可以生效。
location ~ \\.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}*后给一个完整的配置示例
location ~ /mm/(data|uploads|templets)/*.(php)$ {
deny all;
}
location ~ .php$ {
try_files $uri /404.html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}配置完后记得重启Nginx生效。
本文标题:nginx如何禁止运行php
URL链接:http://cdysf.com/article/chdeej.html