Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xampp virtual host - access denied

Tags:

apache

xampp

I'm running a XAMPP server on my laptop and I'm trying to setup a virtual host.

My hosts-file looks like this:

127.0.0.1      localhost
127.0.0.1      localhost.com
127.0.0.1      ehc.local
127.0.0.1      bal.local

The httpd-vhosts.conf file looks like this:

NameVirtualHost *:80
<VirtualHost ehc.local:80>
   DocumentRoot "C:/wamp/EHC/src/main/php/www"
   ServerName ehc.local
   SetEnv APPLICATION_ENV "local"

   <Directory "C:/wamp/EHC/src/main/php/www">
      Options Indexes MultiViews FollowSymLinks
      AllowOverride All
      Order allow,deny
      Allow from all
   </Directory>
   ErrorLog "logs/ehc.dev-error_log"
   CustomLog "logs/ehc.dev-access_log" common
</VirtualHost>

When I browse to 'ehc.local', I only get the default 403-error page.

How can I fix this?

Thanks!

like image 410
gert789 Avatar asked Jan 14 '13 12:01

gert789


2 Answers

This is for osx but must be the same (or similar) in windows:

Because Apache runs as the ‘nobody’ user by default, it may not have adequate permission to browse your [OSX/Win] user directory or some of its subdirectories, in which case you’ll see a 403 ‘access forbidden’ error when you try and view your development site. Similarly, you may find that although you can view your dev site, PHP throws errors when you attempt to write files or make directories on the filesystem.

To fix this you can configure Apache to run as your [OSX/Win] user. Open httpd.conf and look for the following lines:

# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User nobody
Group nogroup

Change User to your [OSX/Win] username, and save the file:

User yourusername

Restart Apache and you should now be able to navigate your site without any issues, including manipulating files and folders using PHP.

Source

I Hope it will be helpful, Greetings!

like image 165
Gerson Avatar answered Sep 28 '22 05:09

Gerson


Changing user didn't work. For me it was this answer that did the trick: Adding VirtualHost fails: Access Forbidden Error 403 (XAMPP) (Windows 7)

Just add Require all granted to your <Directory> setup and it should work as expected.

like image 30
fseydel Avatar answered Sep 28 '22 07:09

fseydel