I just installed Ubuntu 17.04 and set up my LAMP server w/ PHP7 and the PHP modules enabled for Apache2.
When I go to http://localhost/ it defaults to the index.html that is present in /var/www/html and not the index.php that is there. When I go to http://localhost/index.php the php file loads just fine and the php script executes.
In looking at other posts ( index.php not loading by default ) I saw that the preferred solution is to edit the /etc/apache2/mods-enabled/dir.conf file to move the index.php before the index.html in the DirectoryIndex entry.
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
So I did this and saved the file as sudo, restarted the apache service as well as tried restarting the computer and it still serves the index.html first. Any idea? Should I use the .htaccess file solution instead? Thanks!
index.htmland aindex.phpfile? Can't you just deleteindex.html, which would cause localhost to loadindex.phpby default? Also, you need to specifyDirectoryIndexfor each file that you wish to load. See stackoverflow.com/a/26700170/2341603. In fact, if you just specify the PHP file as a directory index, having the.htmlfile won't matter, as Apache will load the PHP file anyway.index.htmlin the subdirectories won't they not load by default if I eliminate it altogether?