• WordPress
  • cPanel
  • Softaculous
  • KVM Virtualization
  • Vmware Virtualization
  • Proxmox
Saturday, June 14, 2025
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
No Result
View All Result
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux

How to Install phpMyAdmin on Ubuntu Server

in Linux OS, Ubuntu
How to Install phpMyAdmin on Ubuntu Server

Managing databases can be a daunting task, especially when working on a server without a graphical user interface. That’s where phpMyAdmin comes in! This powerful web-based tool simplifies the process of managing your MySQL and MariaDB databases, all from the comfort of your web browser. In this article, we’ll walk you through the steps on How to Install phpMyAdmin on Ubuntu Server.

How to Install phpMyAdmin on Ubuntu Server

Prerequisites

Before we begin, make sure you have the following:

  1. An Ubuntu server with a non-root user having sudo privileges.
  2. LAMP (Linux, Apache, MySQL, PHP) stack installed on your server. You can follow our guide on how to set up a web server on Ubuntu using Apache if you haven’t already.

Update Your System

First, update your package index and upgrade the system:

sudo apt update && sudo apt upgrade

Install phpMyAdmin on Ubuntu Server

Once your system is up to date, install phpMyAdmin with the following command:

sudo apt install phpmyadmin

During the installation process, you’ll be prompted to choose the web server you’re using. Select Apache by pressing the spacebar and then hit Enter.

Next, the installer will ask if you want to configure the database for phpMyAdmin with dbconfig-common. Choose “Yes” and press Enter.

Finally, provide a password for the phpMyAdmin application. You’ll be asked to confirm the password. This is not the same as your MySQL or MariaDB password, but a separate one for phpMyAdmin.

Configure Apache

To access phpMyAdmin via your web browser, you need to configure Apache to serve phpMyAdmin. Create a new configuration file:

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

Paste the following content into the file:

Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
    Options SymLinksIfOwnerMatch
    DirectoryIndex index.php

    <IfModule mod_php5.c>
        php_admin_value upload_max_filesize 128M
        php_admin_value post_max_size 128M
        php_admin_value max_execution_time 360
        php_admin_value max_input_time 360
    </IfModule>

    <IfModule mod_php.c>
        php_admin_value upload_max_filesize 128M
        php_admin_value post_max_size 128M
        php_admin_value max_execution_time 360
        php_admin_value max_input_time 360
    </IfModule>
</Directory>

<Directory /usr/share/phpmyadmin/setup>
    <IfModule mod_authz_core.c>
        <RequireAny>
            Require ip 127.0.0.1
            Require ip ::1
        </RequireAny>
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order Deny,Allow
        Deny from All
        Allow from 127.0.0.1
        Allow from ::1
    </IfModule>
</Directory>

Save and exit the file.

Enable the configuration and restart Apache:

sudo a2enconf phpmyadmin
sudo systemctl restart apache2

Secure phpMyAdmin

By default, phpMyAdmin can be accessed by anyone with your server’s IP address or domain name. To enhance security, we recommend restricting access to specific IP addresses or networks.

Edit the Apache configuration file:

  1. Open the Apache configuration file for editing:
sudo nano /etc/apache2/sites-available/000-default.conf
  1. Add the following lines inside the <VirtualHost> section to configure the phpMyAdmin alias:
Alias /phpmyadmin "/usr/share/phpmyadmin"
<Directory "/usr/share/phpmyadmin">
    Options FollowSymLinks
    DirectoryIndex index.php
    AllowOverride All
    Require all granted
</Directory>
  1. Save and exit the file by pressing Ctrl + X, then Y, and finally Enter.
  2. Enable the necessary PHP modules and restart Apache:
sudo phpenmod mbstring
sudo systemctl restart apache2

Configure phpMyAdmin

  1. Set up the phpMyAdmin configuration storage:
sudo mysql < /usr/share/phpmyadmin/sql/create_tables.sql
  1. Create a new MySQL user and grant privileges:
sudo mysql -u root -p

mysql> CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'your_password_here';
mysql> GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'phpmyadmin'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
  1. Edit the phpMyAdmin configuration file:
sudo nano /etc/phpmyadmin/config.inc.php
  1. Add the following lines at the end of the file, replacing your_password_here with the password you created for the ‘phpmyadmin’ user:
$cfg['Servers'][$i]['controluser'] = 'phpmyadmin';
$cfg['Servers'][$i]['controlpass'] = 'your_password_here';
  1. Save and exit the file.
  1. Install htpasswd to create a password file:
sudo apt install apache2-utils
  1. Create a password file and add a user:
sudo htpasswd -c /etc/phpmyadmin/.htpasswd your_username_here
  1. Enter a password for the user when prompted.
  2. Edit the Apache configuration file:
sudo nano /etc/apache2/sites-available/000-default.conf
  1. Add the following lines inside the <Directory "/usr/share/phpmyadmin"> section:
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user
sudo systemctl restart apache2

Access phpMyAdmin

  1. Open your web browser and navigate to http://your_server_ip/phpmyadmin.
  2. Log in using the username and password you created for the .htpasswd file.
  3. You should now see the phpMyAdmin interface, where you can manage your MySQL databases.

Conclusion

Congratulations! You have successfully installed and configured phpMyAdmin on your Ubuntu server. You can now manage your MySQL databases through the phpMyAdmin web interface. Remember to keep phpMyAdmin up-to-date for security reasons and always back up your data before making significant changes.

ShareTweet
Previous Post

How to Install phpMyAdmin on AlmaLinux

Next Post

How to Install phpMyAdmin on Fedora: A Step-by-Step Guide

Related Posts

How to Install Tomcat on Rocky Linux

How to Install Apache Tomcat on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Golden Host VPS
  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.

  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.