0

I have a Linux server and a Windows server with a external drive for my website files. The problem only exists in Linux Apache configuration, where I cannot access the files for the sites located on the external drive.

This is the structure of my external drive: /media/mintmate/NewVolume/Site with two folders, one with Accept and the other one is Testing, both have the same website folders like website a , website b with test prefix for Testing folder.

This is what I have done so far: I have created a file "sites.conf" in /etc/apache2/sites-available with this configuration:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /media/mintmate/NewVolume/Site
</VirtualHost>

and enabled this with sudo a2ensite sites.conf

Then I have edited apache2.conf file with these settings:

<Directory /media/mintmate/NewVolume/Site>
    AllowOverride None
    Require all granted
    Allow from localhost
</Directory>

After saving these files I've restarted the service(sudo service apache2 reload and sudo service apache2 restart)

When I go to localhost on the server machine I get this message "Forbidden You don't have permission to access / on this server". I have also tried http://localhost/Testing/test-a/and http://localhost/Testing/test-a/index.phpand yet the same error message.

This is the output of ls -al /media/mintmate/NewVolume/Site:

total 10 
drwxrwxrwx 1 mintmate mintmate 4096 Sep 25 18:57 . 
drwxrwxrwx 1 mintmate mintmate 4096 Sep 25 18:57 .. 
drwxrwxrwx 1 mintmate mintmate 0 Sep 21 15:35 Accept 
-rwxrwxrwx 1 mintmate mintmate 912 Sep 24 19:20 index.html 
drwxrwxrwx 1 mintmate mintmate 0 Sep 21 15:35 Testing 

I have tried all the steps here: How do I change the root directory of an apache server? and Error message “Forbidden You don't have permission to access / on this server” and still no success. What am I doing wrong?

H35am
  • 111
  • 5

3 Answers3

1

Have you tried to change the Apache user and group to mintmate? The error clearly species that user have no permission to access files or folders. You have to give apache user perssion to access website files.

For your reference:https://www.digitalocean.com/community/questions/forbidden-you-don-t-have-permission-to-access-on-this-server-additionally-a-403-forbidden-error-was-encountered

0

Allow from is the configuration syntax of Apache 2.2. Apache 2.4 is basically capable of using the 2.2 syntax, but when you mix both syntaxes the result is not necessarily what you expect.

Change

Allow from localhost

to

Require ip 127.0.0.1

On the other hand, you can just omit the line, Require all granted already allows access from everywhere, including localhost.

Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89
0

For future reference:

I've changed next item in apache2.conf :

<Directory /media/NewVolume/Site>
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride None
    Require all granted
</Directory>

and this one in 000-default.conf :

DocumentRoot /media/NewVolume/Site

After that I've changed the permissions of the folder for the user like @antony_sebastian suggested.

sudo chown -R mintmate:www-data /media/NewVolume/Site/ and sudo chmod -R 777 /media/NewVolume/Site/

H35am
  • 111
  • 5