open_basedir =./:/usr/local/php/lib/php/
这个,还是不行
php version 5.4.41
下面是报错,
2015/08/12 16:05:14 [error] 4786#0: *5 fastcgi sent in stderr: php message: php warning: require_once(): open_basedir restriction in effect. file(/usr/local/php/lib/php/pear.php) is not within the allowed path(s): (/home/wwwroot/editor.com:/tmp/:/proc/) in /home/wwwroot/editor.com/mail.php on line 46
php message: php warning: require_once(/usr/local/php/lib/php/pear.php): failed to open stream: operation not permitted in /home/wwwroot/editor.com/mail.php on line 46
php message: php fatal error: require_once(): failed opening required 'pear.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/editor.com/mail.php on line 46 while reading response header from upstream, client: 1
回复讨论(解决方案) 你看看 open_basedir 的值
当 open_basedir 非空的情况下,php 只能访问 open_basedir 指定的目录
phpinfo() 查看到是这个文件
loaded configuration file /usr/local/php/etc/php.ini
查看php.ini的值是
-------------------------------------------------------------------------------
; open_basedir, if set, limits all file operations to the defined directory
; and below. this directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file. this directive is
; *not* affected by whether safe mode is turned on or off.
; http://php.net/open-basedi
open_basedir =./:/usr/local/php/lib/php/#这个是我自己设置的
---------------------------------------------------------------------------------------------
[root@localhost ~]# ll /usr/local/php/lib/php/
total 84
drwxr-xr-x 2 root root 20 aug 12 14:41 archive
drwxr-xr-x 2 root root 4096 jun 12 16:22 build
drwxr-xr-x 2 root root 23 aug 12 14:41 console
drwxr-xr-x 5 root root 60 aug 12 15:16 data
drwxr-xr-x 9 root root 124 aug 12 15:16 doc
drwxr-xr-x 3 root root 38 jun 12 16:29 extensions
drwxr-xr-x 2 root root 6 aug 12 14:34 htdocs
drwxr-xr-x 3 root root 40 aug 12 15:16 http
drwxr-xr-x 2 root root 21 aug 12 15:16 net
drwxr-xr-x 2 root root 22 aug 12 14:41 os
drwxr-xr-x 11 root root 4096 aug 12 14:41 pear
-rw-r--r-- 1 root root 15188 aug 12 14:41 pearcmd.php
-rw-r--r-- 1 root root 34864 aug 12 14:41 pear.php
-rw-r--r-- 1 root root 1033 aug 12 14:41 peclcmd.php
drwxr-xr-x 3 root root 38 aug 12 15:16 services
drwxr-xr-x 3 root root 34 aug 12 14:41 structures
-rw-r--r-- 1 root root 20292 aug 12 14:41 system.php
drwxr-xr-x 9 root root 139 aug 12 15:16 test
drwxr-xr-x 3 root root 48 aug 12 15:16 text
drwxr-xr-x 2 root root 21 aug 12 14:41 xml
---------------------------------------------------------------------------------------
目录下面是有这个pear.php这个文件的
-----------------------------------------------------------------------------------
但是nginx 报错了以下的错
--------------------------------------------------------------------------------------
2015/08/13 09:51:38 [error] 635#0: *17 fastcgi sent in stderr: php message: php warning: require_once(): open_basedir restriction in effect. file(/usr/local/php/lib/php/pear.php) is not within the allowed path(s): (/home/wwwroot/editor.com:/tmp/:/proc/) in /home/wwwroot/editor.com/mail.php on line 46
php message: php warning: require_once(/usr/local/php/lib/php/pear.php): failed to open stream: operation not permitted in /home/wwwroot/editor.com/mail.php on line 46
php message: php fatal error: require_once(): failed opening required 'pear.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/editor.com/mail.php on line 46 while reading response header from upstream, client: 127.0.0.1,
-------------------------------------------------------------------------------------------------------------------------------
版本主你看看这个是什么问题?
不要设置 open_basedir
;open_basedir =./:/usr/local/php/lib/php/#这个是我自己设置的
pear 的路径要加在 include_path 中
按照版主的指示
---------------------------
; unix: /path1:/path2
include_path = .:/php/includes:/usr/local/php/lib/php/
;open_basedir =./:/usr/local/php/lib/php/ #我试了一下开启也不行
------------------------------------
重启了php-fpm 和nginx
结果还是报了这个错
-----------------------------------------------
2015/08/13 10:18:20 [error] 4110#0: *1 fastcgi sent in stderr: php message: php warning: require_once(): open_basedir restriction in effect. file(/usr/local/php/lib/php/pear.php) is not within the allowed path(s): (/home/wwwroot/editor.com:/tmp/:/proc/) in /home/wwwroot/editor.com/mail.php on line 46
php message: php warning: require_once(/usr/local/php/lib/php/pear.php): failed to open stream: operation not permitted in /home/wwwroot/editor.com/mail.php on line 46
php message: php fatal error: require_once(): failed opening required 'pear.php' (include_path='.:/php/includes:/usr/local/php/lib/php/') in /home/wwwroot/editor.com/mail.php on line 46 while reading response header from upstream, client: 127.0.0.1, server: editor.com, request: post /appbaseinfosaver.php http/1.1, upstream: fastcgi://unix:/tmp/php-cgi.sock:, host: editor.com, referrer: http://editor.com/appbaseinfo.php?t=new&tplt=capricorn
版本主你好,我这边 把问题解决了
最终是在nginx 里面加一加这个
fastcgi_param php_value open_basedir=open_basedir=$document_root:/usr/local/php/lib/php/:/tmp/:/home/wwwroot/;
