3

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

  • NameVirtualHost *:80 has no effect in apache 2.4.x. Does the directory actually contain an index file ? – drookie Sep 19 '15 at 16:37
  • @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 user vagrant. 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.. – Nate Sep 19 '15 at 16:41
  • nope, owner is not the reason since you have sufficient permissions. what will happen if you will request shopwise.dev/index.php exactly ? – drookie Sep 19 '15 at 16:49
  • @drookie I see the same error when going to that URL. I added a few screenshots to my question, for what it's worth.. – Nate Sep 19 '15 at 16:51
  • And what does the apachectl -S show ? – drookie Sep 19 '15 at 17:09
2

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!

-1

By index.something I mean index.html, index.php, etc. Here is your error file: ErrorLog /home/shopws/logs/apache/error.log

step 1 tail -f /home/shopws/logs/apache/error.log

step 2 hit Refresh or F5 on the browser, you should see something here, if not do the same but with: tail -f /home/shopws/logs/apache/access.log

And you should also see something here, and paste the last lines here.

  • The 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 :-) – Nate Sep 19 '15 at 18:06
  • Well I'm kinda new to this. – AlexR Sep 19 '15 at 18:10
  • But what about access.log??? – AlexR Sep 19 '15 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.