Multiple Domains on one IP Address using Apache Virtual Server

Using Apache Virtual Servers it is easy to make multiple domains point at the same IP address displaying different content. You just have to add the following lines to the file /etc/httpd/conf/httpd.conf and restart apache:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.first-domain.com
ServerAlias first-domain.com *.first-domain.com
DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *:80>
ServerName www.second-domain.com
DocumentRoot /var/www/samples
</VirtualHost>


In this setup http://www.first-domain.com is displaying the content of /var/www/html while http://www.second-domain.com is displaying the content of /var/www/samples.

One Comment

  1. Jayme
    Posted September 28, 2014 at 7:47 am | Permalink | Reply

    I was recommendd this bpog bby my cousin. I’m nott sure whethesr this post is writen by him aas nobody else
    know such destailed about mmy problem. You’re incredible!
    Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: