![](/img/trans.png)
[英]MacOS XAMPP Access Forbidden Error 403 - You don't have permission to access the requested directory
[英]Getting: Forbidden - You don't have permission to access this resource
Mac OS Big Sur - 11.4
我正在嘗試設置一些本地虛擬主機。 我做了以下事情:
修改了 httpd.conf 文件,以包含 vhosts 文件夾:
Include /usr/local/etc/httpd/extra/proxy-html.conf
在我的 /usr/local/etc/httpd/extra/proxy-html.conf 中,我有:
<VirtualHost *:80>
ServerAdmin myemailaddress.com
DocumentRoot "~/Dropbox/cms/drupal_local"
ServerName drupal.local
ErrorLog "/usr/local/var/log/httpd/drupal.local.error.log"
CustomLog "/usr/local/var/log/httpd/drupal.local.access_log" common
</VirtualHost>
然后我修改了 /etc/hosts 文件如下:
27.0.0.1 localhost drupal.local
255.255.255.255 broadcasthost
::1 localhost
我確定我有一個文件夾 ~/Dropbox/cms/drupal_local
在其中,我創建了一個簡單的 index.html,上面寫着:
<h1>Testing local drupal vhost</h1>
然后我做了:
brew services restart httpd
結果是:
Stopping `httpd`... (might take a while)
==> Successfully stopped `httpd` (label: homebrew.mxcl.httpd)
==> Successfully started `httpd` (label: homebrew.mxcl.httpd)
然后我去我的瀏覽器,輸入:
http://drupal.local
回應是:
Forbidden
You don't have permission to access this resource.
我錯過了什么?
這是最終的工作:
我修改了我的 /usr/local/etc/httpd/extra/proxy-html.conf 如下:
<VirtualHost *:80>
ServerAdmin myemailaddress.com
DocumentRoot "~/Dropbox/cms/drupal_local"
ServerName drupal.local
<directory "~/Dropbox/cms/drupal_local/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</directory>
ErrorLog "/usr/local/var/log/httpd/drupal.local.error.log"
CustomLog "/usr/local/var/log/httpd/drupal.local.access_log" common
</VirtualHost>
和我的 /etc/hosts 文件如下:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 drupal.local
然后:
brew services restart httpd
我剛剛在 MacOS Monterey 上遇到了同樣的問題。 根據日志,它是由自動索引錯誤引起的。
我通過將index.php
添加到httpd.conf
中的DirectoryIndex
來修復它(在我的例子中是路徑/usr/local/etc/httpd/httpd.conf
):
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
(然后當然是用brew services restart httpd
重啟服務以使更改生效)
對於在 MacOS Monteray 中仍然遇到此問題的任何人,經過幾天的搜索,我終於在蘋果論壇文章中找到了解決方案:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.