以下三种设置方法均需要PHP版本为5.3或者以上。 方法1)在Nginx配置文件中加入
如果某个站点需要单独设置额外的目录,把上面的代码写在include fastcgi.conf;这行下面就OK了,会把fastcgi.conf中的设置覆盖掉。 这种方式的设置需要重启nginx后生效。 方法2)在php.ini中加入:
方法3)在网站根目录下创建.user.ini并写入:
关于.user.ini文件的详细说明: http://php.net/manual/zh/configuration.file.per-user.php 设置open_basedir的同时最好禁止下执行命令的函数,比如: shell_exec('ls /etc')仍然查看到/etc目录的文件列表 shell_exec('cat /etc/passwd')仍可查看到/etc/passwd文件的内容 建议禁止的函数如下:
|