Skip to content
Follow
Ubuntu Linux

How to install phpMyAdmin with Apache on Ubuntu 24.04

Richard
Written by
Richard
Jun 11, 2024 Updated Jul 13, 2026 7 min read
phpMyAdmin featured image
phpMyAdmin featured image

phpMyAdmin on Ubuntu 24.04 gives you a friendly, browser-based tool to manage your MySQL databases.

phpMyAdmin is a popular free web app that helps you control MySQL and MariaDB databases. It lets you do things like build tables, write database commands, and manage users all from your web browser.

This is a big help for anyone who wants to work with their databases visually, instead of only using complex command-line text.

Setting up phpMyAdmin with the Apache web server on Ubuntu 24.04 makes managing your databases much easier and more accessible.

⚡ Quick Answer

Install Apache and MariaDB using apt. Then, install phpMyAdmin via apt and configure Apache by running `sudo dpkg-reconfigure phpmyadmin`.

Install Apache HTTP server on Ubuntu

To install phpMyAdmin on Ubuntu, you first need to install the Apache HTTP server. Open your Ubuntu terminal and run the commands ‘sudo apt update’ followed by ‘sudo apt install apache2’. This command installs the web server software that phpMyAdmin will use to be accessible through your web browser.

To do that, open the Ubuntu terminal and run the commands below to install the Apache web server.

🐧Bash / Shell
sudo apt update
sudo apt install apache2

Once Apache is installed, the commands below can start, stop, and enable the Apache web server to start automatically when your server boots up.

🐧Bash / Shell
sudo systemctl stop apache2
sudo systemctl start apache2
sudo systemctl enable apache2

You can test that the Apache web server is running by opening your web browser and browsing to the server’s localhost or IP address.

http://localhost

Apache2 default page confirming successful web server installation on Ubuntu 24.04
Apache2 default page confirming successful web server installation on Ubuntu 24.04

When you see the Apache2 Default Page, it means the Apache HTTP server is successfully installed.

Additional help on installing Apache on Ubuntu is in the link below.

How to install Apache on Ubuntu

Install the MariaDB database server on Ubuntu

phpMyAdmin requires a database to manage, so the next step is to install MariaDB on Ubuntu. Open your Ubuntu terminal and run ‘sudo apt update’ and then ‘sudo apt install mariadb-server’. This installs the database system that phpMyAdmin will connect to.

To install and use the MariaDB database server, use the instructions below.

Open the Ubuntu terminal and run the commands below to install the MariaDB database server.

🐧Bash / Shell
sudo apt update
sudo apt install mariadb-server

Once the MariaDB database server is installed, use the commands below to stop, start, and enable the MariaDB server to start automatically when the server boots.

🐧Bash / Shell
sudo systemctl stop mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb

Run the following commands to validate and test if the MariaDB database server is installed successfully.

🐧Bash / Shell
sudo mariadb

Once you run the commands above, it will log you onto the MariaDB console and display a message similar to the one below.

💻Code
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 32
Server version: 10.11.2-MariaDB-1 Ubuntu 23.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> 

The message tells you that the server is installed successfully.

Additional help on installing MariaDB.

Create a phpMyAdmin user account

It’s important to create a specific user account for phpMyAdmin in MariaDB. The default root account uses a special login method that can cause problems, but a dedicated user allows for easier connections. This step ensures phpMyAdmin can properly interact with your database.

The auth_socket plugin authenticates users that connect from the local host through the Unix socket file. You can’t authenticate as a root by providing a password.

⚠️Warning
This can cause issues with some apps that need to connect to the database via root. To fix that, you’ll need to change the default authentication mechanism from auth_socket to mysql_native_password.

Connecting remotely to database servers carries security risks if root users perform the connection. A recommended method is to create a dedicated user account for remote database connections, offering better security than using root.

📝Good to Know
Since you don’t want to connect to the MariaDB database server from phpMyAdmin as the root user, you should probably create a separate account instead of connecting with the root.

All the database steps above can be done using the commands below:

But first, log on to the MariaDB database server:

🐧Bash / Shell
sudo mariadb

Then run the commands below to complete the steps:

💻Code
CREATE USER phymyadmin@localhost IDENTIFIED BY 'type_your_password_here';
GRANT ALL ON *.* TO phymyadmin@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit

Ensure to replace ‘type_your_password_here ‘with your password.

Install PHP on Ubuntu Linux

