Can't access phpmyadmin after installation

Can't access phpmyadmin after installation

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Can't Access phpMyAdmin After Installation? The Real Problem Is Not Apache

When you follow a standard installation guide like the one from DigitalOcean, the steps often look straightforward: install the package, include the configuration file, and restart the web server. However, if your browser immediately starts downloading a file instead of displaying the login page, the issue isn't necessarily with apache2 or phpmyadmin itself. It is almost certainly a content security policy (CSP) mismatch between Apache's default headers and what phpMyAdmin expects to run.

By default, modern Apache configurations include a header that tells browsers which sources are allowed to load resources like JavaScript and CSS files. This is a great security feature, but it breaks out-of-the-box installations of many web applications, including phpMyAdmin. When you see the "download" prompt, your browser is rejecting the main index.php file because its MIME type or content security policy doesn't match what the server is sending.

To fix this, you need to inspect your current Apache headers and adjust the configuration to allow the specific resources phpMyAdmin requires. You can do this by editing the main Apache configuration file or by creating a .htaccess file in your phpMyAdmin directory.

First, let's look at how to identify the exact header causing the issue. Run the following command on your server:

curl -I http://your-server-ip/phpmyadmin

Look for the Content-Security-Policy or X-Content-Type-Options headers in the response. If you see a restrictive policy, you'll need to override it. The most reliable method is to add a specific include line in your main Apache configuration file (/etc/apache2/apache2.conf) after including the phpMyAdmin config:

Include /etc/phpmyadmin/apache.conf
<Directory "/usr/share/phpmyadmin">
    Options +Indexes FollowSymLinks MultiViews
    AllowOverride All
    <FilesMatch "^\.ht">
        AllowOverride All
    </FilesMatch>
</Directory>

After making these changes, restart Apache to apply the new rules:

service apache2 restart

Alternatively, if you prefer not to touch the global configuration, you can drop a file named .htaccess into your phpMyAdmin installation directory (usually /usr/share/phpmyadmin). Add the following line to explicitly disable the restrictive header for that specific directory:

Header unset Content-Security-Policy

This approach isolates the fix to the application without affecting other parts of your site. Be cautious, however; disabling security headers globally can expose your entire server to potential attacks if you aren't careful about what else you allow. Always prefer local overrides when possible.

Another common pitfall is forgetting that phpMyAdmin requires a specific database user to function correctly. If the installation script (sudo apt-get install phpmyadmin) didn't prompt you for a root password or created the necessary pma user, the application might redirect you to a download instead of logging in, thinking it cannot authenticate. Ensure you run the following command to verify the setup:

mysql -u pma -ppma -h localhost phpmyadmin

If you are using a more recent version of Ubuntu or Debian (18.04+), the package manager might have changed how permissions are handled. In those cases, ensure that the www-data user owns the necessary directories:

chown -R www-data:www-data /usr/share/phpmyadmin
chmod -R 755 /usr/share/phpmyadmin

If you are deploying a Laravel application alongside phpMyAdmin, remember to keep them on separate ports or use virtual hosts to avoid port conflicts. While laravelcompany.com offers extensive documentation on securing your Laravel stack, they do not cover legacy tools like phpMyAdmin in depth. For that, sticking to the official Apache and MariaDB/MySQL documentation is safer.

Finally, if you are using a reverse proxy like Nginx in front of Apache, ensure that the proxy headers are correctly forwarded so that phpMyAdmin sees the real client IP address. Without this, some security features within phpMyAdmin might trigger false positives, leading to unexpected redirects or downloads.

Our network