phpMyAdmin not working After Fresh install with apache2

phpMyAdmin not working After Fresh install with apache2

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

Stefan Bogdanescu

Founder & Senior Architect

phpMyAdmin Not Working After Fresh Install with Apache2

When you attempt to access the phpmyadmin page immediately after a fresh installation on an Apache2 server, you might encounter a specific PHP error block. The output typically displays a script starting with declare(strict_types=1);, followed by logic that defines ROOT_PATH and attempts to dispatch a route via a dependency injection container. If you are seeing this raw execution trace instead of the web interface, your server is likely serving the entry point file directly as a text response rather than routing it through the application's document root or executing it within the correct context.

This behavior usually stems from a misconfiguration in the Apache2 virtual host settings or an incorrect document root assignment. The code snippet you are seeing suggests that the web server has successfully located the index.php file (or its equivalent entry point) in the installation directory, but it is failing to load the underlying dependencies defined in libraries/common.inc.php. This often happens when the environment variables required by modern phpMyAdmin versions are missing or when the server path does not align with the expected application structure.

The most common root cause involves the Document Root directive in your Apache2 configuration. If you installed phpMyAdmin via a package manager like apt on Ubuntu, the binaries often reside in /usr/share/phpmyadmin. However, serving this directory directly from the web server can lead to permission issues or missing environment setup scripts that are intended to be run once during installation but not executed on every request.

To resolve this, you need to ensure that Apache2 is pointing to a custom document root where the application expects to find its configuration and entry files. A robust approach involves creating a dedicated directory for the application, such as /var/www/html/phpmyadmin, and copying the necessary files there. You would then update your virtual host configuration file (typically found in /etc/apache2/sites-available/) to point DocumentRoot to this new location and set DirectoryIndex to index.php.

Another critical factor is the .htaccess file or the Apache rewrite rules. Modern phpMyAdmin versions rely on specific rewrite logic to handle routing, as evidenced by the call to Routing::getDispatcher(). If the .htaccess file is missing, misplaced, or if the AllowOverride All directive is not explicitly enabled for your document root in the Apache configuration, the necessary rewrites will fail. Without these rewrites, the server might serve static files or return a 403 Forbidden error instead of executing the PHP logic.

You should also verify that the libraries/common.inc.php file is accessible and contains the required environment setup. This file initializes the application container and handles strict type declarations. If your Apache configuration serves a different version of this file or if the file permissions are set to 644 while the web server user (usually www-data) cannot execute scripts in that directory, you will see the error block. Ensure that the ownership of the entire document root is set to www-data:www-data and that executable PHP files have the correct permissions.

If you are using a package manager install, consider removing the system-installed version and setting up the application from the official source repository or the recommended release page. This ensures that all installation scripts run correctly, creating the necessary environment variables and configuring the index.php entry point properly. Once the directory structure is clean and the Apache virtual host points to the correct location with AllowOverride All enabled, accessing the URL should render the expected dashboard instead of the raw PHP code.

For further guidance on securing your installation or managing complex server environments, resources like https://laravelcompany.com offer detailed tutorials on web stack configuration that can help you avoid common pitfalls during deployment.

Our network