0

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

ALEXANDER LOZANO
  • 1,874
  • 3
  • 22
  • 31

2 Answers2

1

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
Garry Welding
  • 3,599
  • 1
  • 29
  • 46
  • if i add the line Directory index , apache crash, with the follow error: AH00526: Syntax error on line 10 of /etc/apache2/sites-enabled/mysite.conf: Invalid command 'DirectoryIndex', perhaps misspelled or defined by a module not included in the server configuration – ALEXANDER LOZANO Feb 26 '16 at 09:53
  • OK, remove that line from dentalvox.org.conf then. And instead go and edit /etc/apache2/mods-enabled/dir.conf. In there you should have a line that says: DirectoryIndex index.html index.cgi index.pl index.xhtml index.htm change that to say DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm – Garry Welding Feb 26 '16 at 09:59
  • I forgot to say, if you can't find the dir.conf file then you need to run "sudo a2enmod dir" – Garry Welding Feb 26 '16 at 10:03
0

Thanks to garry, for your help, my problem was that there are not a dir.load file in the mods-available folder then the command "sudo a2enmod dir" does not work, i need to create a dir.load file (with the line: LoadModule dir_module /usr/lib/apache2/modules/mod_dir.so); sure that the .so file exist and save into mods-available folder, then i can run "a2enmod dir" and works!!.

ALEXANDER LOZANO
  • 1,874
  • 3
  • 22
  • 31