Windows 10 上的 Apache 2.4.46 虚拟主机

问题描述

我在 httpd-vhosts.conf 中配置了一个虚拟主机,当我在 httpd.conf 上启用(未注释)虚拟主机并尝试访问 localhost 或本地内未在 v-host 中配置的任何链接时,总是向我显示禁止访问您没有访问此资源的权限。

(httpd-vhosts.conf)


    <VirtualHost *:80>
        ServerName workshop.test
        ServerAlias www.workshop.test
        DocumentRoot "C:/Apache24/htdocs/workshop/workshop_app/public"
        ErrorLog "logs/workshop.test-error.log"
        CustomLog "logs/workshop.test-access.log" common
    </VirtualHost>

(httpd.conf)

    Include conf/extra/httpd-vhosts.conf

解决方法

将此添加到您的 workshop.test 虚拟主机块中:

<Directory "C:/Apache24/htdocs/workshop/workshop_app/public">
    DirectoryIndex index.php
    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    Require all granted
</Directory>