Apache Virtual Host is not working right [closed]
Asked Answered
T

1

8

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 [email protected]
    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 ...

Transcribe answered 22/11, 2013 at 14:30 Comment(2)
where are your vhost.conf files located? what is that you see when you access your site? What about your httpd.conf?Rigging
My Vhost Files are located in : /etc/apache2/sites-available and they get linked in /etc/apache2/sites-enabled my apache2.conf is located in /etc/apache2/ When I go on www.example.de I get the index.php from /var/www/default/ instead of /var/www/site/Transcribe
A
9

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.

Alburg answered 22/11, 2013 at 15:56 Comment(4)
I can't listen more as on VHost on port 80 ?Transcribe
@y_nk I am guessing you are facing the issue while using same IP+PORT combination with two or more VirtualHost like above (*:80) where * is for all IPs(it may vary for definite IP like 209.207.228.12:80). If yes then you have to tell the Apache that *:80 is being used by two different VirtualHost directives. Hence you need to add NameVirtualHost *:80(For above case) before adding these two directives. After then ServerAlias will pick your configuration accordingly. Hope it will solve your problem.Alburg
actually after few hours hanging in stacknetwork i found the proper answer : https://mcmap.net/q/396483/-virtual-host-on-ubuntu-13-10-and-apache-2-4-6 it looks weird but it works :) thanks @MandipMankotiaBacksword
This answer is somehow misleading. Also note that the NameVirtualHost directive is deprecated since years.Aghast

© 2022 - 2024 — McMap. All rights reserved.