How to setup two virtual hosts in CentOS?

368 Views Asked by At

I have two domains I'm trying to host on the same IP. This is what I've been trying, but it doesn't work:

    <VirtualHost host1.me:80>
        ServerAdmin [email protected]
        DocumentRoot /var/www/html/host1/
        ServerName host1.me
        ErrorLog logs/host1-error_log
        CustomLog logs/host1-access_log common
    </VirtualHost>

    <VirtualHost host2.me:80>
        ServerAdmin [email protected]
        DocumentRoot /var/www/html/host2/
        ServerName www.host2.me
        ServerAlias host2.me
        ErrorLog logs/host2-error_log
        CustomLog logs/host2-access_log common
    </VirtualHost>

What should I put in my httpd.conf?

1

There are 1 best solutions below

3
On

if you are accessing the urls locally i.e. on server itself, then u need to add their entries in /etc/hosts file.

eg: suppose ur server ip is 192.168.1.1, thn put following entry in hosts file:

192.168.1.1 host1.me host2.me www.host2.me

save the file...

and then check...

hope this helps :)