8

Desired Behaviour

To be able to access localhost in browser without getting 403 Forbidden message.

Current Behaviour

Navigating to localhost in browser returns:

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

Steps To Reproduce

I set up a local server on Linux Mint 17 Cinnamon using these steps:

$ sudo apt-get install apache2 php5
$ sudo apt-get install php5-dev php5-cli
$ sudo apt-get install php-pear
$ pear version
// PEAR Version: 1.9.4
// PHP Version: 5.5.9-1ubuntu4.5
// Zend Engine Version: 2.5.0
// Running on: Linux my-computer 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64

$ pecl version ## as above

$ sudo pecl install mongo ## this installs the mongo driver

At this point, I was prompted with something containing [no] and I pressed enter.

$ cd /etc/php5/apache2
$ sudo vi php.ini

At the end of the file I added: extension=mongo.so

$ sudo /etc/init.d/apache2 restart

At the end of this process, yesterday, I could access localhost successfully.

Today, I am getting the 403 error when navigating to localhost.

Troubleshooting

Apache Status

me@my-computer ~ $ /etc/init.d/apache2 status
 * apache2 is running

Permissions

/var

drwxr-xr-x  12 root root  4096 Nov 23 08:58 var

/var/www

drwxr-xr-x  3 root root   4096 Nov 23 08:58 www

/var/www/html

drwx------ 8 me me 4096 Nov 22 01:07 html

/var/www/html/index.html

-rw-r--r-- 1 root  root  11510 Nov 23 08:59 index.html
8

Looking at the permissions of /var/www/html showed me that only user root had Read Write Execute permissions. As I was using the browser just as a standard user and not getting access, I assumed that 'Other' needed some permissions, so I did this:

sudo chmod 755 html -R

And the new permissions are now:

drwxr-xr-x 2 me me 4096 Nov 23 22:59 html

Now I can access localhost in a browser.

I found this video on "Users, Groups and Permissions in Linux" very helpful:

http://youtu.be/zRw0SKaXSfI

  • 2
    That sounds exactly right. Thanks for taking the time to post it as an answer! – terdon Nov 23 '14 at 16:13
  • Thank you for assisting in clarifying my information sources! – user1063287 Nov 23 '14 at 16:19
0

You shoud give apache execute/read access. The way @user1063287 said is good but may have security issues, giving access to other. I think this way is better:

1) make apache owner of your site root:

chown -R www-data:www-data ROOT_OF_SITE

2) give it full access

chmod -R 700 ROOT_OF_SITE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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