【问题标题】:Mac OSX (El Capitan) Virtual Hosts - challenge configuring custom virtual hostsMac OSX (El Capitan) 虚拟主机 - 挑战配置自定义虚拟主机
【发布时间】:2017-05-28 14:18:56
【问题描述】:

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

我可以访问默认根文件夹所在的localhost /Library/WebServer/Documents

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

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

在虚拟主机中我创建了自定义虚拟主机配置文件: 错字3project.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>

【问题讨论】:

  • 向我们展示typo3project.local.conf的内容。文件夹的所有者/组是什么?
  • 这里是typo3project.local.conf的内容 DocumentRoot "/Library/WebServer/Documents/typo3knjiga/" ServerName typo3knjiga.test AllowOverride All 要求全部授予
  • 文件夹的所有者/组是什么?
  • 所有者是我的用户名,组是管理员
  • 为了确定,您要访问哪个 URL,http://typo3knjiga.test/?是否有 index.html 或 .php,它的所有权/权限是什么?

标签: apache localhost virtualhost osx-elcapitan


【解决方案1】:

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

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

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

127.0.0.1 typo3knjiga.test

【讨论】:

猜你喜欢
  • 2023-04-06
  • 2017-05-27
  • 1970-01-01
  • 2011-05-04
  • 2014-09-01
  • 2014-10-29
  • 2017-06-14
  • 2012-08-22
相关资源
最近更新 更多