Introduction
When setting up a local development environment, many developers choose the Windows-Apache-MySQL-PHP (WAMP) stack. This tutorial will guide you through troubleshooting and resolving a common issue encountered when accessing phpMyAdmin after installing WAMP: the "Forbidden You don’t have permission to access /phpmyadmin/ on this server" error.
Understanding the Problem
This error occurs due to improper configuration in Apache’s directory settings, which restricts access to certain directories based on IP addresses or hostnames. The issue often arises because Apache is not configured to allow access from localhost when trying to reach phpMyAdmin through either localhost
or 127.0.0.1
.
Step-by-Step Solution
1. Check WAMP Server Status
Ensure your WAMP server is online:
- Click the WAMP icon in the system tray.
- Select "Put Online" from the menu. If needed, restart Apache.
If these steps don’t resolve the issue, proceed to modify configuration files.
2. Modify phpmyadmin.conf
Locate and edit the phpmyadmin.conf
file within your WAMP installation directory:
- Typically found at:
c:\wamp\alias\phpmyadmin.conf
or a similar path based on version.
Make sure your configuration resembles one of these options, depending on your Apache version.
For Apache 2.2 and older versions:
<Directory "c:/wamp/apps/phpmyadmin3.x.x/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1
</Directory>
For Apache 2.4 and newer versions:
<Directory "c:/wamp/apps/phpmyadmin3.x.x/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
Key Changes Explained:
-
Apache 2.2: Use
Order Deny,Allow
followed byDeny from all
, then addAllow from 127.0.0.1 ::1
. This configuration allows access only from the localhost IP addresses (IPv4 and IPv6). -
Apache 2.4+: Replace
Allow
directives withRequire all granted
. It simplifies permission management using the new syntax.
3. Restart Apache
After editing the configuration files, restart your Apache server to apply changes:
- Click the WAMP icon in the system tray.
- Select "Restart All Services."
4. Accessing phpMyAdmin
Try accessing phpMyAdmin with http://localhost/phpmyadmin/
or http://127.0.0.1/phpmyadmin/
. Both should work now, but if you encounter issues with one, try the other.
Additional Tips
-
Security Consideration: Always restrict access to localhost in production environments by avoiding
Allow from all
. -
IPv6 Compatibility: If your system prefers IPv6 (
::1
) over IPv4 (127.0.0.1
), ensure both are included in your allow directives. -
Troubleshooting: If issues persist, verify that the directory paths and version numbers match your WAMP installation.
Conclusion
Access control configurations can cause frustrating permission errors when setting up phpMyAdmin on a WAMP stack. By following this guide to adjust Apache’s configuration files based on the server version, you should be able to resolve these common access issues effectively. If problems persist, double-check file paths and ensure your changes are correctly applied by restarting the Apache service.