【问题标题】:after replacing /var/www/html directory, apache does not work anymore替换 /var/www/html 目录后,apache 不再工作
【发布时间】:2015-02-12 11:59:09
【问题描述】:

我正在设置一个 aws ec2 实例。安装 apache 后,它有 /var/www/html。然后我用我自己的包含我的 php 文件的 html 目录替换了 html。现在无法从浏览器访问 index.php 文件了。我在网上搜索,找不到任何解决方案。如果有人可以提供帮助,我将不胜感激。

我可以访问 test.php 或 test.html。但是无法访问实际上应该默认加载的 index.php 而不给出名称。

如果这些信息有用的话,我复制的目录是 wordpress。现在,浏览器只显示一个空白页面。

【问题讨论】:

    标签: apache amazon-ec2


    【解决方案1】:

    它有一个非常简单的解决方案,在 .htaccess 文件中定义目录索引。如果您的网站根目录上没有 .htaccess 文件,则添加一个并将下面的行放入其中。

    DirectoryIndex index.php
    

    【讨论】:

      【解决方案2】:

      在您的 htaccess 或 httpd.conf 文件中添加这一行

      DirectoryIndex index.php

      【讨论】:

        【解决方案3】:

        也许你没有为 Apache 定义“.php”索引

        <IfModule mime_module>
           AddType text/html .php .phps
        </IfModule>
        

        查看本教程install Apache and php

        install Apache and php

        【讨论】:

        • 我做到了。以前我可以使用 ip/html/index.php 或 ip/html/ 访问该站点。替换现有的apache html目录后,问题就出现了。我这样做是因为我想直接使用 ip 访问站点,而不需要目录名。
        【解决方案4】:

        检查文件的权限

        ls -lR /var/www
        

        可能是 Apache 用户(例如 www-data)对他们没有权限。

        chmod 744 -R /var/www/html
        

        并尝试重新启动 Apache。

        /etc/init.d/apache2 restart
        

        【讨论】:

        • 谢谢。我刚试过,它现在给了我这个:Forbidden You don't have permission to access / on this server.
        • 你能检查ls -lR /var/www的输出吗?另外,尝试转到 /index.php
        • @Ryan 你是怎么解决 Forbidden You don't have permission to access / on this server 问题的??
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-12-05
        • 1970-01-01
        • 2017-02-28
        • 1970-01-01
        • 2010-11-18
        • 2013-10-05
        相关资源
        最近更新 更多