Ubuntu amp Forbidden

apache-2.2permissionsPHPUbuntu

I'm trying to access my site at localhost, but I get:

"Forbidden

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

My error.log says:

PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/mcrypt.ini on line 1 in Unknown on line 0
[Sun Jun 20 08:51:51 2010] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.2 with Suhosin-Patch configured -- resuming normal operations
[Sun Jun 20 08:51:57 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:51:57 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:52:00 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:52:17 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:54:15 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:54:17 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:55:19 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:55:23 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:56:40 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 09:00:10 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 09:02:05 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 09:02:07 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 09:05:04 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 09:06:50 2010] [notice] SIGHUP received.  Attempting to restart
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/mcrypt.ini on line 1 in Unknown on line 0
[Sun Jun 20 09:06:50 2010] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.2 with Suhosin-Patch configured -- resuming normal operations
[Sun Jun 20 09:06:57 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 09:08:46 2010] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /var/www/index.html
[Sun Jun 20 09:08:59 2010] [error] [client 127.0.0.1] PHP Warning:  Unknown: failed to open stream: Permission denied in Unknown on line 0
[Sun Jun 20 09:08:59 2010] [error] [client 127.0.0.1] PHP Fatal error:  Unknown: Failed opening required '/var/www/test.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
[Sun Jun 20 09:09:47 2010] [error] [client 127.0.0.1] PHP Warning:  Unknown: failed to open stream: Permission denied in Unknown on line 0
[Sun Jun 20 09:09:47 2010] [error] [client 127.0.0.1] PHP Fatal error:  Unknown: Failed opening required '/var/www/test.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
[Sun Jun 20 09:09:54 2010] [notice] SIGHUP received.  Attempting to restart
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/mcrypt.ini on line 1 in Unknown on line 0
[Sun Jun 20 09:09:54 2010] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.2 with Suhosin-Patch configured -- resuming normal operations
[Sun Jun 20 09:09:55 2010] [error] [client 127.0.0.1] PHP Warning:  Unknown: failed to open stream: Permission denied in Unknown on line 0
[Sun Jun 20 09:09:55 2010] [error] [client 127.0.0.1] PHP Fatal error:  Unknown: Failed opening required '/var/www/test.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
[Sun Jun 20 09:15:28 2010] [notice] Graceful restart requested, doing restart
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/mcrypt.ini on line 1 in Unknown on line 0
[Sun Jun 20 09:15:28 2010] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.2 with Suhosin-Patch configured -- resuming normal operations
[Sun Jun 20 09:16:51 2010] [notice] Graceful restart requested, doing restart
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/mcrypt.ini on line 1 in Unknown on line 0
[Sun Jun 20 09:16:51 2010] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.2 with Suhosin-Patch configured -- resuming normal operations
[Sun Jun 20 09:16:52 2010] [notice] Graceful restart requested, doing restart
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/mcrypt.ini on line 1 in Unknown on line 0
[Sun Jun 20 09:16:52 2010] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.2 with Suhosin-Patch configured -- resuming normal operations
[Sun Jun 20 09:17:04 2010] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /var/www/index.html
[Sun Jun 20 09:17:07 2010] [error] [client 127.0.0.1] (13)Permission denied: cannot read directory for multi: /var/www/
[Sun Jun 20 09:17:15 2010] [error] [client 127.0.0.1] PHP Warning:  Unknown: failed to open stream: Permission denied in Unknown on line 0
[Sun Jun 20 09:17:15 2010] [error] [client 127.0.0.1] PHP Fatal error:  Unknown: Failed opening required '/var/www/test.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
[Sun Jun 20 09:18:38 2010] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /var/www/index.html

I chowned to myusername:myusername /var and /var/www, chmoded to 711 /var and 751 /var/www, I tried recursive chowning on /var and recursive chmoding on /var/www, but still nothing.

How to access my site?

UPDATE:

var and www are chowned www-data:deltrem, var is chmoded 711, www 751, it still doesn't work 🙁

recursive chowning on var (luckyfully) doesn't seem to have worked

Best Answer

/var should stay chmod 755 and root:root. There is no reason to change /var.

For /var/www try:

chown -R myusername:www-data /var/www
chmod -R 755 /var/www

Make sure you keep this permissions when you create files. And you will probaby need to change some files to 775 on those that need to be written by apache2.

Important: Note that doing it this way, anybody who has access to your user account can modify the websites files.