Permission forbidden on localhost with apache2

Posted by N Alex on Server Fault See other posts from Server Fault or by N Alex
Published on 2013-08-10T15:56:32Z Indexed on 2014/05/31 9:32 UTC
Read the original article Hit count: 303

Here is what I am trying to do.

I tried to add another folder to apache and I get the following error when trying to acces testing/index.html.

The idea is that I would like to have for every customer a folder like /home/neagoe/Work/InterWebs/Projects/[PROJECT NAME]/CustomerProjects/website/dist.

Forbidden

You don't have permission to access /index.html on this server.
Apache/2.2.22 (Ubuntu) Server at testing Port 80

Here are the steps that I followed:

Step1:

sudo chmod a+x /home/neagoe/Work/InterWebs/Projects/testing/CustomerProjects/website/dist

Step2:

sudo chown -R www-data:www-data /home/neagoe/Work/InterWebs/Projects/testing/CustomerProjects/website/dist

sudo chmod -R 775 /home/neagoe/Work/InterWebs/Projects/testing/CustomerProjects/website/dist

Step3:

sudo adduser $USER www-data

Step4:

sudo a2enmod userdir

Step5:

sudo cp /etc/apache/sites-available/default /etc/apache/sites-available/testing

I edited the file /etc/apache/sites-available/testing so it looks like this:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName testing
    DocumentRoot /home/neagoe/Work/InterWebs/Projects/testing/CustomerProjects/website/dist

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /home/neagoe/Work/InterWebs/Projects/testing/CustomerProjects/website/dist/ >
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

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

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Step6:

I edited hosts ("/etc/hosts") so it looks like this:

127.0.0.1       localhost 
127.0.0.1       testing


# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Step7:

sudo a2ensite testing
sudo service apache2 restart

I searched for about 2 hours on the internet but I can't figure out what went wrong. All the pages that I found following the same steps as described above.

I know there are similar questions here on the internet, but the answer is to change permission to the directory which I did on Step2.

I am sorry if this is really a duplicate but I could't find the right answer.

Thank you!

PS. I asked this also on AskUbuntu but didn't get any answers so I'm trying my luck here.

Edit:

There isn't much on the error log or the access log.

On the access.log:

::1 - - [10/Aug/2013:11:23:28 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22   (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:29 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:31 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:32 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:33 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:34 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:35 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
127.0.0.1 - - [10/Aug/2013:11:23:23 +0300] "POST /wordpress-testing/wp-cron.php?doing_wp_cron=1376123003.7026669979095458984375 HTTP/1.0" 200 705 "-" "WordPress/3.6; http://localhost/wordpress-testing"
::1 - - [10/Aug/2013:11:23:36 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:37 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:38 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
127.0.0.1 - - [10/Aug/2013:11:31:32 +0300] "GET /index.html HTTP/1.1" 200 485 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:23.0) Gecko/20100101 Firefox/23.0"

And the last line repeats for about 200 rows.

On the error.log:

1. This lines repeat from time to time.

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525   /msql.so' - /usr/lib/php5/20100525/msql.so: cannot open shared object file: No such file or directory in Unknown on line 0
[Sat Aug 10 13:06:42 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.4.9-4ubuntu2.2 configured -- resuming normal operations
[Sat Aug 10 13:07:36 2013] [notice] caught SIGTERM, shutting down
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/msql.so' - /usr/lib/php5/20100525/msql.so: cannot open shared object file: No such file or directory in Unknown on line 0
[Sat Aug 10 13:07:37 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.4.9-4ubuntu2.2 configured -- resuming normal operations

2. And this is the predominant error. (hundreds of lines)

[Sat Aug 10 13:07:40 2013] [error] [client 127.0.0.1] (13)Permission denied: access to /index.html denied

© Server Fault or respective owner

Related posts about apache-2.2

Related posts about permissions