dongyun3805 2016-02-26 09:35 采纳率: 0%
浏览 74

apache 2.4错误404

I just setup an Apache 2.4 & PHP 5.5.6 on ubuntu 12.04

When I call the page on a web browser -> mysite.com/index.php, the pages shows normally and works, but if i call the page mysite.com (without the /index.php) i get the error 404, the Apache does not load the index.php automatically.

I need to write this in navigation bar of the browser (the site have too an index.html). My virtual host of mysite.conf is:

<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 -->

The folder does not have and htacess file. I try change the apache2.conf, but without luck.

Thanks for your help

  • 写回答

2条回答 默认 最新

  • duanmian1085 2016-02-26 09:40
    关注

    The following should work for you:

    <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 -->
    

    EDIT:

    If that doesn't work, go and edit /etc/apache2/mods-enabled/dir.conf and change it from:

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

    to:

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

    As a side note, if you can't fine the dir.conf file within the mods-enabled folder then you need to run the following command:

    sudo a2enmod dir
    
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?