Apache虚拟主机无法正常工作

时间:2013-11-22 14:30:23

标签: apache virtualhost virtual-hosts server-name

不知怎的,我的虚拟主机文件不能直接工作我不知道为什么 - 我敢打赌它只是我早安脑中的邮件功能:p

现在我通过指向/ etc / apache2 /目录中可用网站的符号链接启用了两个网站,如:

0 Nov 21 12:24 000-default -> ../sites-available/default
0 Nov 21 14:52 001-site -> ../sites-available/site

我的VHosts文件如下:

DEFAULT

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName (the IP Address from my Server)
        ServerAlias (the 2nd IP Address from my Server)
        DocumentRoot /var/www/default
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/default>
                Options FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

SITE

<VirtualHost *:80>
    ServerAdmin myname@example.de
    DocumentRoot /var/www/site/
    ServerName jobbörse-köln.de
    ServerAlias www.example.de ww.example.de w.example.de

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/site>
            Options FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/site-error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/site-access.log combined
</VirtualHost>

当我继续“example.de”时,我会进入DEFAULT目录而不是SITE目录。 甚至是日志文件:

site-error.log
site-access.log

留在0字节......我做错了什么?我打赌这是愚蠢和容易的事情......

1 个答案:

答案 0 :(得分:9)

您正在为虚拟主机条目使用默认的80端口。所以我希望您使用NameVirtualHost *:80作为配置。

您共享的配置中的

VirtualHost会在端口80上重叠,因此第一个优先。

相关问题