Home > Backend Development > PHP Tutorial > lnmp cancels PHP execution permissions in nginx directory_PHP tutorial

lnmp cancels PHP execution permissions in nginx directory_PHP tutorial

WBOY
Release: 2016-07-13 10:30:13
Original
984 people have browsed it

First, edit the virtual host configuration of nginx and add the following content in front of the location statement of fastcgi:

1. Remove PHP execution permission from a single directory

Location ~ /attachments/.*.(php|php5)?$ {

deny all;

 }

Remove PHP execution permissions from the attachments directory.

2. Remove PHP execution permissions from multiple directories

Location ~ /(attachments|upload)/.*.(php|php5)?$ {

deny all;

 }

Remove PHP execution permissions from the attachments and upload directories.

Attached is a complete virtual host example for reference:

server

 {

Listen 80;

server_name www.45it.com;

 index index.html index.htm index.php;

root /home/wwwroot/bbs.vpser.net;include discuz.conf;

Location ~ /(attachments|upload)/.*.(php|php5)?$ {

deny all;

 }

Location ~ .*.(php|php5)?$

 {

fastcgi_pass unix:/tmp/php-cgi.sock;

fastcgi_index index.php;

include fcgi.conf;

 }

access_log off;

 }

After adding, execute: /usr/local/nginx/sbin/nginx -t to test the configuration file, execute: /usr/local/nginx/sbin/nginx -s reload to load the configuration file to make it effective.

Note: Pay attention to the order and must be placed above the line "location ~ .*.(php|php5)?$", otherwise it will not take effect.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/767401.htmlTechArticleFirst edit the virtual host configuration of nginx and add the following content in front of the fastcgi location statement: 1. Remove PHP execution permissions from a single directory location ~ /attachments/.*.(php|p...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template