0
Apache/2.4.18 (Ubuntu)
Ubuntu 16.04

I tested the initial configuration, pointed my browser to the server, and got the normal ubunutu page. Works fine.

The 000-default.conf is:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
</VirtualHost>

The index.html is in the /var/www/html directory and the /var/www/html directory has permissions set to 0755

I created a directory /home/utils/rails/public, owned the user utils. I set the permissions for this directory to 0755

I copied the file index.html from /var/www/html to /home/utils/rails/public

I then modified the /etc/apache2/sites-available/000-default.conf to the following:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /home/utils/rails/public
</VirtualHost>

I restarted apache2 and pointed the browser to the location, but this time I got the

Forbidden
You don't have permission to access / on this server

If I reverse the procedure, and change the DocumentRoot back to /var/www/html, everything works fine.

What am I doing wrong?

namei -lx /home/utils/rails/public
f: /home/utils/rails/public
Drwxr-xr-x root  root  /
drwxr-xr-x root  root  home
drwxr-xr-x utils utils utils
drwxrwxr-x utils utils rails
drwxr-xr-x utils utils public

1 Answers1

0

The following solved the problem:

<VirtualHost *:80>
   ServerAdmin myanme@myserver.net
   ServerName myserver.net
    DocumentRoot "/home/utils/rails/public"
    <Directory "/home/utils/rails/public">
        <IfModule mod_negotiation.c>
            Options -MultiViews
        </IfModule>
        AllowOverride None
        Require all granted
   </Directory>
   LogLevel warn
   ErrorLog ${APACHE_LOG_DIR}/myserver.net_error.log
   CustomLog ${APACHE_LOG_DIR}/myserver.net_access.log combined
</VirtualHost>

The key is:

Require all granted

This is used since Apache 2.4. The other directives are not key to the access issue, but I have them to disallow .htaccess directives (ALlowOverride) and deal with Multiviews

Setting permissions to 0755 works and did not need to be changed