PHP5 无法使用自定义 DocumentRoot

发布于 2024-09-09 08:11:32 字数 1005 浏览 3 评论 0原文

我目前正在努力解决以下问题。

我已经成功安装了Apache2和PHP5。它一直有效,直到我将 Apache2 的 DocumentRoot 更改为与 /var/www 不同的内容。

我想将 DocumentRoot 设置为 /home//wwwroot,但是执行此操作后,所有 php 页面都是白色的。 (没有下载消息或其他东西。)

这是我的 php5.conf:

<IfModule mod_php5.c>
   AddType application/x-httpd-php .php .phtml .php3
   AddType application/x-httpd-php-source .phps
#    <FilesMatch "\.ph(p3?|tml)$">
# SetHandler application/x-httpd-php
#    </FilesMatch>
#    <FilesMatch "\.phps$">
# SetHandler application/x-httpd-php-source
#    </FilesMatch>
    # To re-enable php in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    # <IfModule mod_userdir.c>
        # <Directory /home/*/public_html>
            # php_admin_value engine Off
        # </Directory>
    # </IfModule>
</IfModule>

我不明白,需要帮助。

谢谢!

I am currently struggling with the following problem.

I have successfully installed Apache2 and PHP5. And it works until I change the DocumentRoot of the Apache2 to something different than /var/www.

I want to set the DocumentRoot to /home//wwwroot, but after doing this all php pages are just white. (no download message or sth.)

Here is my php5.conf:

<IfModule mod_php5.c>
   AddType application/x-httpd-php .php .phtml .php3
   AddType application/x-httpd-php-source .phps
#    <FilesMatch "\.ph(p3?|tml)$">
# SetHandler application/x-httpd-php
#    </FilesMatch>
#    <FilesMatch "\.phps$">
# SetHandler application/x-httpd-php-source
#    </FilesMatch>
    # To re-enable php in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    # <IfModule mod_userdir.c>
        # <Directory /home/*/public_html>
            # php_admin_value engine Off
        # </Directory>
    # </IfModule>
</IfModule>

I dont get it, and need help.

Thx!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

手长情犹 2024-09-16 08:11:32

试试这个吧。不要使用 AddType,因为这会破坏内容协商。

LoadModule ...
<IfModule php5_module>
    #PHPIniDir "/whatever/"

    AddType text/html .php .phps
    AddHandler application/x-httpd-php .php
    AddHandler application/x-httpd-php-source .phps

    <Directory /home/*/public_html>
        php_admin_value engine Off
    </Directory>
</IfModule>

Try this instead. Don't use AddType, as that breaks content negotiation.

LoadModule ...
<IfModule php5_module>
    #PHPIniDir "/whatever/"

    AddType text/html .php .phps
    AddHandler application/x-httpd-php .php
    AddHandler application/x-httpd-php-source .phps

    <Directory /home/*/public_html>
        php_admin_value engine Off
    </Directory>
</IfModule>
哆啦不做梦 2024-09-16 08:11:32

如果你想为不同的 php 版本、不同的网站、服务器等使用不同的 ini 文件,PHPIniDir 很重要。我不会删除它,我有一个不同的 ini 文件用于 windows、osx 和 linux。

PHPIniDir is important if you want to use a different ini file for different php version, different website, server, etc. i wouldn't delete it, i have a different ini files for windoze, for osx and for linux.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文