获取:禁止 - 您无权访问此资源

时间:2021-06-15 01:23:07

标签: macos apache macos-big-sur

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.

我错过了什么?

1 个答案:

答案 0 :(得分:0)

以下是结果:

我修改了我的 /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