Sometimes Website Administrators and users complain that they get a "403 forbidden" message while they try to access phpPgAdmin.
Generally, the 403 Forbidden Error happens when the web page (or other resource) that you're trying to open in your web browser is a resource that you're not allowed to access. Also it can trigger when Website Administrators have improperly set up permissions and you're getting denied access when you really shouldn't be.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related phpPgAdmin queries.
In this context, we shall look into how to fix this phpPgAdmin permission error.
phpPgAdmin is a mature web-based administration tool for PostgreSQL. Recently we received a support request from one of our Customers stating that they were receiving a "forbidden" message as shown below while accessing phpPgAdmin:
Forbidden
You don't have permission to access /phppgadmin/ on this server
This error generally happens due to some restrictions in the apache configuration file. After the fresh installation of phpPgAdmin, apache2 may not allow us to access phpPgAdmin.
Initially, after the installation of phpPgAdmin, we need to follow a series of configuration steps. If they are not followed, we may receive a "Not Found" message while accessing the phpPgAdmin.
To implement this, we need to configure the Apache server to tell it where to find phpPgAdmin.
First, we need to edit /etc/apache2/apache2.conf and add the following line to it.
$ sudo nano /etc/apache2/apache2.conf
Include /etc/apache2/conf.d/phppgadmin
When you have done this, restart apache:
$ sudo service apache2 reload
Now, that we have configured Apache, we need to correct the permission. We need to edit the phpPgAdmin file as shown below:
$ sudo nano /etc/apache2/conf.d/phppgadmin
Here, we need to comment out the following line:
allow from 127.0.0.0/255.0.0.0 ::1/128
Then we need to uncomment the line below it,
allow from all
The file should look like this:
order deny,allow
deny from all
# allow from 127.0.0.0/255.0.0.0 ::1/128
allow from all
Save it out and restart apache again, now try to access phpPgAdmin again.
You should be able to see the site now.
This article covers methods to tackle "403 forbidden" error messages in phpPgAdmin. Basically, the "Forbidden" error happens while accessing phpPgAdmin when permissions in the phpPgAdmin configuration file are not intact.
To resolve 403 forbidden error, In the Apache configuration, simply replace:
<Directory /usr/share/phppgadmin>
DirectoryIndex index.php
Order deny,allow
Allow from all
</Directory>
With:
<Directory /usr/share/phppgadmin>
Require all granted
</Directory>