Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am not able to connect to localhost it showed me the error:


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

I removed apache2:

sudo apt-get remove apache2*

And then I reinstalled it, but it still shows the same error.

Please someone help me, as I am new to Ubuntu I don't know much.

share|improve this question
This needs more context. Why are you connecting to localhost? What are you testing? What commands are you running? – belacqua Apr 2 '13 at 17:44
I am making php pages needed to be run on localhost, thats why I am trying to connect to localhost – user146306 Apr 2 '13 at 18:28

You have to change the permissions of your web folder

chmod 775 /var/www

You also need to set ownership of the file for your web user.

share|improve this answer
also just realize you're trying to access / folder try adding in an index document otherwise you're just accessing the root directory – Dylan Dodds Apr 2 '13 at 19:36

You need to configure the filesystem to be accessable.

In apache config/virtual-host:

# Forbid default access to filesystem locations
<Directory />
    Order Deny,Allow
    Deny from all

# Allow access to filesystem location
<Directory /path-to/whatever/dir/>
    Order Allow,Deny
    Allow from all
share|improve this answer


cd var/
chmod 755 www

Check this article too.

If that doesn't work try this:

chmod 755 /var/www/
share|improve this answer
none of the commands is working. `/usr/local/apache2/htdocs': No such file or directory – user146306 Apr 2 '13 at 18:29
@Sabeer: /var/www is the canonical preconfigured location for the web root of Apache on Ubuntu/Debian. – 0xC0000022L Apr 2 '13 at 19:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.