How to Install phpMyAdmin with Apache on Ubuntu 24.04
phpMyAdmin for Ubuntu 24.04 provides a web-based dashboard that lets you manage MySQL databases straight from your browser without typing complex commands in a terminal. The tool runs on the Apache web server and handles tasks like building tables, running queries, and managing user accounts.
Getting the platform running on Ubuntu 24.04 takes about 15 minutes and requires installing Apache, PHP, and a database server first. This guide walks you through each step so you can get your database manager online quickly and safely.
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 Apache HTTP server on Ubuntu as part of your phpMyAdmin setup, open your terminal and run the commands sudo apt update and sudo apt install apache2. This installs the web server software required to load web pages and access your database management tool through a browser.
To do that, open the Ubuntu terminal and run the commands below to install the Apache web server.
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.
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

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.
Install the MariaDB database server on Ubuntu
To install the MariaDB database server on Ubuntu, open your terminal and run the commands sudo apt update and sudo apt install mariadb-server. This provides the database system that phpMyAdmin connects to so you can create and manage your website databases.
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.
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.
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.
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.
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.
- How to install MariaDB on Ubuntu Linux
- MariaDB without password prompt
Create a phpMyAdmin user account
To create a phpMyAdmin user account, log into your MariaDB prompt and run a SQL command to add a new user with full privileges. This prevents login errors caused by default root authentication settings and ensures phpMyAdmin can properly connect to your databases.
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.
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.
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:
sudo mariadb
Then run the commands below to complete the steps:
CREATE USER phymyadmin@localhost IDENTIFIED BY 'type_your_password_here';
GRANT ALL ON *.* TO phymyadmin@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
Install PHP on Ubuntu Linux
To install PHP on Ubuntu Linux for your phpMyAdmin setup, open your terminal and run the command sudo apt install php libapache2-mod-php php-mysql along with the required extension packages. This makes sure your web server can process the PHP code that powers phpMyAdmin.
Run the commands below to install PHP.
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
Install phpMyAdmin
To install phpMyAdmin on Ubuntu, open your terminal and run the command sudo apt install phpmyadmin. Make sure to select apache2 when prompted so the installer automatically configures your web server to work with the database management tool.
There's no need to install additional tools.
Run the commands below to phpMyAdmin on Ubuntu.
sudo apt install phpmyadmin
When prompted to choose the web server, select apache2 and continue.
+------------------------+ 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.
┌────────────────────────┤ 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
To set up Let's Encrypt SSL/TLS for phpMyAdmin, you install Certbot and configure your Apache web server to use free security certificates. This encrypts the connection between your browser and server, protecting your database login details from being intercepted.
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.
http://localhost/phpmyadmin
Log on with the account you created earlier for phpMyAdmin.

That’s it!
If you followed the steps above and it didn’t work, try this fix:
sudo nano /etc/apache2/apache2.conf
Then, add the following line to the end of the file.
Include /etc/phpmyadmin/apache.conf
Then restart Apache
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?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!