Nginx, Apache, lighttpd prohibit directory execution PHP configuration sample _nginx

Source: Internet
Author: User

In order to enhance the security of the site, in addition to restricting directory permissions, we also need to disable a directory to prohibit the execution of PHP. In IIS, you can remove script execution permissions for a directory directly, but what about non-Windows systems?

The next article will simply introduce the different webserver How to disable PHP execution ....

Apache:

Copy Code code as follows:

<Directory/website/attachments>
Php_flag engine off
</Directory>

Nginx:

To disable a single directory:

Copy Code code as follows:

location/upload/{
Location ~. *\. (PHP)? $
{
Deny all;
}
}

To disable multiple directories:

Copy Code code as follows:

Location ~* ^/(upload|images)/.*\. (PHP|PHP5) $
{
Deny all;
}

LIGHTHTTPD:

Copy Code code as follows:

$HTTP ["url"] =~ "^/" (Forumdata|templates|customavatars?) /” {
Fastcgi.server = ()
}

Apache

<location "/forumdata" >
Php_admin_flag engine off
options-execcgi
AddType text/plain. html. htm. shtml. php
</Location>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.