来自http://tunps.com/php-open_basedir
在php写了句require_once ‘../Zend/Loader.php’; 报错:Warning: require_once() [function.require-once]: open_basedir restriction in effect. File(../Zend/Loader.php) is not within the allowed path(s): (D:\phpnow\vhosts\zf.com;C:\Windows\Temp;) in D:\phpnow\vhosts\zf.com\index.php on line 6 Warning: require_once(../Zend/Loader.php) [function.require-once]: failed to open stream: Operation not permitted in D:\phpnow\vhosts\zf.com\index.php on line 6 Fatal error: require_once() [function.require]: Failed opening required '../Zend/Loader.php' (include_path='D:\phpnow\vhosts\zf.comZend;.;C:\php5\pear') in D:\phpnow\vhosts\zf.com\index.php on line 6字面分析是受到了open_basedir的限制,造成Operation not permitted(操作不被允许)。 打开php.ini跳转到open_basedir相关设置段落:
; 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. ;open_basedir =如果设置了open_basedir,那么所有能被操作的文件就只能限制在open_basedir指定的目录里面。 这个在虚拟主机里面这个指令相当有用。不管安全模式是否打开,这个指令都不受影响。 看来php.ini没有设置open_basedir。 打开apache虚拟主机配置文件:
<virtualhost *> <directory "../vhosts/zf.com"> Options -Indexes FollowSymLinks </directory> ServerAdmin admin@zf.com DocumentRoot "../vhosts/zf.com" ServerName zf.com:80 ServerAlias *.zf.com ErrorLog logs/zf.com-error_log php_admin_value open_basedir "D:\phpnow\vhosts\zf.com;C:\Windows\Temp;"</virtualhost> |