XAMPP (Mac) Virtual host showing 403

2019-01-23 15:25发布

问题:

I keep getting Access Forbidden Error 403 when I try running my installation of XAMPP on my MAC

I am running the project outside of /Applications/XAMPP/htdocs. It's in my /Users/my_user_name/Projects/ directory.

Every time I try and go to my virtualhost I get a 403 error: Access forbidden.

I have edited my httpd-vhosts.conf file and I have allowed Virtual hosts in httpd.conf.

I have also set the User and Group to User my_user_name and Group Admin in httpd.conf

I even tried chmoding all my files and directory 777 but I still get Access forbidden.

I have also change Deny to Allow in the httpd-xampp.conf file in the new security settings.

The erro_log provided by XAMPP doesn't mention the 403 error I do see it in my access log as 127.0.0.1 - - [21/Aug/2013:14:45:20 -0400] "GET / HTTP/1.1" 403 1034

I turned on errors and I am seeing this [authz_core:error] [pid 52813] [client 127.0.0.1:57473] AH01630: client denied by server configuration:

Not sure what else to check or try. Please help lol.

回答1:

Just to have the answer right here: You can permit access by adding Require all granted to each VirtualHost in your httpd-vhosts.conf:

# VirtualHost for my.site.com
<VirtualHost *:80>
    ServerAdmin webmaster@site.com
    DocumentRoot "/Users/me/www/my.site.com/"
    ServerName my.site.com
    <Directory "/Users/me/www/my.site.com">
        ServerSignature Off
        Options Indexes FollowSymLinks IncludesNoExec
        AllowOverride All

        #Order allow,deny  <- You can remove this
        #Allow from all    <- and that

        # Insert the following:
        Require all granted

    </Directory>
</VirtualHost>

Good luck!



回答2:

I kept having this 403 issue and could not find an answer UNTIL...

Curly (right and left) quotes where in my vhosts file.

If you see something like "xe2\x80\x9c" in your error log then this is your problem.

I opened the httpd-vhosts.conf file in a reliable editor (I used Dreamweaver) and noticed that the quotations are curly ones (left and right quotes). They need to be straight quotes. The regular text editor on my Mac would auto change any quotes I make to these curly ones and I wasn't noticing it.

Hopefully this answer will help someone.



回答3:

In my case problem was with user definition in httpd.conf for Windows:

User daemon
Group daemon

Changed to

User myusername

And it worked

For linux:

User myusername
Group sudo

For OSX:

User myusername
Group admin

also you might have to set permissions on folder

sudo chown -R yourusername /Applications/XAMPP/xamppfiles/htdocs


回答4:

I found something that actually fixed my issue at the following link. I hope this saves someone hours of pulling out their hair. lol

http://www.apachefriends.org/f/viewtopic.php?p=198815&sid=35790f5d017f27c93c1fd4d260b35128



回答5:

I got this error because I forgot to set my 'DocumentRoot' url and my 'Directory' url the same.

#dl local
<VirtualHost *:80>
    ServerName dl.local
    DocumentRoot "/Users/myuser/dl_live"               <<< ----- This URL has to match
    <Directory "/Users/myuser/dl_live">                <<< ----- this URL
        Options Indexes FollowSymLinks IncludesNoExec
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog "logs/dl.local_error_log"
</VirtualHost>

If you do this you may see an error like this in your error log file:

[Tue Feb 03 13:50:26.189944 2015] [authz_core:error] [pid 25254] [client 127.0.0.1:54841] AH01630: client denied by server configuration: /Users/myUsername/path/to_local/virtual_host/