duanmeng2842 2011-11-08 16:41
浏览 59
已采纳

PHP open_basedir在Apache中被破坏但在运行时在PHP中运行

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.

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?

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>

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

I even tried to just set the base directory to root (php_flag open_basedir /) and it still gave me an error.

Existing server: Debian GNU/Linux 4.0, PHP Version 5.2.0-2, Apache 2.2.3

New server: Debian GNU/Linux 6.0, PHP Version 5.3.3-7+squeeze3, Apache 2.2.16

  • 写回答

1条回答 默认 最新

  • dongqiaochi2711 2011-11-08 16:50
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 C语言设计一个简单的自动换档程序
  • ¥15 关于logstash转发日志时发生的部分内容丢失问题
  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。