lamp – is this virtual host creation process correct?

ppp asked:

I recently reinstalled ubuntu on my system and I cannot get virtual hosts to work properly.

What I’m trying to accomplish is typing ‘test’ on my browser and pointing to my local machine on the location /var/www/test

I have followed several tutorials on the subject, and after every one of them, w3m test outputs the contents of the index.html on the test directory as expected, but when I go to firefox/chrome and type ‘test’ in the address bar, the browser googles it and shows me results.

So I’m wondering if there is something wrong with my process.

What I’ve been doing so far is:

  1. sudo apt-get install lamp-server^
  2. sudo gedit /etc/hosts
  3. append ‘ test’ to hosts file
  4. save and exit
  5. sudo gedit /etc/apache2/sites-available/test
  6. add the following lines to test:

    <VirtualHost *:80>
    ServerName test
    DocumentRoot /var/www/test
  7. save and exit
  8. sudo a2ensite test
  9. restart apache (tried sudo service apache2 restart, reload, and also
    rebooted the whole system)

Any clues as to why w3m shows me the correct file and browsers refuse to do so?

Please note that I have cleared Firefox and Chrome caches several times.

——– Update ——-

It looks like I had misconfigured my lamp server in the first place.

The above process worked just fine when I reinstalled lamp (sadly I had to reinstall OS too), with one slight modification.

In step 3, you do not have to append the name of the vhost to the hosts file, you have to append it to the line that starts with localhost (usually the first line)

I cannot accept any of the answers, since if someone faces the same difficulty in the future, none of the answers will give the solution.

I will have to search the configuration files to see exactly what was wrong, and the. I will post it.

My answer:

Your browser is too smart, and thinks that if you enter a single word into the address bar, that you meant to search, rather than browse to a site. Enter in a complete URL instead, for instance:




View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.