nginx apache lighthttpd 禁止某个目录执行PHP文件

安全问题无小事,死生之地,存亡之道,不可不察也。有关web站点安全设置可以参见:nginx安全配置Linux下Apache安全配置策略lnmp架构下php安全配置分享确保nginx安全的10个技巧Linux系统必备安全配置

本文主要讲述针对nginx、Apache、lighthttpd三大web容器的针对某个特定的目录禁止执行PHP等程序。

nginx

 

1
2
3
4
5
6
location/upload/{
location~.*\.(php)?$
{
deny all;
}
}

 

1
2
3
4
location~*^/(upload|images)/.*\.(php|php5)$
{
deny all;
}

 

Apache

 

1
2
3
<Directory/webroot/attachments>
php_flag engine off
</Directory>

 

lighthttpd

 

1
2
3
$HTTP["url"]=~"^/(forumdata|templates|upload|images)/"{
fastcgi.server=()
}
点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注