【Plesk经验分享】Plesk中托管的网站不可访问怎么办?

适用版本:
Plesk for Windows

问题
网站不可访问,且出现下面的错误:
404 file not found


500 Internal Server Error


Error 500 move_uploaded_file(): open_basedir restriction in effect. File(/var/www/any/path/to/the/directory) is not within the allowed path(s): (/var/www/vhosts/example.com/:/tmp/)

在Plesk for Linux中,域名错误日志文件 /var/www/vhosts/example.com/logs/error_log中出现下面的错误信息:
A PHP Error was encountered
Severity: Warning
Message: is_dir(): open_basedir restriction in effect. File(/var/lib/php/session) is not within the allowed path(s): (/home/www/vhosts/example.com/:/tmp/)


Got error 'age: PHP Warning is_dir(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/var/www/vhosts/example.com/:/tmp/) in /var/www/vhosts/example.com/httpdocs/wp-includes/functions.php on line 1613\

在Plesk for Windows中,域名错误日志文件 %plesk_vhosts%example.com\logs\php_errors\example.com\php_error.log 中出现下面的错误信息:
PHP Warning: Unknown: open_basedir restriction in effect. File(E:\custom_folder\sessions) is not within the allowed path(s): (C:/inetpub/vhosts/example.com\;C:\Windows\Temp\) in Unknown on line 0

在某些情况下:
域名 > example.com > PHP 设置 > 查看 phpinfo() 页面 启动的php.ini页面不可访问:
Unable to retrieve information about the PHP configuration

日志文件大小增加得非常快:
# find /var/www/vhosts/system -size +1G -exec ls -lh {} \;
-rw-r--r-- 2 root root 218G 1. Jun 11:27 /var/www/vhosts/system/example.com/logs/error_log

原因
PHP脚本正尝试访问不允许访问的文件夹。该限制由单独针对每个虚拟主机的PHP open_basedir 变量控制。默认open_basedir 会被设置为允许PHP文件访问 tmp 和 httpdocs 目录。

解决方案
调整open_basedir的值以包括取自错误信息的丢失的路径:
1. 在Plesk中转入 域名 > example.com > PHP 设置

2. 修改open_basedir的值:
Linux:
以下示范将目录 /var/lib/php/session 包括到 open_basedir中:
{WEBSPACEROOT}{/}{:}{TMP}{/}{:}{/}var{/}lib{/}php{/}session{/}


/var/www/vhosts/example.com/:/tmp/:/var/lib/php/session

Windows:
以下示范将目录 E:\custom_folder\sessions 包括到 open_basedir 中:
{WEBSPACEROOT}{/};{TMP};{/};"E:\custom_folder\sessions\"

3. 应用更改。

提交
还没有评论,快来抢沙发吧!
售前
支持
代理
合作
售后
支持