ffoiled
Posts: 39
Joined: Sat Mar 23, 2013 12:11 pm
Location: Just outside the asylum

Apache2 403 error on rebuilt Pi

Fri Jun 12, 2020 11:49 am

I've just rebuilt a Pi2 from Stretch to Buster (by replacing the SD card), and now I can't get Apache2 to work properly.

On the basic install it is OK, the index page in /var/www comes up as expected. However, I'm running all my web stuff from a locally mounted disc (/media/extdisc1)

I've made a copy of /etc/apache2/sites-available/000-default.conf and altered the DocumentRoot field to :

/media/extdisc1/webstuff

and restarted the apache2 service. Now I get :

Forbidden

You don't have permission to access this resource.
Apache/2.4.38 (Raspbian) Server at 192.168.1.118 Port 80

I've checked the file permissions, and the php file that I'm trying to read has :

-rw-r--r-- webuser www-data

I've also got an index.html file in the same directory, with the same permissions, and I can't read that either, so I don't think this is a PHP problem.

Looking up the file tree, /media is drwxr-xr-x root root
/media/extdisc1 is the same
/media/extdisc1/webstuff is drwxr-xr-x webuser www-data
so as far as I can see, the file permissions/ownerships are OK.

As the user pi (and webuser), I am able to access the files via the command line.

From what I've been able to dig up on various websites, that seems to cover all bases, but I'm still not able to move forward.

Adrian
Frequently Ffoiled

ffoiled
Posts: 39
Joined: Sat Mar 23, 2013 12:11 pm
Location: Just outside the asylum

Re: Apache2 403 error on rebuilt Pi

Sat Jun 13, 2020 4:34 pm

I had a thought.

As root, I created a softlink called webstuff from /var/www/html to /media/extdisc1/webstuff and then altered the DocumentRoot to /var/www/html/webstuff and I can now load my php files.

The question now is why does it work with a softlink, but not with the actual path ?

Adrian
Frequently Ffoiled

fbe
Posts: 648
Joined: Thu Aug 17, 2017 9:08 pm

Re: Apache2 403 error on rebuilt Pi

Sun Jun 14, 2020 7:14 pm

You changed the DocumentRoot to /media/extdisc1/webstuff. You also need to give Apache the permission for HTTP access to this filesystem path. E.g. the permission for HTTP-access to /var/www is given in /etc/apache2/apache2.conf

ffoiled
Posts: 39
Joined: Sat Mar 23, 2013 12:11 pm
Location: Just outside the asylum

Re: Apache2 403 error on rebuilt Pi

Sun Jun 14, 2020 7:36 pm

fbe wrote:
Sun Jun 14, 2020 7:14 pm
You changed the DocumentRoot to /media/extdisc1/webstuff. You also need to give Apache the permission for HTTP access to this filesystem path. E.g. the permission for HTTP-access to /var/www is given in /etc/apache2/apache2.conf
Thanks. That looks like something that has changed since I originally installed Apache2.

If I understand correctly, then I'll need something like :

Code: Select all

<directory /media/extdisc1/webstuff>
  Options indexes FollowSymLinks
  AllowOveride None
  Require all granted
</directory>
adding to the apache2.conf file.

Adrian
Frequently Ffoiled

ffoiled
Posts: 39
Joined: Sat Mar 23, 2013 12:11 pm
Location: Just outside the asylum

Re: Apache2 403 error on rebuilt Pi

Mon Jun 15, 2020 12:23 pm

ffoiled wrote:
Sun Jun 14, 2020 7:36 pm
fbe wrote:
Sun Jun 14, 2020 7:14 pm
You changed the DocumentRoot to /media/extdisc1/webstuff. You also need to give Apache the permission for HTTP access to this filesystem path. E.g. the permission for HTTP-access to /var/www is given in /etc/apache2/apache2.conf
Thanks. That looks like something that has changed since I originally installed Apache2.

If I understand correctly, then I'll need something like :

Code: Select all

<directory /media/extdisc1/webstuff>
  Options indexes FollowSymLinks
  AllowOveride None
  Require all granted
</directory>
adding to the apache2.conf file.

Adrian
I've tried that (and after sorting out the typos) it works.

Thanks for the assistance.

Adrian
Frequently Ffoiled

Return to “Networking and servers”