Apache Virtual Host is not working right

北慕城南 提交于 2019-12-08 16:37:46

问题


Somehow my Virtual host files are not working straight I can't tell why - I bet it's just a mailfunction in my good-morning brain :p

Right now I got TWO sites enabled via a symbolic link to sites available in /etc/apache2/ directory like :

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

my VHosts files look like :

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>

Somehow when I go on "example.de" I get to the DEFAULT Directory instead of the SITE Directory. Even the log files :

site-error.log
site-access.log

stay on 0 bytes ... what am I doing wrong ? I bet it's something dumb and easy ...


回答1:


You are using the default 80 port for both the virtual host entry. So I hope you are using NameVirtualHost *:80 as configuration.

in the configuration you shared VirtualHost are getting overlaped on port 80, so the first has precedence.



来源:https://stackoverflow.com/questions/20147305/apache-virtual-host-is-not-working-right

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!