0

I successfully installed Apache, MySQL and PHP on my Linux Mint 17.3 Mate computer few days back. After installation I could do all tasks, creating, accessing and modifying files in localhost folder /var/www/html/.

Today I wanted to test my website containing around 100 files (all with .php extension) nicely arrange in folders and subfolders. So I copied all my website files located in my Windows 10 laptop's c:/xampp/htdocs folder to the localhost folder located in my Linux Mint desktop. After copying files I'm now unable to access any file through browser, even those files which were accessible yesterday.

When I type http://localhost/ on the addressbar of the browser I get the error:

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

(command used for copying files was 'cp -a /source-folder-path/. /var/www/html/')

eps
  • 11
  • 4
  • Possible duplicate of [Error message "Forbidden You don't have permission to access / on this server"](http://stackoverflow.com/questions/10873295/error-message-forbidden-you-dont-have-permission-to-access-on-this-server) – Joe Jun 20 '16 at 12:36

3 Answers3

1

error faced by me disappeared after i changed the localhost folder permissions using the command "sudo chmod -R 777 /var/www/html".

i've been told that this command posses a security risk as it makes the folder vulnerable to attack and should be used in ONLY in developmental setup and NOT in actual website

eps
  • 11
  • 4
0

Can you paste here the apache configuration of your website?

You can create a new virtualhost into apache "/etc/apache2/sites-availables/mywebsite.conf" and paste this content:

<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/html/
DirectoryIndex your_index.php
</VirtualHost>

then enable this configuration with :

a2ensite mywebsite
service apache2 reload
R.Dussin
  • 312
  • 2
  • 6
  • Thanks R.Dussin for such a prompt reply, I tried your solution but unfortunately it didn't work, probably because the details given by me in my question were not complete. so i undid the changes suggested and then I changed the file/folder permission settings using the command "sudo chmod -R 777 /var/www/html" and the error disappeared. – eps Jun 20 '16 at 17:07
0

I understand,

When you copied your data from windows to linux, apache wasn't the owner of your data.

When you've done "sudo chmod -R 777 /var/www/html", you set the permissions for the "Others" users, but the owner isn't apache (see "ll /var/www/html").

As you said, using the "chmod 777" command is unsafe.

You have to do this:

sudo chmod -R 660 /var/www/html
sudo chown -R www-data: /var/www/html

Press F5 and tell me if it works ;)

R.Dussin
  • 312
  • 2
  • 6