skip to Main Content

when i try to access the phpmyadmin page i receive the following error:

<?php
declare(strict_types=1);
use PhpMyAdminRouting;
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.

5

Answers


  1. 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

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. I was facing the same problem but solved it through the below command

    sudo apt install libapache2-mod-php8.1
    
    sudo systemctl restart apache2
    
    Login or Signup to reply.
  4. Try this.

    sudo a2enmod php8.1
    sudo systemctl restart apache2
    
    Login or Signup to reply.
  5. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search