Ubuntu – 403 Forbidden Error after changing LAMP Apache root/ www directory

Apache2lamppermissionsPHPserver

I installed and set up all the LAMP services, and got it working from the www folder, thing it though I need it to point to a folder in my Dropbox (on the same partition)

I modified the /etc/apache2/sites-enabled/000-default.conf so it now looks like:

<VirtualHost *:80>
    ServerAdmin admin@mysite.com
    ServerName mysite.com
    ServerAlias www.mysite.com *.mysite.com
    DocumentRoot /home/alicia/Dropbox/Programing/PHP/intern-magnet
<Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>
    <Directory /home/alicia/Dropbox/Programing/PHP/intern-magnet/>
Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel info

    CustomLog /var/log/apache2/access.log common
    ServerSignature On

I also modified the permissions of the new root directory at every level making it drxr-xr-x / 755
The namei -m command outputed the following for the new root directory, which all looks fine to me:

drwxr-xr-x /
 drwxr-xr-x home
 drwxr-xr-x alicia
 drwxr-xr-x Dropbox
 drwxr-xr-x Programing
 drwxr-xr-x PHP
 drwxr-xr-x intern-magnet

The last few entries in the /var/log/apache2/error.log read:

[Sun Dec 21 13:38:09.265113 2014] [authz_core:error] [pid 8096] [client 127.0.0.1:33250] AH01630: client denied by server configuration: /home/alicia/Dropbox/Programing/PHP/intern-magnet/favicon.ico
[Sun Dec 21 13:38:16.115896 2014] [authz_core:error] [pid 8097] [client 127.0.0.1:33251] AH01630: client denied by server configuration: /home/alicia/Dropbox/Programing/PHP/intern-magnet/css
[Sun Dec 21 13:38:16.232509 2014] [authz_core:error] [pid 8097] [client 127.0.0.1:33251] AH01630: client denied by server configuration: /home/alicia/Dropbox/Programing/PHP/intern-magnet/favicon.ico
[Sun Dec 21 13:38:22.717367 2014] [authz_core:error] [pid 8102] [client 127.0.0.1:33252] AH01630: client denied by server configuration: /home/alicia/Dropbox/Programing/PHP/intern-magnet/favicon.ico

Oh yeah, and I am running Ubuntu GNOME 14.10

So basically it has not got permission, but WHY?! I have spent all day and most of last night trying to figure this out, I've gone through loads of tutorials, still can't see what I'm missing.

Any ideas or help would be much appreciated, thanks in advance 🙂

I have read some similar questions to this on askubuntu but none of the solutions workes, so I guess this is a different problem and therefore not a duplicate

Best Answer

It appears that you're running Apache 2.4; they changed the auth module between 2.2. and 2.4.

<Directory /home/alicia/Dropbox/Programing/PHP/intern-magnet/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    # Remove Apache 2.2 access controls
    #Order allow,deny
    #allow from all

    # Add Apache 2.4 access controls
    Require all granted
</Directory>

Other thoughts to consider: generally it is considered "best practice" to house your personal web development projects in ~/public_html, enable the usedir module a2enmod userdir, allow PHP to execute code there, and finally call the URL by browsing to http://localhost/~alicia/intern-magnet

Specific steps if you're interested in this tangent:

sudo a2enmod userdir
sudo $EDITOR /etc/apache2/mods-enabled/php5.conf
# Comment out lines "<IfModule mod_userdir.c> ... </IfModule>"
# This re-allows executing PHP code by users of your workstation, (presumably only you).
mkdir ~/public_html
ln -s ~/Dropbox/Programing/PHP/intern-magnet ~/public_html/intern-magnet
sudo service apache2 restart
# Develop and Profit!

Additional projects you start simply need their code linked to inside ~/public_html just like the above ln -s command, then browse to /~alicia/PROJECT_NAME_HERE!

Related Question