Субдомен Apache virtualhosts

Субдомен Apache virtualhosts

У меня есть 2 wholes в файле 000-default. Один из них о поддомене, а другой обо всем остальном. Проблема в том, что работает только один, какой первый в файле. Так что если я сначала напишу запись поддомена, которая работает, если другой, то тот.

<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

решение1

Попробуйте использовать NameVirtualHost *:80 в верхней части конфигурации виртуального хоста.

решение2

Оба работают у меня правильно ServerAdmin webmaster@localhost ServerName puppetmaster.matrix.nx DocumentRoot /var/www/html Параметры FollowSymLinks AllowOverride Нет Параметры Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all

ServerAdmin webmaster@localhost Имя_сервера puppet.matrix.nx Псевдоним_сервера 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]# ПОЛУЧИТЬ http://puppetmaster.matrix.nx/ тестовая страница1

[root@puppetmaster conf.d]# ПОЛУЧИТЬ http://puppet.matrix.nx/ тестовая страница2

Связанный контент