Ubuntu – Apache 2.4 & Ubuntu 14.04 error on Vagrant: “You don’t have permission to access / on this server.”

apache-2.4Ubuntuubuntu-14.04vagrantvirtualhost

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 myemail@gmail.com
    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 are 755 and the file permissions are also currently 755 (although I think they're actually supposed to be 644?).

Is my configuration incorrect?

UPDATE:

enter image description here

enter image description here

enter image description here

enter image description here

Best Answer

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 myemail@gmail.com
    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 Topic