Apache virtualhosts 子網域

Apache virtualhosts 子網域

我在 000-default 檔案中有 2 個完整的檔案。其中一個與子網域有關,另一個與其他所有內容有關。問題是只有一個有效,即文件中的第一個。因此,如果我先寫一個可以工作的子網域條目,那麼另一個就可以了。

<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 無 選項索引 FollowSymLinks MultiViews AllowOverride 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]# GET http://puppetmaster.matrix.nx/ 測試頁1

[root@puppetmaster conf.d]# GET http://puppet.matrix.nx/ 測試頁2

相關內容