Since phpMyAdmin is built using PHP, you need to install PHP and its necessary modules on your Ubuntu system. Run the command ‘sudo apt install php libapache2-mod-php php-intl php-mysql php-curl php-cli php-zip php-xml php-gd php-common php-mbstring php-xmlrpc php-json php-sqlite3 php-soap php-ldap php-zip’ in your terminal to get everything needed.

Run the commands below to install PHP.

🐧Bash / Shell
sudo apt install php libapache2-mod-php php-intl php-mysql php-curl php-cli php-zip php-xml php-gd php-common php-mbstring php-xmlrpc php-json php-sqlite3 php-soap php-ldap php-zip

Additional help on installing PHP

How to install PHP on Ubuntu Linux

Install phpMyAdmin

Now that Apache and MariaDB are set up, you can install phpMyAdmin on Ubuntu using the standard package manager. Just run the command ‘sudo apt install phpmyadmin’ in your terminal. When prompted, make sure to select ‘apache2’ as your web server option.

There’s no need to install additional tools.

Run the commands below to phpMyAdmin on Ubuntu.

🐧Bash / Shell
sudo apt install phpmyadmin

When prompted to choose the web server, select apache2 and continue.

🐘PHP
+------------------------+ Configuring phpmyadmin +------------------------+
| Please choose the web server that should be automatically configured to |
| Web server to reconfigure automatically: |
| |
| [*] apache2 |
| [ ] lighttpd |
| <ok> |
+-------------------------------------------------------------------------+

When prompted again to allow web config-common to install a database and configure, select Yes and press Enter.

🐘PHP
┌────────────────────────┤ Configuring phpmyadmin ├─────────────────────────┐
│ │
│ The phpmyadmin package must have a database installed and configured │
│ before it can be used. This can be optionally handled with │
│ dbconfig-common. │
│ │
│ If you are an advanced database administrator and know that you want to │
│ perform this configuration manually, or if your database has already │
│ been installed and configured, you should refuse this option. Details on │
│ what needs to be done should most likely be provided in │
│ /usr/share/doc/phpmyadmin. │
│ │
│ Otherwise, you should probably choose this option. │
│ │
│ Configure database for phpmyadmin with dbconfig-common? │
│ │
<Yes> <No> │

Next, type and confirm a phpMyAdmin password to the database registry. It can be any password you want to use.

Setup Let’s Encrypt SSL/TLS for phpMyAdmin

It’s a good idea to secure your phpMyAdmin login with an SSL/TLS certificate from Let’s Encrypt. This adds an extra layer of safety when you access your database tools. You can follow a separate guide to set up these certificates with Apache after restarting your server.

Please read the post below for additional resources on installing and creating Let’s Encrypt SSL certificates for Apache.

How to set up Let’s Encrypt SSL certificate for Apache on Ubuntu Linux

Once you have restarted the Apache web server, open your browser and browse to the server hostname or IP address defined in the Apache server block.

After installing phpMyAdmin, open your web browser and browse to the server hostname or IP address followed by /phpmyadmin.

🐘PHP
http://localhost/phpmyadmin

Log on with the account you created earlier for phpMyAdmin.

phpMyAdmin logon portal
phpMyAdmin logon portal

That’s it!

If you followed the steps above and it didn’t work, try this fix:

🐧Bash / Shell
sudo nano /etc/apache2/apache2.conf

Then, add the following line to the end of the file.

🐘PHP
Include /etc/phpmyadmin/apache.conf

Then restart Apache

🐧Bash / Shell
sudo systemctl restart apache2

That should do it!

Conclusion

  • Installing phpMyAdmin with Apache on Ubuntu 24.04 grants you comprehensive database management capabilities through a user-friendly web interface.
  • Apache, MariaDB, and PHP, in conjunction with phpMyAdmin, provide a robust environment for database administration.
  • Securing your phpMyAdmin installation with Let’s Encrypt SSL/TLS ensures data privacy and integrity.
  • Following the outlined steps will result in a successful setup, allowing seamless access to phpMyAdmin for database management tasks.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Install Let's Chat on Ubuntu Linux
Ubuntu Linux How to Install Let's Chat on Ubuntu Linux
How to Install Apache on Ubuntu Linux
Ubuntu Linux How to Install Apache on Ubuntu Linux
How to Change Screen Brightness in Ubuntu Linux
Ubuntu Linux How to Change Screen Brightness in Ubuntu Linux
How to Install Foswiki with Apache on Ubuntu 24.04
CMS How to Install Foswiki with Apache on Ubuntu 24.04

No comments yet — be the first to share your thoughts!

Leave a Comment

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