日期:2014-05-16  浏览次数:20900 次

在apache2的sites-available目录下放置多个站点
我用的ubuntu。
在sites-available目录下放置了两个站点:example.net  example.org
<VirtualHost *:80>
    ServerAdmin webmaster@example.net
    ServerName example.net
    ServerAlias www.example.net
    DocumentRoot /var/www/example.net/public_html/
    ErrorLog /var/www/example.net/logs/error.log
    CustomLog /var/www/example.net/logs/access.log combined
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin admin@example.org
    ServerName example.org
    ServerAlias www.example.org
    DocumentRoot /var/www/example.org/public_html/
    ErrorLog /var/www/example.org/logs/error.log
    CustomLog /var/www/example.org/logs/access.log combined
</VirtualHost>


在各自站点的Public_html目录下放置了index.html 文件。

但是我用localhost 访问时,只有example.net 显示了,而 example.org 没有显示。

我现在想知道,如何弄两个站点呢?
apache

------解决方案--------------------
    #Configure VirtualHost, Based IP
    #基于IP,一个IP一个站点,如需指定日志,参照xxxx.net
    <VirtualHost 192.168.1.1:80>
        DocumentRoot /var/www/abc/
        ServerName www.abc.cn
    </VirtualHost>

    <VirtualHost 192.168.1.2:80>
        ServerAdmin webmaster@localhost
        ServerName xxxx.net
        DocumentRoot /var/www/xxxx/
        CustomLog /var/log/apache2/xxxx-access.log
        ErrorLog /var/log/apache2/xxxx-error.log
    </VirtualHost>


    #Configure NameVirtualHost, Based Name, 2013.10.5
    #基于名称,同个IP多个站点
    NameVirtualHost 192.168.1.3:80
    <VirtualHost 192.168.1.3:80>
        DocumentRoot /var/www/web1/
        ServerName web1.abc.org
    </VirtualHost>

    <VirtualHost 192.168.1.3:80>
        DocumentRoot /var/www/web2/
        ServerName web2.abc.org
    </VirtualHost>
     
    <VirtualHost 192.168.1.3:80>
        DocumentRoot /var/www/bbs/