我们经常会把网站的图片文件上传目录设置为只可上传文件但不能执行文件,就是要禁止执行权限,小编来给大家举一个上传目录配置,禁止执行权限方法,各位可参考。

如果不让有执行权限最简单的办法

 代码如下 复制代码

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

上面的方法满足不了我要求,后来找到一个不错的脚本

 代码如下 复制代码

server
        {
                listen       80;
                server_name xxxx.com;
                index index.html index.htm index.php default.html default.htm default.php;
                root  /home/wwwroot/xxxx.com;

include none.conf;

#匹配多个上传目录
                location ~ ^/(Upload|Upload1)
                {
                        # 匹配文件最名包含两个.以上的文件
                        location ~ "([.]{2,})$"
                        {
                                deny all;
                        }
                        # 配置php和php5后缀
                        location ~ ".(php|php5)$"
                        {
                                deny all;
                        }
                }

location ~ .*.(php|php5)?$
                {
                                try_files $uri =404;
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fcgi.conf;
                }

location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
                {
                                expires      30d;
                }

location ~ .*.(js|css)?$
                {
                                expires      12h;
                }

access_log off;
        }

nginx下禁止dedecms目录php执行权限的配置方法。

如下配置即可:

 代码如下 复制代码

location ~ /mm/(data|uploads|templets)/*.(php)$ {
deny all;
}

location ~ .php$ {
    try_files $uri /404.html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    includefastcgi_params;
}

nginx上传目录配置,禁止执行权限的更多相关文章

  1. php+nginx上传文件配置

  2. 文件图片上传目录 禁止执行php

    apache配置上传目录禁止运行php的方法 导读: 禁止上传目录运行php等可执行文件可以从一定程度上增加网站的安全性, 禁止上传目录运行php的方法可以用.htaccess文件, 也可以直接在ap ...

  3. 上传网站后建议执行:chown www:www -R /path/to/dir 对网站目录进行权限设置,/path/to/dir替换为你网站目录。

    上传网站后建议执行:chown www:www -R /path/to/dir 对网站目录进行权限设置,/path/to/dir替换为你网站目录.

  4. IIS中的上传目录权限设置问题

    虽然 Apache 的名声可能比 IIS 好,但我相信用 IIS 来做 Web 服务器的人一定也不少.说实话,我觉得 IIS 还是不错的,尤其是 Windows 2003 的 IIS 6(马上 Lon ...

  5. 解决百度ueditor配置上传目录为外部目录时,项目启动访问不到图片的问题。

    如图所示,公司项目用到了百度的ueditor,配置的上传目录并不在项目根目录下,而是在外部目录中.于是在上传图片时,出现了无法获取图片的问题. 解决方法:添加该目录至tomcat项目部署目录中,如下图 ...

  6. nginx上传模块nginx_upload_module和nginx_uploadprogress_module模块进度显示,如何传递GET参数等。

    ownload:http://www.grid.net.ru/nginx/download/nginx_upload_module-2.2.0.tar.gzconfigure and make : . ...

  7. nginx上用fastcgi配置python环境

    费了2天的功夫,翻阅了无数的中文.英文资料,终于搞定.写下此文留待以后翻阅用      本文环境,centOS 5.4 ,Nignx-0.8.49, Python 2.6.5   ========== ...

  8. php文件上传参考配置与大文件上传

      PHP用超级全局变量数组$_FILES来记录文件上传相关信息的,在php文件上传之前,可通过调节php.ini中相关配置指令,来控制上传相关细节. 1.file_uploads=on/off   ...

  9. nginx上传文件

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

随机推荐

  1. Android核心分析之二十六Android GDI之SurfaceFlinger

    Android GDI之SurfaceFlinger SurfaceFinger按英文翻译过来就是Surface投递者.SufaceFlinger的构成并不是太复杂,复杂的是他的客户端建构.Sufac ...

  2. linux 系统优化

  3. 311. Sparse Matrix Multiplication

    题目: Given two sparse matrices A and B, return the result of AB. You may assume that A's column numbe ...

  4. Makefile 快速入门

    Makefile 速成 标签: Makefile编译器 2015-06-06 18:07 2396人阅读 评论(1) 收藏 举报  分类: C/C++(132)  Linux & MAC(19 ...

  5. USACO Section 3.3: Home on the Range

    到最后发现是DP题 /* ID: yingzho1 LANG: C++ TASK: range */ #include <iostream> #include <fstream> ...

  6. USACO Section 3.2: Stringsobits

    这题看了网上的答案的.还是很巧妙的 /* ID: yingzho1 LANG: C++ TASK: kimbits */ #include <iostream> #include < ...

  7. Android 动画 setVisibility 后出错解决方法

    ===先说明下背景. 写的是个ListView 设置 adapter,并在列表末尾显示加载更多,点击 加载更多 时, 变成一个 圆环形的加载动画和 正在加载. 说明下,这个 加载动画是自己做得,一个圆 ...

  8. 干货:yii日志功能详解

    转载请注明来自souldak,微博:@evagle 一.基本日志功能 详细的介绍查看官网的document:http://www.yiiframework.com/doc/guide/1.1/en/t ...

  9. js调用高德API获取所在当前城市

    可以在js代码中直接调用API接口,获取所处当前城市信息,代码如下: <script type="text/javascript"> function getCurre ...

  10. SQLServer2008 行转列2

    with a as ( select numb,name,row_number() over( partition by numb order by name desc) rowid from fen ...