在虚拟主机中使用多个站点(apache)

时间:2013-05-08 11:33:01

标签: apache virtualhost

我已经在我的Windows机器上安装了XAMPP - 我试图在虚拟主机文件中运行多个网站,但无论我做什么,我一次只能运行一个网站。例如,为了运行第三站点,我需要注释掉对站点1和站点1的所有引用。 2(反之亦然)。

任何人都可以解释我做错了吗?

我的v / hosts文件如下:

<VirtualHost *:80>
ServerName s1.localhost
ServerAlias s1.localhost
DocumentRoot "C:/xampp/htdocs/site1/public_html"
<Directory "C:/xampp/htdocs/site1/public_html">
    AllowOverride All
   Options FollowSymlinks
    Order allow,deny
    Allow from all
</Directory>

<VirtualHost *:80>
ServerName s2.localhost
ServerAlias s2.localhost
DocumentRoot "C:/xampp/htdocs/site2/public_html"
<Directory "C:/xampp/htdocs/site2/public_html">
    AllowOverride All
    Options FollowSymlinks
    Order allow,deny
    Allow from all
</Directory>

<VirtualHost *:80>
ServerName s3.localhost
ServerAlias s3.localhost
DocumentRoot "C:/xampp/htdocs/site3"
<Directory "C:/xampp/htdocs/site3">
    AllowOverride All
    Options FollowSymlinks
    Order allow,deny
    Allow from all
</Directory>

我的Windows主机文件:

127.0.0.1 s1.localhost
127.0.0.1 s2.localhost
127.0.0.1 s3.localhost

1 个答案:

答案 0 :(得分:0)

NameVirtualHost *:80 - 此行需要取消注释以解决此问题