简体   繁体   中英

How to setup two virtual hosts in CentOS?

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 admin@menet.me
        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 admin@menet.me
        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?

if you are accessing the urls locally ie 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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM