为了加强网站安全性,我们除了限制目录权限外,还需要禁用某此目录禁止执行php。在IIS中可以直接将目录的脚本执行权限去掉,而针对非windows系统如何做呢?
接下来的文章将简单的介绍不同的webserver如何禁用php执行。。。。
php命令执行
Apache
1
<Directory /website/p_w_uploads>
2
php_flag engine off
3
</Directory>
Nginx
禁用单个目录:
1
location /upload/ {
2
location ~ .*\.(php)?$
3
{
4
deny all;
5
}
6
}
禁用多个目录:
1
location ~* ^/(upload|p_w_picpaths)/.*\.(php|php5)$
2
{
3
deny all;
4
}
lighthttpd
01
$HTTP["url"] =~ “^/(forumdata|templates|customavatars?)/” {
02
fastcgi.server = ()
03
}
04
05
Apache:
06
07
<Location “/forumdata”>
08
php_admin_flag engine off
09
Options -ExecCGI
10
AddType text/plain .html .htm .shtml .php
11
</Location>
转自:https://baoz.net/nginx-apache-lighttpd-disable-php/
转载于:https://blog.51cto.com/anonymouse/1890519