可能重复:
为多个虚拟主机设置httpd-vhosts.conf
说我有专用的IP 155.5.5.5我有所有的DNS设置正确的两个域www.a.com和www.b.com
在我的apache目录中,我有/ var / www / a / / var / www / b /
如何设置apache vhosts.conf文件,使ip(155.5.5.5)进入/ var / www /,A.com进入/ var / www / a,B.com进入/ var / www / b ?
使用基于名称的虚拟主机
NameVirtualHost *:80 <VirtualHost *:80> ServerName a.com ServerAlias www.a.com DocumentRoot /var/www/a </VirtualHost> <VirtualHost *:80> ServerName b.com ServerName www.b.com DocumentRoot /var/www/b </VirtualHost>
http://httpd.apache.org/docs/1.3/vhosts/name-based.html
根据您的发行版,虚拟主机将进入/ etc / apache2 / sites-enabled /或仅位于/etc/httpd/conf/httpd.conf的底部。
slicehost文章非常适合从linux系统pipe理员/ apache / etc开始。