apache Vhost打开其他Vhost

时间:2015-10-30 11:59:07

标签: linux apache ubuntu-14.04

我已经设置了一个带有4个不同虚拟主机的Ubuntu 14.04 apache2服务器,如下所示。我遇到的问题是当我启动apache并打开www.site1.io然后尝试打开www.site2.io时 - 它会打开www.site1.io而不是。

例如:

  1. 打开www.site1.io/admin
  2. 打开www.site2.io
  3. 将我重定向到www.site2.io/admin并在site2网址下显示www.site1.io/admin页面
  4. 这是我的Vhosts:

    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    
    <VirtualHost *:80>
            ServerName www.pma.io
            ServerAlias pma.io
            DocumentRoot /var/www/html/phpmyadmin
            ErrorLog /var/www/html/logs/pma.io/error.log
            CustomLog /var/www/html/logs/pma.io/access.log common
            <Directory /var/www/html/phpmyadmin>
                    AllowOverride All
                    Order allow,deny
                    Allow from all
            </Directory>
    </VirtualHost>
    
    <VirtualHost *:80>
        DocumentRoot "/var/www/html/site1.io"
        ServerName www.site1.io
        ServerAlias site1.io
        ErrorLog /var/www/html/logs/site1.io/error.log
        CustomLog /var/www/html/logs/site1.io/access.log common
        <Directory /var/www/html/site1.io>
                AllowOverride All
                Order allow,deny
                Allow from all  
        </Directory>
    </VirtualHost>
    
    <VirtualHost *:80>
            DocumentRoot "/var/www/html/site2.io"
            ServerName www.site2.io
            ServerAlias site2.io
            ErrorLog /var/www/html/logs/site2.io/error.log
            CustomLog /var/www/html/logs/site2.io/access.log common
            <Directory /var/www/html/site2.io>
                    AllowOverride All
                    Order allow,deny
                    Allow from all  
            </Directory>
    </VirtualHost>
    

    apachectl -s输出:

    VirtualHost configuration:
    *:80                   is a NameVirtualHost
             default server 127.0.0.1 (/etc/apache2/sites-enabled/000-default.conf:1)
             port 80 namevhost 127.0.0.1 (/etc/apache2/sites-enabled/000-default.conf:1)
             port 80 namevhost www.site1.io (/etc/apache2/sites-enabled/site1.io.conf:1)
                     alias site1.io
             port 80 namevhost www.site2.io (/etc/apache2/sites-enabled/site2.io.conf:1)
                     alias site2.io
             port 80 namevhost www.pma.io (/etc/apache2/sites-enabled/phpmyadmin.conf:1)
                     alias pma.io
    

    主持文件:

    127.0.0.1       pma.io
    127.0.0.1       www.pma.io
    127.0.0.1       site1.io
    127.0.0.1       www.site1.io
    127.0.0.1       site2.io
    127.0.0.1       www.site2.io
    

    感谢您的帮助

1 个答案:

答案 0 :(得分:0)

解决方案:不要乱用php5-xcache模块

禁用它,一切都很顺利