phpMyAdmin not working After Fresh install with apache2
Asked Answered
F

9

9

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.

Fernando answered 15/10, 2021 at 15:41 Comment(7)
Your post does not include the error that you mention. Please edit your question and include the error messageGoldfinch
The error is a blank page with the code i wrote, there isn't much i can addFernando
It seems like your system doesn't have a working PHP installation. Which operating system do you have and how have you installed Apache? Did you install and configure any PHP interpreter?Redundancy
Hi @IsaacBennetch yes i have apache installed, but i don't remember about "PHP Interpreter" i'll research about it.Fernando
How have you installed Apache? Do you use a package manager, did you compile it from source, etc?Redundancy
Installed using: apt-get install apache2 libapache2-mod-perl2Fernando
You should install a PHP interpreter with something like apt-get install libapache2-mod-php. There are some other library pacakges like php-gd orphp-mbstring that you might need, but they might be pulled in automatically when you install libapache2-mod-php, so give that a try and let me know what happens next.Redundancy
H
37

I was facing the same problem but solved it through the below command

sudo apt install libapache2-mod-php8.1

sudo systemctl restart apache2
Horizon answered 23/9, 2022 at 5:47 Comment(1)
saved me thanksLeflore
H
3

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

Halfbaked answered 6/1, 2022 at 21:2 Comment(2)
apt-get install php8.1 php8.1-mysql php8.1-xml for php 8.1 (I also needed to reinstall phpmyadmin, after that it worked like a charm...)Duplex
I gotta admit it! its a very good answer! when phpmyadmin reacts like that its definetely because it is missing php-*-mysql and xml in it. good job guysMorphology
D
2

Step 1 – Install Apache and PHP

$ 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

Step 2 – Install phpMyAdmin on Ubuntu 22.04

$ 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 

Step 3 – Configure phpMyAdmin

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

Add the below content to the file.###

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

Step 4 – Adjusting FirewallD

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
Dorsett answered 26/10, 2022 at 12:39 Comment(0)
R
1

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
Ridenour answered 5/11, 2023 at 17:29 Comment(0)
S
1

This mean php intepreter is not installed. To solve this, do :

sudo apt-get install php
Sestet answered 10/11, 2023 at 12:31 Comment(0)
N
0

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.

Norvell answered 9/1, 2022 at 10:35 Comment(1)
I had exactly the same issue, but PHP was installed and running. Restarting Apache fixed the problem.Covarrubias
C
0

Try this.

sudo a2enmod php8.1
sudo systemctl restart apache2
Callisto answered 21/10, 2022 at 8:49 Comment(0)
C
0

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

Constanceconstancia answered 19/8 at 10:10 Comment(0)
B
-2
sudo a2enmod php8.2
sudo systemctl restart apache2
Broeker answered 28/5, 2023 at 22:49 Comment(2)
Your answer could be improved by adding more information on how the proposed solution solves the problem and how it helps the OP.Riorsson
Hello, please don't just submit code in your answer(s), add some details as to why you think this is the optimal solution.Trustless

© 2022 - 2024 — McMap. All rights reserved.