Configure virtual host on Apache

125 Views Asked by At

I have a VPS with a single IP address and with Virtualmin/Webmin installed. I have created a virtual host *example.com *that will answer to www.example.com (the domain already points to the IP address of the VPS). However, when I access www.example.com I am not seeing the website I have uploaded for example.com but rather the default server:

It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

What should I do? Do I have to configure DNS or something?

1

There are 1 best solutions below

0
On

Yes, you will need to configure DNS for your www.* site if it has not been done already. This www.* alias may have been created automatically when you set up the domain in DNS, but perhaps you will need to specify it explicitly.

Seeing the message "It works!" is a common issue. Apache has a default virtual host which you may want to disable. Exactly how to do that depends on the platform of your web server (it's a good idea to mention the platform and version when asking questions).

For example, if you have shell access to a Debian or Ubuntu machine, you can use the command:

sudo a2dissite default

In virtualmin there may also be an option for this, see for example http://www.virtualmin.com/node/15854

Once you have DNS set up and the www.* domain responding correctly to pings with IP of your server, you will also need to make sure that the virtual host definition for your site includes the www.* alias.