0

I need my Ubuntu install to use index.php as the default file.

Added

  DirectoryIndex index.php 

to /etc/apache2/apache2.conf

Added

<Directory /path/to/website/root/>
    DirectoryIndex index.php 
</Directory>

to /etc/apache2/sites-available/mysite.conf followed by enabling & restarting

sudo a2ensite mysite
sudo service apache2 restart

What did I miss? Still, the server won't load a default file.

NOTE: Adding DirectoryIndex index.php to .htaccess causes the desired affect but I would prefer to do this via .conf file.

csi
  • 1,555
  • 7
  • 23
  • 42

3 Answers3

1

Where did you put the DirectoryIndex? Adding it to the .htaccess is equivalent to putting the statement in:

<Directory /path/to/htaccess/file/>
DirectoryIndex index.php
</Directory>

so try adding a directory statement around the DirectoryIndex. A bit hackish but it'll probably work? If it doesn't try giving us a lot more of your config, like the entire vhost config.

Some Linux Nerd
  • 3,327
  • 3
  • 19
  • 22
  • Sorry I wasn't clear... DirectoryIndex index.php was inside a directory statement. I added to question. Still not working. – csi Sep 06 '13 at 17:36
0

Today we had a similar problem on SLES 11 SP4 with Apache 2.2 with an pretty much default apache configuration. Problem was, Apache ignored an existing index.html file when not explicitly called on the url. e.g. server.domain.tld/dir/

However if called with explicit file, it serves the content. e.g. server.domain.tld/dir/index.hmtl . so there was no problem with filesystem permissions. All Files under htdocs had sufficient permissions for Group OTHERS . BUT all the htdocs files back then where owned by root.root . So in this "Mode" Apache did not serve index.html if not mentioned in the URL.

The Moment we recursively changed back the htdocs directory and files back to owner "wwwrun.www" which is "default" on SLES (suse linux enterprise Server) without changing the permissions itself, apache started to serve the index.html again, as usually expected. No restart nor nothing needed.

cant tell if this is a bug or a feature. just wanted to let you know what we have experienced and what solved the problem.

so you might check on your ownership of your htdocs files and make sure its owned by the webservers service-account and group.

Axel Werner
  • 156
  • 1
  • 12
0

Try using location directive instead.

<Location /path/to/htaccess/file/>
    DirectoryIndex index.php
</Location>