Home  >  Article  >  Operation and Maintenance  >  It is forbidden to upload directory to execute php script under linux

It is forbidden to upload directory to execute php script under linux

王林
王林Original
2020-04-25 10:39:533049browse

It is forbidden to upload directory to execute php script under linux

Can be achieved by modifying the nginx.conf configuration file.

The method is as follows:

Disable single directory:

location ~* ^/attachments/.*.(php|php5)$ {
deny all;
}

(Video tutorial recommendation: linux video tutorial)

Prohibit multiple directories :

location ~* ^/(attachments|upload)/.*.(php|php5)$ {
deny all;
}

Note:

1. The above configuration file code needs to be placed above location ~ .php{...}. If placed below, it will be invalid.

2. Attachments need to write relative paths, not absolute paths.

3. Don’t forget to restart nginx

service nginx restart

Recommended tutorial: linux tutorial

The above is the detailed content of It is forbidden to upload directory to execute php script under linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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