Forbidden :You don't have permission to access /phpmyadmin on this server
When you attempt to load http://yourserver/phpmyadmin and immediately hit a "Forbidden" error, your web server is explicitly telling you that it has blocked the request before PHP ever gets a chance to run. This isn't a configuration error within phpMyAdmin itself; it is an access control decision made by Apache.
The specific error message You don't have permission to access /phpmyadmin indicates that the URL path matches, but the HTTP 403 status code confirms that the mod_authz_core module (or its equivalent in older versions) has denied the request. Looking at the configuration provided, the root cause is immediately apparent: the <Directory> block for /usr/share/phpMyAdmin/ restricts access strictly to local IP addresses (127.0.0.1 and ::1).
If you are trying to access phpMyAdmin from a browser on your machine using an IP address other than the loopback interface, or if you are accessing it from a different machine entirely, the request is being dropped at the web server level. The configuration snippet uses <RequireAny> with specific IP requirements, which means "Allow ONLY these IPs." Anything outside 127.0.0.1 results in a 403 Forbidden.
Diagnosing the Alias Configuration
Before diving into permissions, verify that Apache knows where to find the application. The configuration shows two Alias directives:
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
These are redundant but harmless. They ensure that both /phpMyAdmin and /phpmyadmin resolve to the same physical directory. If your Apache error log shows a 403 immediately upon trying to access the path, the issue is almost certainly not the alias but the <Directory> directive following it.
Resolving Localhost Access Issues
If your goal is to access phpMyAdmin only from your own machine via the loopback interface, you must ensure that localhost resolves correctly or use the specific IP. However, a common pitfall occurs when accessing via 127.0.0.1 while the config expects ::1, or vice versa, depending on how your browser resolves the hostname.
To fix access from your local machine if you are currently blocked:
- Open your Apache configuration file (usually
/etc/httpd/conf.d/phpMyAdmin.confor similar). - Locate the
<Directory /usr/share/phpMyAdmin/>block. - Modify the
Require ipdirectives to match your actual connection source. If you are accessing via127.0.0.1, ensure that line is present and uncommented.
<IfModule mod_authz_core.c>
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
Enabling Remote Access (With Caution)
The source material warns that allowing access to anyone other than localhost is dangerous unless properly secured by SSL. If you intend to expose this application to a wider network, you must change the authorization logic.
You cannot simply remove the Require ip lines if you want to keep strict control; instead, you should use IP ranges or subnet matching. A common approach for remote access is:
<IfModule mod_authz_core.c>
<RequireAny>
Require ip 127.0.0.1
# Add specific allowed IPs here, e.g.,
# Require ip 192.168.1.0/24
</RequireAny>
</IfModule>
Alternatively, to allow all connections (which is generally discouraged without strong authentication and SSL), you would comment out the IP restrictions entirely:
<Directory /usr/share/phpMyAdmin/>
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
Crucial Security Note: If you proceed with Require all granted, you are bypassing the security model of the default configuration. You must ensure that:
- SSL/TLS is enforced (redirecting HTTP to HTTPS).
- Strong passwords are set for the root user in the database.
- The application directory permissions are restricted so that only the Apache user can execute scripts, preventing arbitrary file uploads via PHP.
Verifying Permissions and SELinux
Even with correct Apache directives, CentOS environments often run SELinux in enforcing mode. If SELinux is active, it may block Apache from reading files in /usr/share/phpMyAdmin regardless of what the httpd.conf says.
To troubleshoot this, check the audit log:
ausearch -m avc -ts recent | grep phpmyadmin
If you see denials related to httpd trying to access files in that directory, you will need to adjust the SELinux context or file context using semanage.
Finally, ensure the physical filesystem permissions are correct. The Apache user (usually apache or www-data) must have read and execute permissions on the PHP files:
chown -R apache:apache /usr/share/phpMyAdmin
chmod -R 750 /usr/share/phpMyAdmin
If you are building a modern stack where phpMyAdmin is managed by Docker or Nginx, these Apache-specific directives will not apply. However, in the context of standard CentOS/RHEL installations with httpd, correcting the <Directory> access rules is the definitive fix for the "Forbidden" error.
