zoukankan      html  css  js  c++  java
  • Nginx+Php中限制站点目录防止跨站的配置方案记录

    Nginx+Php中限制站点目录防止跨站的配置方案记录(使用open_basedir)-------------------
    方法1)在Nginx配置文件中加入:

    1
    fastcgi_param  PHP_VALUE  "open_basedir=$document_root:/tmp/:/proc/";

    通常nginx的站点配置文件里用了include fastcgi.conf;,这样的,把这行加在fastcgi.conf里就OK了。
    如果某个站点需要单独设置额外的目录,把上面的代码写在include fastcgi.conf;这行下面就OK了,会把fastcgi.conf中的设置覆盖掉。
    这种方式的设置需要重启nginx后生效。

    方法2)在php.ini中加入

    1
    2
    3
    4
    [HOST=www.wangshibo.com]
    open_basedir=/home/www/www.wangshibo.com:/tmp/:/proc/
    [PATH=/home/www/www.wangshibo.com]
    open_basedir=/home/www/www.wangshibo.com:/tmp/:/proc/

    这种方式的设置需要重启php-fpm后生效。

    方法3)在网站根目录下创建.user.ini文件,并在该文件中写入下面信息:

    1
    open_basedir=/home/www/www.wangshibo.com:/tmp/:/proc/

    这种方式不需要重启nginx或php-fpm服务。安全起见应当取消掉.user.ini文件的写权限。

    php.ini中建议禁止的函数如下:

    1
    disable_functions = pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_w
  • 相关阅读:
    给C盘瘦身的秘诀
    电化学词汇大全
    Scrapy学习-(1)
    数学部分分支关系总结,有修改的欢迎留言。
    BindingException: Mapper method 'xxx.dao.StudentDao.insertStudent' attempted to return null from a method with a primitive return type (int).
    insertSale attempted to return null from a method with a primitive return type (int).
    Maven [ERROR] 不再支持源选项 5。请使用 7 或更高版本
    Python中字符串型数组--转换为-->数字型数组
    18、pywintypes.com_error: (-2147221008, '尚未调用 coinitialize。', none, none)
    17、ModuleNotFoundError: No module named 'pywin32_bootstrap'
  • 原文地址:https://www.cnblogs.com/fengzhongzhuzu/p/8780096.html
Copyright © 2011-2022 走看看