phpnow:open_basedir restriction in effect;file is not within the allowed path的解决办法

来源:互联网 发布:网易跟帖知乎 编辑:程序博客网 时间:2024/06/10 00:43
phpnow: 出现类似 open_basedir restriction in effect;file(。。)is not within the allowed path。。
下边还会有至少2行的Warning和Fatal error;

解决的方法有两个:
①:运行PnCp.cmd,选择0 -vhs 添加 虚拟主机 
程序会列出现有的虚拟主机列表,在最下面输入要添加的虚拟主机的域名(也就是IIS下所谓的“主机头”) 
输入主机别名(也就是将多个域名绑定到主机上,多个域名之间一定是要用空格隔开) 
指定网站目录(也就是网站程序文件所在的文件夹) 
[ 如果分配此主机给其他用户, 并限制其权限, 请输入 "y";否则, 请输入 "n". 默认 Y ]
-> 限制虚拟主机权限? (Y/n):这里请一定要输入“n”,不限制权限,否则将会出现前面所说的“open_basedir restriction in effect”的错误! 

②可以在apache的conf\extra下的httpd-vhosts.conf文件对要添加的虚拟主机进行修改,如下:
<VirtualHost *>
    <Directory "D:/test/Site">
        Options -Indexes FollowSymLinks
        Allow from all
        AllowOverride All
    </Directory>
    ServerAdmin admin@dev.ystore
    DocumentRoot "D:/test/Site"
    ServerName dev.test.info:80
    ServerAlias *.dev.test.info
    ErrorLog logs/dev.test.info-error_log
    php_admin_value open_basedir "D:\test;C:\WINDOWS\Temp;"###这一句是关键,如果你require的文件是D:\test下的init.php,由于init.php不在Directory设置的目录下,故而会报错。将open_basedir 的路径设置成D:\test就好了。
</VirtualHost>
原创粉丝点击