How to Install LAMP Server in Ubuntu Linux Distribution

1. Apache server installation

sudo apt update                    # Update Ubuntu system
sudo apt install apache2          # Install Apache server
sudo ufw app list                  # Allow firewall
sudo ufw allow in "Apache"  # Allow Apache
sudo systemctl reload apache2  # Reload or restart Apache Server

2. My SQL installation

sudo apt install mysql-server   # Install MySQL

After installation

sudo mysql                                  # Run this command on the terminal
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin123';   # Set root user password
exit

My SQL secure installation

sudo mysql_secure_installation   # MySQL Secure Installation

Two times press enter then Y press

3. PHP installation

sudo apt install php libapache2-mod-php php-mysql # php installation 

Site enable command

sudo a2ensite your_domain   # Site enable command

Site disable command

sudo a2dissite 000-default   # Site disable command

PHP MyAdmin installs Ubuntu

If you need a UI database you can use phpmyadmin.

sudo apt update                                          # Firstly update system
sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl   # Install PHPMyAdmin and set password
sudo apt install phpmyadmin                            # Install PHPMyAdmin