开发者

How to I point multiple URLs to the right directory?

I have a VPS running CentOS 5. I want to point multiple domains at the same VPS (point them at the same IP), but serve up distinct websites for each domain.

So, the setup I want is like this:

site1.com ----> 127.0.0.1 ----> /var/www/html/site1.com/

site2.com ----> 127.0.0.1 ----> /var/www/html/site2.com/

I've tried setting up virtual hosts through the CentOS GUI for Apache, but they don't seem to be working. Only the first virtual host added will work (i.e. If I add site1.com first, both domains direct to that site. If I add site2.com first, both domains direct to that site.)

What might I be doing wrong? Is there an effective step-by-step tutorial for newcomers to get me started?


Update

Please remember, I have little to no experience working with CentOS and Linux ... but I'm learning.

To those who asked to see the directives I'm using, here's what CentOS added to the bottom of /etc/httpd/conf/httpd.conf when I used the built-in Apache GUI:

<VirtualHost skylarkapp.com:80>
    DocumentRoot /var/www/html/skylarkapp.com
    <Directory "/var/www/html/skylarkapp.com">
        allow from all
        Options +Indexes
    </Directory>
    ServerName skylarkapp.com
</VirtualHost>
<VirtualHost eamann.com:80>
    DocumentRoot /var/www/html/eamann
    <Directory "/var/www/html/eamann">
        allow from all
        Options +Indexes
    </Directory>
    ServerName eamann.com
</VirtualHost>

At the moment, all traffic to both skylarkapp.com and eamann.com on this system dire开发者_如何学编程ct to the content of /var/www/html/skylarkapp.com.

Also, I'm using my Windows hosts file to manually point eamann.com to this server (204.92.23.6) because I'm in the process of migrating a live site. I want to get things working on the server before I actually move things from one box to another.


Name-based virtual hosts must be turned on explicitly with NameVirtualHost *:80. See http://httpd.apache.org/docs/2.2/vhosts/name-based.html


This line:

<VirtualHost eamann.com:80>

won't work since eamann.com won't resolve to your CentOS server's IP address (only your Windows machine resolves eamann.com to 204.92.23.6). Try making apache listed on any IP by replacing with:

<VirtualHost *:80>

You probably also want:

ServerAlias www.eamann.com

to allow visitors to www.eamann.com to see the site as well. Restart apache after making these changes:

service httpd restart
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