Mac apache localhost 给出 403 Forbidden

2024-02-14

我正在尝试在我的新 mac OSX 10.9 上设置本地环境。我知道它已经安装了apache,所以我一直在使用它。无论我如何设置 httpd-vhosts.conf/hosts/httpd.conf 文件,在浏览器上访问 localhost 或“test.com”时,我都会不断收到 403 禁止错误。下面列出了错误/文件/其他信息。

这是我访问任一网页时遇到的错误

Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

我的 /private/etc/hosts 文件

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost

127.0.0.1       test.com
127.0.0.1       www.test.com

我的 /private/etc/apache2/httpd.conf 文件

This file is in its original form besides the following changes:
Uncommented Include /private/etc/apache2/extra/httpd-vhosts.conf

我的 /private/etc/apache2/extra/httpd-vhosts 文件

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /Library/WebServer/Documents/
</VirtualHost>

<VirtualHost *:80>
        ServerName test.com
        ServerAlias www.test.com
        DocumentRoot "/Users/[my_name]/Sites/test"

        <Directory "/Users/[my_name]/Sites/test">
                Options Indexes FollowSymLinks Includes ExecCGI
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

其他注意事项

I've created a config file my user account in /private/etc/apache/users/
I've given that file read and write permissions to "everyone"
I've restarted apache after every save to any config file
I've reset the cache on my browser every time I make a change to these files
I have an index.html file set up in my /Users/[my_name]/Sites/test/ folder

使用命令 sudo apachectl -t 时

Warning: DocumentRoot [/usr/\xe2\x80\x9c/Users/joshwoelfel/Sites/test\xe2\x80\x9d] does not exist
httpd: Could not reliably determine the server's fully qualified domain name, using Joshs-MacBook-Air.local for ServerName
Syntax OK

我现在不知道该尝试什么。我花了几个小时查看教程和人们发布的其他问题。看来我的文件和权限是正确的!


我刚刚解决了这个问题。尝试添加“要求所有已授予”而不是“允许所有”。

<VirtualHost *:80>
    ServerName test.com
    ServerAlias www.test.com
    DocumentRoot "/Users/[my_name]/Sites/test"

    <Directory "/Users/[my_name]/Sites/test">
            Options Indexes FollowSymLinks Includes ExecCGI
            AllowOverride All
            Require all granted 
    </Directory>
</VirtualHost>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Mac apache localhost 给出 403 Forbidden 的相关文章

