Have trouble installing phpmyadmin on PHP7 Apache/2.4.7 (Ubuntu)
You're trying to modernize your stack by moving from PHP 5 to PHP 7, specifically using the packages available in the ondrej PPA on Ubuntu. You successfully installed the core components: php7.0-cli, libapache2-mod-php7.0, and php7.0-fpm. However, when you attempt to install or access phpMyAdmin, you encounter a classic compatibility wall. The error message clearly indicates that the package manager is looking for dependencies labeled with version 5 (e.g., php-common (= 5)) while your system only contains PHP 7 packages.
This isn't a configuration error in Apache or a missing .htaccess file; it is a fundamental mismatch between the installed PHP version and the meta-package you are trying to install. The phpmyadmin package on Ubuntu defaults to installing against whichever version of PHP is currently active as the "default" or most recently installed, but often it attempts to pull in legacy dependencies if it detects an older environment or if the versioning scheme hasn't fully aligned with the PPA's output yet.
To resolve this without manually hunting down every single dependency file, you need to force the package manager to install phpMyAdmin specifically for PHP 7. The standard apt-get install phpmyadmin command is too generic; it doesn't know which PHP version you want to pair with the web interface.
Run the following command instead:
sudo apt-get install phpmyadmin php-mysql
If that still fails or if the package manager complains about missing dependencies, try specifying the exact major version in the dependency chain. Since you are on Ubuntu and using the Ondrej PPA, you might find a specific build for PHP 7:
sudo apt-get install phpmyadmin php-mysql=5.6.*
Wait, that won't work if your system is strictly PHP 7. The correct approach when dealing with these PPA packages is to ensure the phpmyadmin package version matches the architecture and versioning of your PHP installation. In many cases on Ubuntu, simply installing the generic phpmyadmin works fine if you have cleaned up old references.
Here is the most reliable sequence of actions:
Remove any existing phpMyAdmin configurations: Sometimes a previous installation leaves behind a config file that tells Apache to look for PHP 5 modules. Run:
sudo rm /etc/phpmyadmin/config.user.inc.php sudo apt-get remove --purge phpmyadminInstall the specific dependency: Ensure you have the correct MySQL driver for PHP 7 installed. Since you already ran
apt-get install php7.0-mysql, verify that the module is actually enabled in Apache. Check if the file/etc/apache2/mods-available/php7.0_mysql.loadexists. If not, create a symlink:sudo ln -s /etc/php/7.0/mods-available/mysqlnd.ini /etc/php/7.0/mods-available/ sudo a2enmod php7.0-mysqlReinstall with explicit versioning: If the standard install still fails, try installing the
phpmyadminpackage that explicitly targets PHP 7. On some versions of Ubuntu, this might require:sudo apt-get install phpmyadmin=5.*However, if you are on a very recent setup where
phpmyadminis already in version 5.x (which supports PHP 7+), the issue might be that your system thinks you still have PHP 5.
The core issue is often that apt-get sees php-common or similar libraries as version 5 because they were installed by default before you added the PPA, or because the package database hasn't been refreshed to reflect the new versions in the PPA correctly.
Run:
sudo apt-get update
sudo apt-get install phpmyadmin php-mysql=5.6.*
Actually, the cleanest fix is usually to force the installation of the PHP 7 version of the client tools alongside the web interface:
sudo apt-get install phpmyadmin php-common=1:* libapache2-mod-php7.0 php7.0-mysql
After installation, you must configure Apache to serve the new instance. Edit /etc/phpmyadmin/apache.conf and ensure it contains:
<FilesMatch "\.(html|php)$">
SetHandler application/x-httpd-php
</FilesMatch>
Then restart Apache:
sudo systemctl restart apache2
When you access http://your-server/phpmyadmin, you should now see the login screen. If you still get a 403 Forbidden, check your virtual host configuration to ensure PHP is enabled for that directory and that file permissions on /usr/share/phpmyadmin are set to 755.
One final note: If you are deploying Laravel or other modern frameworks alongside phpMyAdmin, remember that phpMyAdmin is a legacy tool. While useful for quick database introspection, production-grade applications often prefer CLI tools like mysql or GUIs like Adminer or directly managed cloud consoles. But for now, getting this specific stack working requires respecting version constraints in your package manager rather than fighting them.