Apache Virtualhosts-Subdomäne

Apache Virtualhosts-Subdomäne

Ich habe 2 Einträge in der 000-default-Datei. Einer davon betrifft eine Subdomain und der andere alles andere. Das Problem ist, dass nur einer funktioniert, der erste in der Datei. Wenn ich also zuerst den Subdomain-Eintrag schreibe, funktioniert das, wenn der andere, dann dieser.

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                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

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

    <Location /svn>
    DAV svn
    SVNParentPath /home/svn
    AuthType Basic
    AuthName "Your repository name"
    AuthUserFile /etc/subversion/passwd
    Require valid-user
    SVNPathAuthz On
#   SVNAdvertiseV2Protocol Off
    </Location>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName  sub.domain.com
    ServerAlias sub.domain.com

    DocumentRoot /var/www/sub.domain
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/sub.domain/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

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

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

RewriteEngine On

Antwort1

Versuchen Sie, NameVirtualHost *:80 oben in der virtuellen Hostkonfiguration zu verwenden.

Antwort2

Beide funktionieren bei mir einwandfrei ServerAdmin webmaster@localhost ServerName puppetmaster.matrix.nx DocumentRoot /var/www/html Options FollowSymLinks AllowOverride None Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all

ServerAdmin webmaster@localhost ServerName puppet.matrix.nx ServerAlias ​​puppet.matrix.nx

DocumentRoot /var/www/sub.domain
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/sub.domain/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

[root@puppetmaster conf.d]# GET http://puppetmaster.matrix.nx/ Testseite1

[root@puppetmaster conf.d]# GET http://puppet.matrix.nx/ Testseite2

verwandte Informationen