随机推荐

  • 如何在文本板中使用正则表达式逐行删除指定字符后的任何内容?

    假设我在 Textpad 中有以下文本 kwejkewrjl ksajdlakj e833ekjh skdjkahak 2098e123809 ksjdkas dkjwhfdkjqhio skjddksjal 98a09asfdsaok k
  • 矢量化 SciPy ode 求解器

    我的问题是关于当前的 scipy ode 求解器 来自scipy 文档页面 http docs scipy org doc scipy reference generated scipy integrate ode html scipy i
  • Linq 中的 ToList 方法

    如果我没记错的话 ToList 方法会迭代提供的集合的每个元素 并将它们添加到 List 的新实例中并返回此实例 假设一个示例 using linq list Students Where s gt s Name ABC ToList tr
  • 为什么将 min 和 max 列为序列运算?

    Python 的文档中有一个表格 其中包含 常用序列操作 https docs python org 3 library stdtypes html common sequence operations 大多数序列类型都支持 它列出了例如x
  • Android 中使用 Google API 的依赖 apache HTTP 客户端

    我一直在使用 Google Play 服务库 仅通过 Google 登录 效果很好 但现在我想将日历 API 包含到我的应用程序中 我正在关注本教程 https developers google com google apps calen
  • 使用 wsdl2java/Apache CXF 生成 Web 服务代理类

    我正在尝试使用 Apache CXF 附带的 wsdl2java 工具生成 Web 服务代理 生成本身似乎一切顺利 但生成的文件中存在一些错误 调用了不存在的构造函数 该文件提供了解决方案 This constructor requires
  • 以编程方式生成 Apache Spark 中数据帧的架构和数据

    我想动态生成一个包含报告标题记录的数据帧 因此根据以下字符串的值创建一个数据帧 val headerDescs String Name Age Location val headerSchema StructType headerDescs
  • 将 HTTP 请求标头键值获取到条件检查中

    我已在 Azure 门户中创建了一个逻辑应用程序 它是由 HTTP POST 触发的 在该 POST 中我设置了一个名为 jmb private key 的密钥 逻辑应用程序收到 HTTP 请求后 我放置了一个条件 我想检查其密钥 检查He
  • .class 样式到 .class B 样式可以轻松制作动画吗?

    有没有一种方法可以在 Jquery 中设置动画而无需指定每个属性 让我们说 classA color red classB color blue function animate selector classA classB time st
  • 猫头鹰的含义:有值吗?

    一个的含义是什么owl hasValue限制 以及它与owl allValuesFrom and owl someValuesFrom 在本体论中 我想写一个公理 每个拥有文凭的人都是有文化的 我该怎么写这个 不同类型的限制类别 考虑一个个
  • Microsoft Bot 中的相同线程重复欢迎消息

    我有一条欢迎消息 配置为在我的机器人第一次启动时出现在 MessagesController 中 private Activity HandleSystemMessage Activity message if message Type A
  • Perl 是否有计算字符串中匹配项数量的快捷方式?

    假设我有 my string one two three four 我应该如何利用上下文来获取模式找到匹配项的次数 3 这可以使用单行完成吗 我试过这个 my number scalar string gi 我认为通过加上括号 number
  • 通过 Graph API 评论 Facebook 页面评级(评论)

    长期潜伏者第一次海报 我们正在与 Facebook API 合作 将其集成到我们的网络应用程序中 并且我们能够通过 page id ratings 部分中的 open graph story 参数获取公司页面评级 但是我们找不到评论 回复的
  • Buffer.BlockCopy 与不安全的 byte* 指针复制

    复制字节块时哪个性能更好 Buffer BlockCopy非常优化 它基本上是原始内存副本的包装器 所以它应该非常快 并且避免弄乱指针和unsafe代码 它应该是默认的 你当然可以用各种方式来衡量
  • HList 选项的幂集

    我正在玩 Shapeless 我正在尝试计算 某种 powerset https en wikipedia org wiki Power set of an HList of Options 基本上 我想解释一下HList作为一个集合 在这
  • Angular2 /错误:找不到集合

    我对 Angular2 很陌生 正在尝试构建一个 Todo 应用程序 这是我的文件结构 My todo service ts代码 里面shared folder import Injectable from angular core imp
  • tkinter 中的“权重”有什么作用?

    我一直在搜索不同的网站 试图找出权重在 tkinter 中的作用 我从那里得到这个TkDocs http www tkdocs com tutorial grid html 每列和行都有一个与之关联的 权重 网格选项 该选项告诉它如果母版中
  • 使用 UNION 将数据拉入网格

    我的网站上有一个数据网格 我从两个表中提取公司信息 我正在创建一个表单来根据 3 个过滤器 类别 州 城市 对这些结果进行排序 这是我最初将数据加载到网格中的查询 我希望它填充我的所有表数据 直到用户决定过滤它 这就是为什么我使用 UNIO
  • 使用 gradle 'java-library' 时无法引用库中的类

    升级到 Android Studio 3 0 后我还使用新的 android gradle 插件com android tools build gradle 3 0 0 alpha1我想用java 库 https docs gradle o
  • Mac apache localhost 给出 403 Forbidden

    我正在尝试在我的新 mac OSX 10 9 上设置本地环境 我知道它已经安装了apache 所以我一直在使用它 无论我如何设置 httpd vhosts conf hosts httpd conf 文件 在浏览器上访问 localhost