Question

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

  • Posted December 29, 2013

Hi,

So I’ve got my server set up with LAMP, but I’ve go one problem. If I go to mydomain.com the standard “It works!” page shows up. I’ve placed my own index.html in var/www/ and if I go to mydomain.com/index.html it shows up. Naturally, I want mydomain.com to point to /var/www/index.html.

How do I fix this?

Thanks in advance,

  • W
Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I followed these steps, taken from James Tansley, on this post https://www.digitalocean.com/community/articles/how-to-install-wordpress-on-ubuntu-12-04 <br> <br>1. Go to /etc/apache2/mods-enabled/ directory. To do this, type “cd /etc/apache2/mods-enabled/” without the quotes. <br>2. Open the dir.conf file so you can edit it. To do this, type “sudo nano dir.conf” without the quotes. <br>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. <br>4. Press Ctrl+X to save your changes and then press Enter to exit the editor. <br>5. Restart Apache by typing “sudo /etc/init.d/apache2 restart” without the quotes.

Hi @andreas.john.wik

When you are configuring your Apache2 config file for mydomain.com, you need to set the root folder as /var/www/yourdomain.com. Here is an example config file which you can use:

<VirtualHost *:80>
    ServerAdmin admin@test.com
    ServerName test.com
    ServerAlias www.test.com
    DocumentRoot /var/www/yourdomain.com/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

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.

It could be cached in your browser—try clearing your browser’s cache or doing a full reload (ctrl-shift-r).

Did you restart Apache, afterwards? If not, execute: <br><pre>sudo service apache2 restart</pre> <br>* I don’t work for DigitalOcean.

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. <br> <br>Thanks, <br> <br>- W

<b>“So I’ve got my server set up with LAMP…”</b> <br> <br>When you configured Apache, what did you declare as your root directory? <br> <br><b>“I’ve placed my own index.html in var/www/…”</b> <br> <br>Make sure <code>/var/www/</code> is defined as your web server’s root directory. Also make sure there’s only 1 <code>index.html</code> file in that directory.