简体   繁体   中英

Getting: Forbidden - You don't have permission to access this resource

Mac OS Big Sur - 11.4

I am trying to set up some local vhosts. I did the following:

Modified the httpd.conf file, to include the vhosts folder:

Include /usr/local/etc/httpd/extra/proxy-html.conf

And in my /usr/local/etc/httpd/extra/proxy-html.conf, I have:

<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>

I then modified the /etc/hosts file as follows:

27.0.0.1    localhost drupal.local
255.255.255.255 broadcasthost
::1             localhost

I made sure I had a folder ~/Dropbox/cms/drupal_local

And in it, I created a simple index.html, that says:

<h1>Testing local drupal vhost</h1>

I then did:

brew services restart httpd

And the result was:

Stopping `httpd`... (might take a while)
  ==> Successfully stopped `httpd` (label: homebrew.mxcl.httpd)
  ==> Successfully started `httpd` (label: homebrew.mxcl.httpd)

I then went to my browser, and typed:

http://drupal.local

And the response was:

Forbidden
You don't have permission to access this resource.

What am I missing?

Here's what ended up working:

I modified my /usr/local/etc/httpd/extra/proxy-html.conf as follows:

<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>

and my /etc/hosts file as follows:

127.0.0.1    localhost 
255.255.255.255 broadcasthost
::1             localhost
127.0.0.1    drupal.local

Then:

brew services restart httpd

I just had the same issue on MacOS Monterey. Based on the logs, it was caused by an autoindex error.

I fixed it by adding index.php to DirectoryIndex in httpd.conf (path /usr/local/etc/httpd/httpd.conf in my case):

<IfModule dir_module>
   DirectoryIndex index.html index.php
</IfModule>

(Then of course, restart the service with brew services restart httpd for changes to take effect)

For anyone still having this issue in MacOS Monteray, after days of searching I finally found the solution in the apple forums article:

https://discussions.apple.com/docs/DOC-250004361

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM