阿帕奇 2.4 错误 404


apache 2.4 error 404

我刚刚在ubuntu 12.04上设置了一个Apache 2.4和PHP 5.5.6

当我在 Web 浏览器上调用页面时 -> mysite.com/index.php ,页面显示正常并正常工作,但是如果我调用页面mysite.com(没有/index.php),我会得到错误404,Apache 不会自动加载索引.php。

我需要在浏览器的导航栏中写这个(该网站也有index.html)。我的虚拟mysite.conf主机是:

<VirtualHost *:80>
ServerAdmin webmaster@mysite.org
DocumentRoot /home/alexbk/webs/mysite
ErrorLog /home/alexbk/webs/mysite/error.log
CustomLog /home/alexbk/webs/mysite/access.log combined
<Directory /home/alexbk/webs/mysite>
Options Indexes FollowSymLinks MultiViews
Require all granted
AllowOverride All
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet -->

文件夹没有 和 htacess 文件。我尝试更改apache2.conf,但没有运气。

感谢您的帮助

以下内容应该适合您:

<VirtualHost *:80>
    ServerAdmin webmaster@mysite.org
    DocumentRoot /home/alexbk/webs/mysite
    ErrorLog /home/alexbk/webs/mysite/error.log
    CustomLog /home/alexbk/webs/mysite/access.log combined
    <Directory /home/alexbk/webs/mysite>
        Options Indexes FollowSymLinks MultiViews
        Require all granted
        AllowOverride All
        DirectoryIndex index.php
    </Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet -->

编辑:

如果这不起作用,请编辑/etc/apache2/mods-enabled/dir.conf 并将其从

<IfModule mod_dir.c>
    DirectoryIndex index.html index.cgi index.pl index.xhtml index.htm
</IfModule>

自:

<IfModule mod_dir.c>
    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>

作为旁注,如果您无法在启用 mods 的文件夹中对 dir.conf 文件进行罚款,则需要运行以下命令:

sudo a2enmod dir

感谢 garry,感谢您的帮助,我的问题是 mods 可用文件夹中没有 dir.load 文件,然后命令"sudo a2enmod dir"不起作用,我需要创建一个 dir.load 文件(行:加载模块dir_module/usr/lib/apache2/modules/mod_dir.so); 确保 .so 文件存在并保存到 mods 可用文件夹中, 然后我可以运行"A2enmod dir"并工作!.