Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache2 virtualhost 403 forbidden?

I'm running ubuntu 13.04 64bit on my desktop, I installed Apache2, MySQL and PHP etc.

I wanted to have my web root in /home/afflicto/public_html instead of /var/www. So I went along with this guide:
http://www.maketecheasier.com/install-and-configure-apache-in-ubuntu/2011/03/09
(I did everything from "configuring different sites") as I like the solution more.

Here's what I did:
Installed Apache2, MySQL etc..
copied /etc/apache2/sites-avaliable/default to /etc/apache2/sites-available/afflicto. Then edited it, it now looks like the following:

/etc/apache2/sites-available/afflicto

<VirtualHost *:80> ServerAdmin webmaster@localhost  DocumentRoot /home/afflicto/public_html <Directory />     Options FollowSymLinks     AllowOverride None </Directory> <Directory /home/afflicto/public_html/>     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>   

I did sudo a2dissite default && sudo a2ensite afflicto && sudo service apache2 restart

I created a index.php and index.html in /home/afflicto/public_html/test/
when accessing localhost/test or localhost/test/index.html etc, I get 403 forbidden error.

What am I doing wrong? thanks in advance.

update 1
I have set the owner of the public_html directory to www-data.
Also sudo chmod -R +x public_html && sudo chmod -R 777 public_html
Still same 403 error.

Here's the output of the apache error log:

[Sun Jul 14 06:10:32 2013] [error] [client 127.0.0.1] (13)Permission denied: access to / denied  [Sun Jul 14 06:10:32 2013] [error] [client 127.0.0.1] (13)Permission denied: access to /favicon.ico denied 
like image 769
Petter Thowsen Avatar asked Jul 14 '13 03:07

Petter Thowsen


People also ask

How do I fix 403 Forbidden nginx ubuntu?

However, if the specified index files are not in the directory, Nginx will return 403 forbidden error. One way to resolve this issue is to add the index file specified in the configuration file or add the available index file to the config file.


1 Answers

I was faced with this issue. But I didn't like the idea of changing the group of my home directory to www-data. This problem can simply be solved by modifying the configuration file for the virtualHost. Simply configure the Directory tag to include these

<Directory "your directory here">    Order allow,deny    Allow from all    Require all granted </Directory> 

The Require all granted is a new feature I guess; having a default value of denied.

see this page for further info: http://httpd.apache.org/docs/current/mod/core.html#directory

like image 110
Peter Avatar answered Sep 20 '22 07:09

Peter