var/www/index.html not showing up - just standard "It works!" page - how to solve?

December 29, 2013 25.5k views
Hi, So I've got my server set up with LAMP, but I've go one problem. If I go to the standard "It works!" page shows up. I've placed my own index.html in var/www/ and if I go to it shows up. Naturally, I want to point to /var/www/index.html. How do I fix this? Thanks in advance, - W
6 Answers
I followed these steps, taken from James Tansley, on this post

1. Go to /etc/apache2/mods-enabled/ directory. To do this, type "cd /etc/apache2/mods-enabled/" without the quotes.
2. Open the dir.conf file so you can edit it. To do this, type "sudo nano dir.conf" without the quotes.
3. You will see a line of index files (index.html, index.php, index.cgi, etc) under the DirectoryIndex setting. Add index.php as the first item in the list. Doing so will tell Apache to first look for and load an index.php file before looking for the other index file extensions.
4. Press Ctrl+X to save your changes and then press Enter to exit the editor.
5. Restart Apache by typing "sudo /etc/init.d/apache2 restart" without the quotes.
by Etel Sverdlov
Wordpress is a free and open source website and blogging tool that uses php and MySQL. It was created in 2003 and has since then expanded to manage 22% of all the new websites created and has over 20,000 plugins to customize its functionality. This tutorial shows how to install Wordpress on a server with LAMP. It is written for Ubuntu 12.04.
  • That works and the trick is using /etc/init.d/apache2 restart. So now I can get the server to serve php if index.php is the first item. Thanks.

"So I've got my server set up with LAMP..."

When you configured Apache, what did you declare as your root directory?

"I've placed my own index.html in var/www/..."

Make sure /var/www/ is defined as your web server's root directory. Also make sure there's only 1 index.html file in that directory.
I used the LAMP server image that you offer so I didn't configure it myself. Is there an easy way to change the root directory? And yes, I deleted the index.html which was already in var/www before I added mine.


- W
Did you restart Apache, afterwards? If not, execute:
sudo service apache2 restart

* I don't work for DigitalOcean.
It could be cached in your browser—try clearing your browser's cache or doing a full reload (ctrl-shift-r).

I have done this, but it still isn't working. Is there a setting in apache2 conf that i also need to do? php works from the command line, but in the browser, I can see the code. I have fixed this problem before but cannot figure out what's wrong this time.

Have another answer? Share your knowledge.