允许在 apache2.conf 文件中浏览目录 - 不起作用

允许在 apache2.conf 文件中浏览目录 - 不起作用

我试图允许在apache2.conf文件中浏览目录,但重新启动服务器时出现错误。此错误导致 Web 服务器崩溃,我无法访问 localhost 目录。因此,我必须再次删除此行代码,以使服务器可用。如何允许目录浏览到 Web 服务器中的特定文件夹?是否可以允许从文件访问目录apache2.conf

以下是我在 Ubuntu 中的代码片段:

在此处输入图片描述

答案1

首先,您的代码中有一个拼写错误。 应该是。AllowOvverideAllowOverride

以下是其他一些提示:

Alias /nytest /var/www/nytest                              # this directive will make the directory accessible at http://localgost/nytest in case that your DocumentRoot is not '/var/www/' but '/var/www/html/' as it is by default
<Directory /var/www/nytest>
    Options +Indexes
    IndexOptions FancyIndexing FoldersFirst NameWidth=* DescriptionWidth=* # better appearance
    DirectoryIndex Disabled                                # disable the 'execution' of the index files
    AllowOverride None                                     # disable .htaccess files
    AddType text/plain .html .htm .shtml .php .phtml .php5 # display these file types as plain text
    php_admin_flag engine off                              # don't run arbitrary PHP code; if you've other scripting languages, disable them too.
    Order allow,deny
    Allow from all
    Require all granted
</Directory>

相关内容