Skip to content
Follow
Ubuntu Linux

How to install phpMyAdmin with Nginx on Ubuntu 24.04

Richard
Written by
Richard
Jun 12, 2024 Updated Sep 15, 2026 8 min read
phpMyAdmin featured image
phpMyAdmin featured image

phpMyAdmin with Nginx on Ubuntu 24.04 gives you a web-based control panel to manage MySQL and MariaDB databases without using the command line. phpMyAdmin is a free tool with a point-and-click screen, while Nginx is the web server that loads that screen in your browser.

Advertisement

Running this setup on Ubuntu 24.04 needs at least 2GB of RAM to keep things running fast and smooth. You can follow these steps to install both tools and connect them on your server.

⚡ Quick Answer

Install Nginx and MariaDB, then create a dedicated phpMyAdmin user. Next, download phpMyAdmin, configure its directory, and set up a Nginx server block for it. Finally, secure your phpMyAdmin installation.

Advertisement

Install Nginx HTTP server on Ubuntu

Nginx web server is required to host your phpMyAdmin setup on Ubuntu 24.04. You can install Nginx by updating your package list and running the default package manager command in your terminal. This sets up the core web server needed to serve your web pages and database interface.

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

sudo apt update
sudo apt install nginx

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

sudo systemctl stop nginx
sudo systemctl start nginx
sudo systemctl enable nginx

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

Advertisement

http://localhost

Nginx default welcome page on Ubuntu 24.04
Nginx default welcome page on Ubuntu 24.04

When you see the "Welcome to nginx" page, it means the Nginx HTTP server is successfully installed.

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

How to install Nginx on Ubuntu

Advertisement

Install the MariaDB database server on Ubuntu

MariaDB database server stores all the data for your phpMyAdmin installation on Ubuntu 24.04. You can install MariaDB using the standard package manager to handle user accounts, tables, and database queries. This gives your web applications a reliable SQL database backend.

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.

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

Advertisement

Create a phpMyAdmin user account

A dedicated phpMyAdmin user account lets you securely connect to your MariaDB database without using the root account. Creating this custom user profile helps protect your database from unauthorized access and gives you better control over permissions.

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.

⚠️WarningThis 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.

A dedicated database user should connect remotely to database servers instead of using root users, as root user remote connections introduce security risks.

Advertisement
💡TipSince 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:

Advertisement
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-FPM on Ubuntu Linux

PHP-FPM (a tool that processes PHP code on web servers) processes the PHP code required to run phpMyAdmin on your Ubuntu system. You can install PHP-FPM along with the necessary PHP extensions using your terminal to ensure phpMyAdmin loads properly in your browser.

Run the commands below to install PHP-FPM.

sudo apt install php-fpm 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

PhpMyAdmin is installed directly from the default Ubuntu 24.04 software sources using the package manager. Once your Nginx web server and MariaDB database are ready, running a single terminal command downloads and sets up the interface files.

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 that should be automatically configured to run phpMyAdmin, tap Ok and press ENTER.

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

Set up Nginx with phpMyAdmin

Nginx configuration files tell the web server how to handle requests for phpMyAdmin and link them to your installation folder. Creating a specific configuration snippet connects your Nginx server block to the phpMyAdmin files so you can load the login page in your browser.

To do that, run the commands below to create a phpMyAdmin snippet that can be used on an existing server block.

sudo nano /etc/nginx/snippets/phpmyadmin.conf

Then copy and paste the code below into the file and save.

location /phpmyadmin {
root /usr/share/;
index index.php;
location ~ ^/phpmyadmin/(.+.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}

location ~* ^/phpmyadmin/(.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}

Save the file and exit.

Finally, include the configuration above in your Nginx server block.

include snippets/phpmyadmin.conf;

If you don’t have an existing domain, open the Nginx default server block by running the commands below.

sudo nano /etc/nginx/sites-available/default

Copy and paste the highlighted line when the file opens, then save.

# Default server configuration
server {
listen 80 default_server;
listen [::]:80 default_server;

include snippets/phpmyadmin.conf;

root /var/www/html;

# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;

server_name _;
location / {
try_files $uri $uri/ =404;

}
# pass PHP scripts to FastCGI server
#
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php
8.3-fpm.sock;
}

}

Restart Nginx

sudo systemctl restart nginx

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

Setup Let's Encrypt SSL/TLS for phpMyAdmin

Let's Encrypt SSL/TLS certificates encrypt the traffic between your browser and your Nginx server to protect your phpMyAdmin login data. Setting up this free certificate ensures your database passwords and queries cannot be intercepted over the network.

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

How to set up Let's Encrypt SSL certificate for Nginx on Ubuntu Linux

Once you have restarted the Nginx web server, open your browser and browse to the server hostname or IP address defined in the Nginx 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.

phpMyAdmin login portal interface on Ubuntu 24.04
phpMyAdmin login portal interface on Ubuntu 24.04

That should do it!

Conclusion:

  • Installing phpMyAdmin with Nginx on Ubuntu 24.04 allows for efficient management of MySQL databases through a user-friendly web interface, providing a secure way to access phpMyAdmin.
  • The installation involves setting up the Nginx HTTP server, installing the MariaDB database server, creating a dedicated user account for phpMyAdmin, installing PHP-FPM, and finally setting up Let's Encrypt SSL/TLS for enhanced security.
  • Following the outlined steps ensures a successful installation and configuration of the phpMyAdmin application, allowing users to access and manage databases seamlessly.

Was this guide helpful?

Was this helpful?
Richard

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.

Advertisement

📚 Related Tutorials

Install MySQL and MariaDB on Ubuntu: A Step-by-Step Guide
Ubuntu Linux Install MySQL and MariaDB on Ubuntu: A Step-by-Step Guide
How to Setup WordPress Nginx Cloudflare Ubuntu Fast
CMS How to Setup WordPress Nginx Cloudflare Ubuntu Fast
How to Install Drupal with Nginx and Cloudflare on Ubuntu
CMS How to Install Drupal with Nginx and Cloudflare on Ubuntu
How to Setup Joomla on Ubuntu with Nginx & Cloudflare
CMS How to Setup Joomla on Ubuntu with Nginx & Cloudflare

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

Leave a Comment

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