Apache 2.4 & Ubuntu 14.04 error on Vagrant: "You don't have permission to access / on this server."
As usual, my issue was totally my fault and due to my ignorance :-)
I needed to use the Directory
directive to grant users permission to access the directory I chose to put my site's files in. This is my final working configuration:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.shopwise.dev
ServerAlias shopwise.dev
DocumentRoot /home/shopws/public_html
# Logfiles
ErrorLog /home/shopws/logs/apache/error.log
CustomLog /home/shopws/logs/apache/access.log combined
</VirtualHost>
<Directory /home/shopws/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
I hope that helps someone else someday!
Related videos on Youtube
Nate
I'm a senior in college, majoring in EE and minoring in CS, with a passion for electronics and programming. I'm an entrepreneur and started a small hobby electronics company called FoxyTronics a few years ago, and am now working on launching a shopping website called PriceWombat.
Updated on September 18, 2022Comments
-
Nate over 1 year
I realize there are a lot of similar questions on here, but I've been struggling with this for hours and have been unable to find a solution.
When I try visiting my Vagrant Ubuntu box via the host name
shopwise.dev
(set to the Vagrant box's IP in/etc/hosts
), I get the following error page:Forbidden You don't have permission to access / on this server. Apache/2.4.7 (Ubuntu) Server at shopwise.dev Port 80
I created the file
/etc/apache2/sites-available/shopwise.conf
:ServerName host.foxytronics.com NameVirtualHost *:80 <Directory /> Options FollowSymLinks AllowOverride All Require all granted </Directory> <Directory "/home/shopws/public_html"> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> <VirtualHost *:80> ServerAdmin [email protected] ServerName www.shopwise.dev ServerAlias shopwise.dev DirectoryIndex index.php Options FollowSymLinks DocumentRoot "/home/shopws/public_html" # Logfiles ErrorLog /home/shopws/logs/apache/error.log CustomLog /home/shopws/logs/apache/access.log combined </VirtualHost>
Then ran:
sudo a2ensite shopwise.conf service apache2 reload
I verified the directory permissions along the path
/home/shopws/public_html
are755
and the file permissions are also currently755
(although I think they're actually supposed to be644
?).Is my configuration incorrect?
UPDATE:
-
drookie over 8 years
NameVirtualHost *:80
has no effect in apache 2.4.x. Does the directory actually contain an index file ? -
Nate over 8 years@drookie Thanks for your reply! Yes, there is an index.php file here:
/home/shopws/public_html/index.php
. One thing that just occurred to me is that the files are "owned" by the uservagrant
. Could it be that Apache isn't able to open the files because it doesn't "own" them? I guess that is kind of a Vagrant-specific question.. -
drookie over 8 yearsnope, owner is not the reason since you have sufficient permissions. what will happen if you will request shopwise.dev/index.php exactly ?
-
Nate over 8 years@drookie I see the same error when going to that URL. I added a few screenshots to my question, for what it's worth..
-
drookie over 8 yearsAnd what does the apachectl -S show ?
-
Nate over 8 years@drookie Added a screenshot. Thanks again for your help!
-
AlexR over 8 yearsWhat about error log file, what do you see there, maybe paste here? Who is the owner of /home/shopws/ and subfolders (you should have vagrant). Do you have an index.something?
-
Nate over 8 years
root
is the owner of/home
, vagrant is the owner of/home/shopws
on down. I'm not sure what you mean byindex.something
? I'm having trouble finding the error logs, but will post them once I do. Thanks for your help! -
Nate over 8 yearsThe error log file hasn't been created, then. Yes, there is an index.php file at
/home/shopws/public_html/index.php
.
-
-
Nate over 8 yearsThe error log file hasn't been created, then. Yes, there is an index.php file at
/home/shopws/public_html/index.php
. Also, you should update your other answer or post a comment on your other answer instead of posting a new answer :-) -
AlexR over 8 yearsWell I'm kinda new to this.
-
AlexR over 8 yearsBut what about access.log???
-
Martin Joiner almost 8 yearsJust saved my day! :-)