为什么 Ubuntu 中 Apache 的默认站点有“”吗?

为什么 Ubuntu 中 Apache 的默认站点有“”吗?

这些是 /etc/apache2/sites-available/default 的内容

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

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

    # 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 None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

下面的块是做什么用的?

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

答案1

该块适用于根目录或/目录。请记住语法是<Directory /path/to/files>。在您的示例中,路径是/

这意味着其下的任何目录/都会有规则:Options FollowSymlinks除非AllowOverride None有针对特定目录覆盖该规则的规则。

要了解这些指令的含义,请查看Apache 指令索引

相关内容