PHP的open_basedir打破了Apache但在运行时在PHP工作 [英] PHP open_basedir broken in Apache but works in PHP at runtime
问题描述
我的网站迁移到新的服务器和一个网站正在使用的open_basedir在其网站可用文件给我的问题,只是显示当我尝试加载一个空白页。
I am migrating websites to a new server and one site that is using open_basedir in its sites-available file is giving me problems and just showing a blank page when I try to load it.
我已经通过的ini_set内从Apache虚拟主机的配置的open_basedir移动到前面index.php页面固定它()。此修复困扰我,虽然我觉得我失去了一些东西。是否有一个特定的Apache设置,我需要改变什么来得到这个在虚拟主机的配置工作?
I have fixed it by moving the open_basedir config from the Apache VirtualHost to the front index.php page within an ini_set(). This fix bothers me though and I feel that I'm missing something. Is there a particular Apache setting that I need to change or something to get this to work in a VirtualHost config?
请注意,我没有重启Apache更改网站可用文件之后。
Note that I did restart apache after changing the sites-available file.
下面是网站的可用文件:
Here is the sites-available file:
<VirtualHost *:443>
ServerName www.mysite.com
ServerAdmin webmaster@mysite.com
DocumentRoot /var/www/www.mysite.com/content
php_flag open_basedir /var/www/www.mysite.com/
SSLEngine On
SSLCertificateFile /etc/ssl/certs/www_mysite_com.crt
SSLCertificateKeyFile /etc/ssl/private/www_mysite_com.key
SSLCACertificateFile /etc/ssl/certs/DigiCertCA.crt
RewriteEngine on
FileETag INode MTime Size
ExpiresActive On
ExpiresDefault "access plus 1 week"
ExpiresByType text/html "access plus 5 seconds"
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
下面是错误的Apache是给我(/var/log/apache2/error.log):
Here is the error Apache is giving me (/var/log/apache2/error.log):
... PHP Warning: Unknown: open_basedir restriction in effect. File(/var/www/www.mysite.com/content/index.php) is not within the allowed path(s): (0) in Unknown on line 0
... PHP Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0
... PHP Fatal error: Unknown: Failed opening required '/var/www/www.mysite.com/content/index.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
我甚至想刚才设置的基本目录为根(的php_flag的open_basedir /),它仍然给了我一个错误。
I even tried to just set the base directory to root (php_flag open_basedir /) and it still gave me an error.
现有的服务器:的Debian GNU / Linux的4.0,PHP版本5.2.0-2,阿帕奇2.2.3
Existing server: Debian GNU/Linux 4.0, PHP Version 5.2.0-2, Apache 2.2.3
新服务器:的Debian GNU / Linux的6.0,PHP版本5.3.3-7 + squeeze3,阿帕奇2.2.16
New server: Debian GNU/Linux 6.0, PHP Version 5.3.3-7+squeeze3, Apache 2.2.16
推荐答案
请尝试以下操作来代替:
Try the following instead:
<VirtualHost *:443>
...
php_admin_value open_basedir "/var/www/www.mysite.com/"
...
</VirtualHost>
您正在使用 * _标志
,你应该使用 * _值
。
You are using *_flag
where you should be using *_value
.
* _标志
是,而布尔值* _值
是字符串。见怎样修改配置设置以获取更多信息的。
*_flag
is for boolean values whereas *_value
is for strings. See How to change configuration settings for more information.
这篇关于PHP的open_basedir打破了Apache但在运行时在PHP工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!