Mac OSX (El Capitan) 虚拟主机 - 挑战配置自定义虚拟主机

Mac OSX (El Capitan) Virtual Hosts - challenge configuring custom virtual hosts

我在 mac 上配置了本地 Apache 服务器。我想配置自定义虚拟主机,例如:project1.local 等...

默认情况下我可以访问根文件夹所在的本地主机 /Library/WebServer/Documents

我在文档文件夹中创建了新文件夹 /Library/WebServer/Documents/typo3project

比我在/etc/apache2/httpd.conf中包含的: 包括 /private/etc/apache2/vhosts/*.conf

在 vhosts 中我创建了自定义虚拟主机配置文件: typo3project.local.conf

我遇到 403 错误(您没有权限访问...在此服务器上。)

我设置了文件夹权限:drwxr-xr-x

typo3project.local.conf

<VirtualHost *:80> 
    DocumentRoot "/Library/WebServer/Documents/typo3knjiga/" 
    ServerName typo3knjiga.test 
    <Directory "/Library/WebServer/Documents/typo3knjiga"> 
        AllowOverride All 
        Require all granted 
    </Directory> 
</VirtualHost>

您的虚拟主机配置未指定 DirectoryIndex。如果未启用选项索引,则可能会导致 403,因为当您请求 http://typo3knjiga.test/ 时,return 没有允许的资源。假设您有 index.html 或 index.php,请尝试添加以下内容:

<VirtualHost *:80>
    ...
    DirectoryIndex index.html index.php
</VirtualHost>

顺便说一句,你没有提到它,但我假设你已经在你的 /etc/hosts 文件中添加了一条记录,例如:

127.0.0.1 typo3knjiga.test