Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Databases»How To Install phpMyAdmin on Ubuntu 20.04

    How To Install phpMyAdmin on Ubuntu 20.04

    By RahulSeptember 4, 20213 Mins Read

    phpMyadmin is the best web based client for accessing MySQL servers. It is freely available to download and install on your server. You can host this on any server running with Apache and PHP.

    Advertisement

    The phpMyAdmin is written on PHP. The current phpMyAdmin version is compatible with PHP 7.1 and newer and MySQL 5.5 or MariaDB 5.5 or newer.

    This tutorial will help you to install and configure phpMyAdmin on Ubuntu 20.04 Linux system.

    Step 1 – Install Apache and PHP

    We are assuming you already have installed the MySQL server on Ubuntu system. So just install the other required packages to run and access phpMyAdmin.

    sudo apt install apache2 wget unzip 
    sudo apt install php php-zip php-json php-mbstring php-mysql 
    

    Once the installation finished, enable and start Apache web server.

    sudo systemctl enable apache2 
    sudo systemctl start apache2 
    

    Step 2 – Install phpMyAdmin on Ubuntu 20.04

    phpMyAdmin is also available under the default packages repository but mostly they have older version. In this tutorial, we will download latest phpMyAdmin and configure on our system.

    Your system is ready for the phpMyAdmin installation. Download the latest phpMyAdmin archive from the official download page, or use the below commands to download phpMyAdmin 5.1.1 on your system.

    After downloading extract archive and move to the proper location.

    wget https://files.phpmyadmin.net/phpMyAdmin/5.1.1/phpMyAdmin-5.1.1-all-languages.zip 
    unzip phpMyAdmin-5.1.1-all-languages.zip 
    mv phpMyAdmin-5.1.1-all-languages /usr/share/phpmyadmin 
    

    Next, create tmp directory and set the proper permissions.

    mkdir /usr/share/phpmyadmin/tmp 
    chown -R www-data:www-data /usr/share/phpmyadmin 
    chmod 777 /usr/share/phpmyadmin/tmp 
    

    Step 3 – Configure phpMyAdmin

    Now, you need to configure web server to serve phpMyAdmin on network. Create Apache configuration file for phpMyAdmin and edit in text editor:

    sudo vi /etc/apache/conf-available/phpmyadmin.conf 
    

    add the below content to file.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    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>

    Save your file. Press ESC key to switch to command more. Then type : (colon) and type w after the colon and hit Enter.

    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 
    

    Step 5 – Access phpMyAdmin

    All done. You have finished the setup with the phpMyAdmin on Ubuntu Linux system. Now access phpMyAdmin with the server IP address or domain name.

    http://your-server-ip-domain/phpmyadmin
    

    Replace your-server-ip-domain with the localhost (for the local machines), or system IP address for remote machines. I have updated our DNS and pointed dbhost.tecadmin.net to the server’s IP address.

    how to install phpmyadmin on ubuntu 20.04

    Log in with the username and password used to access MySQL on the command line.

    setup phpmyadmin ubuntu 20.04

    Conclusion

    You have successfully configured phpMyAdmin on Ubuntu system. Let’s disable root user login for the phpMyAdmin for security purposes.

    mariadb MySQL PHP phpmyadmin PMA
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Securing MySQL Database with Limited User Permissions

    PHP Arrays: A Beginner’s Guide

    Running Laravel Queue Worker as a Systemd Service

    View 17 Comments

    17 Comments

    1. Naga on September 15, 2022 8:49 am

      Hello Rahul,

      Thank you fro quick reply to all above questions.

      I’m not able to save the file vi /etc/apache2/conf-available/phpmyadmin.conf. It showing as “phpmyadmin.conf” E166: Can’t open linked file for writing

      Can you help me?

      Reply
    2. Rodrigo on August 4, 2022 5:39 am

      Hello,

      This is not working for me, IDK what could be the issue. I’m running ubuntu 20.04 on a local machine with PHP 8.1 Everything works OK and I don’t get any errors, but when I go to localhost/phpmyadmin I just see the content of the index.php file

      <?php

      declare(strict_types=1);

      use PhpMyAdmin\Common;
      use PhpMyAdmin\Routing;

      if (! defined('ROOT_PATH')) {
      // phpcs:disable PSR1.Files.SideEffects
      define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
      // phpcs:enable
      }

      if (PHP_VERSION_ID < 70205) {
      die('PHP 7.2.5+ is required.Currently installed version is: ‘ . PHP_VERSION . ”);
      }

      // phpcs:disable PSR1.Files.SideEffects
      define(‘PHPMYADMIN’, true);
      // phpcs:enable

      require_once ROOT_PATH . ‘libraries/constants.php’;

      /**
      * Activate autoloader
      */
      if (! @is_readable(AUTOLOAD_FILE)) {
      die(
      ‘File ‘ . AUTOLOAD_FILE . ‘ missing or not readable.’
      . ‘Most likely you did not run Composer to ‘
      . ‘‘
      . ‘install library files
      .’
      );
      }

      require AUTOLOAD_FILE;

      global $route, $containerBuilder, $request;

      Common::run();

      $dispatcher = Routing::getDispatcher();
      Routing::callControllerForRoute($request, $route, $dispatcher, $containerBuilder);

      Reply
      • Rahul on August 4, 2022 9:31 am

        Make sure you have installed the “libapache2-mod-php8.1” package on your system.

        Reply
    3. Raphael on February 25, 2022 4:57 pm

      I got this error when i ran a2enconf phpmyadmin
      ERROR: Conf phpmyadmin does not exist!

      Reply
      • martin on July 20, 2022 8:38 am

        Use apache2 instead:

        sudo nano /etc/apache2/conf-available/phpmyadmin.conf

        Reply
    4. younes on November 27, 2021 11:43 pm

      Hi Rahul,
      Fastest applied and successful first try tutorial I have ever done.
      very good work.

      Reply
    5. Dawid Motyka on September 28, 2021 12:00 pm

      I got 403 forbidden error after following these steps help

      Reply
    6. SACHIN GARG on September 10, 2021 10:50 am

      Great tutorial.

      Reply
    7. redet on September 3, 2021 3:03 pm

      just do sudo apt-get install phpmyadmin

      Reply
      • Rahul on September 4, 2021 6:23 pm

        Yes, but generally the repositories contains older package versions. That’s why I prefer to install phpmyadmin from source code.

        Reply
      • Arvind Kumar on October 12, 2021 2:54 pm

        I tried this first but it did not work. It did not create phpmyadmin.conf for some reason.

        This tutorial worked like a charm!

        Reply
    8. asd on August 24, 2020 7:47 pm

      how i save

      Reply
      • asd on August 24, 2020 7:48 pm

        step 3 PLS HELP ME XD

        Reply
        • Rahul on August 25, 2020 3:25 am

          To save file, Press ESC key to switch to command more. Then type : (colon) and type w after the colon and hit Enter.

          Reply
    9. Jeff Ro on August 10, 2020 3:36 pm

      Thanks, that was a big help Rahul. Just a suggestion, I think

      `vi /etc/apache/conf-enabled/phpmyadmin.conf`

      should be

      `vi /etc/apache2/conf-available/phpmyadmin.conf`

      Reply
      • Rahul on August 11, 2020 1:59 am

        Thanks Jeff, Updated tutorial.

        Reply
        • Arvind Kumar on October 12, 2021 2:55 pm

          It still shows sudo vi /etc/apache/conf-available/phpmyadmin.conf. Probably need to clear cache or something 🙂

          Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.