Reputation: 99
when i try to access the phpmyadmin page i receive the following error:
<?php
declare(strict_types=1);
use PhpMyAdmin\Routing;
if (! defined('ROOT_PATH')) {
// phpcs:disable PSR1.Files.SideEffects
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
// phpcs:enable
}
global $route, $containerBuilder;
require_once ROOT_PATH . 'libraries/common.inc.php';
$dispatcher = Routing::getDispatcher();
Routing::callControllerForRoute($route, $dispatcher, $containerBuilder);
couldn't find a solution to this on any pixel of the internet, any help would be appreciated.
Upvotes: 9
Views: 38373
Reputation: 470
For Ubuntu 24.04 or newer version use this command:
sudo apt install libapache2-mod-php8.3
sudo systemctl restart apache2
I solved and I hope it will help others
Upvotes: 0
Reputation: 31
This mean php intepreter is not installed. To solve this, do :
sudo apt-get install php
Upvotes: 1
Reputation: 11
It should work. credit gose to MoonE.
# install the required modules
sudo apt install php libapache2-mod-php
# enable php in apache2, type the name of the module from the list of available modules
sudo a2enmod
# reload apache for the changed config to take effect.
sudo systemctl reload apache2
Upvotes: 1
Reputation: 21
$ sudo apt install apache2 wget unzip
$ sudo apt install php php-zip php-json php-mbstring php-mysql
Once the installation is finished, enable and start the Apache web server.
$ sudo systemctl enable apache2
$ sudo systemctl start apache2
$ wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip
$ unzip phpMyAdmin-5.2.0-all-languages.zip
$ sudo mv phpMyAdmin-5.2.0-all-languages /usr/share/phpmyadmin
Next, create tmp directory and set the proper permissions. This is a necessary step to make it work properly.
$ sudo mkdir /usr/share/phpmyadmin/tmp
$ sudo chown -R www-data:www-data /usr/share/phpmyadmin
$ sudo chmod 777 /usr/share/phpmyadmin/tmp
Now, you need to configure the web server to serve phpMyAdmin on the network. Create an Apache configuration file for phpMyAdmin and edit it in a text editor:
$ sudo nano /etc/apache2/conf-available/phpmyadmin.conf
Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
<RequireAny>
Require all granted
</RequireAny>
</IfModule>
</Directory>
<Directory /usr/share/phpmyadmin/setup/>
<IfModule mod_authz_core.c>
<RequireAny>
Require all granted
</RequireAny>
</IfModule>
</Directory>
After making all the changes, make sure to start the Apache service to reload all settings.
$ sudo a2enconf phpmyadmin
$ sudo systemctl restart apache2
The systems with enabled firewalls need to allow HTTP service from the firewall. Run the below commands to open a port for the webserver in the firewall.
$ sudo firewall-cmd --permanent --add-service=http
$ sudo firewall-cmd --reload
If you don't have firewall installed, run:
$ sudo apt-get firewall
Upvotes: 2
Reputation: 511
I was facing the same problem but solved it through the below command
sudo apt install libapache2-mod-php8.1
sudo systemctl restart apache2
Upvotes: 39
Reputation: 2870
If you see php code in your browser it means that the PHP interpreter wasn't used. This means the problem is not with PhpMyAdmin but with your php installation. I googled quickly this but you (or others) may find better tutorials.
When new to apache php and mysql/mariadb I recommend installing wampserver or mamp. They do take all the hard configuration work from you.
Upvotes: 0
Reputation: 31
You can try to remove my php with apt-get --purge remove php-common
and download it back with apt-get install php7.4 php7.4-mysqli php7.4-xml
followed by systemctl reload apache2
to restart apache.
If the above does not work, I recommend you to re-download phpmyadmin
Upvotes: 3