1. Install Apache using Ubuntu's package manager, apt:
$ sudo apt update
$ sudo apt install apache2
Modify apache to allow URL rewrites:
sudo nano /etc/apache2/sites-available/000-default.conf
Create a directory section where we allow overrides:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName server_domain_name_or_IP
<Directory /var/www/html/>
AllowOverride All
</Directory>
. . .
sudo a2enmod rewrite
sudo systemctl restart apache2
2. Install MariaDB
$ sudo apt install mariadb-server mariadb-client
3. Secure MariDB
$ sudo mysql_secure_installation
4. Install PHP
$ sudo apt install php libapache2-mod-php php-mysql
We want to tell the web server to prefer PHP files over others, so make Apache look for an index.php file first:
$ sudo nano /etc/apache2/mods-enabled/dir.conf
Move the PHP index file to the first position after the DirectoryIndex specification, like this:
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
Ctrl+x, the ‘y' to save and exit. Restart the Apache web server:
$ sudo systemctl restart apache2
5. Install phpMyAdmin
$ sudo apt install phpmyadmin
On the first prompt, select ‘apache2' by pressing the space bar then the ‘tab' key. Press the ‘enter' key to accept. On the following prompt, refuse the option to configure database for phpmyadmin.
Log into MariaDB
$ sudo mysql
Create a new user and give it a strong password:
MariaDB [(none)]> CREATE USER 'yourusername'@'localhost' IDENTIFIED BY 'password';
Then, grant your new user appropriate privileges. For example, you could grant the user privileges to all tables within the database, as well as the power to add, change, and remove user privileges, with this command:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'yourusername'@'localhost' WITH GRANT OPTION;
Following that, exit the MariaDB shell:
MariaDB [(none)]> exit
You can now access the web interface by visiting your server's domain name or public IP address followed by /phpmyadmin:
https://your_domain_or_IP/phpmyadmin
6. Secure phpMyAdmin (optional)
Edit the linked file that has been placed in your Apache configuration directory:
$ sudo nano /etc/apache2/conf-available/phpmyadmin.conf
Add an ‘AllowOverride All' directive within the <Directory /usr/share/phpmyadmin> section of the configuration file, like this:
<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
. . .
When you have added this line, Ctrl+x, then ‘y' to save and close the file. Restart Apache:
$ sudo systemctl restart apache2
see more at https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-18-04