Open terminal (ctrl+alt+t) and type the following commands
sudo apt-get update
sudo apt-get install apache2 mysql-server php7.2 libapache2-mod-php libapache2-mod-php7.2 php7.2-mysql php7.2-curl php7.2-json php7.2-cgi php7.2-gd git htop curl htpdate php7.2-mbstring
For 20.04 use the following command
sudo apt-get install apache2 mysql-server php7.4 libapache2-mod-php libapache2-mod-php7.4 php7.4-mysql php7.4-curl php7.4-json php7.4-cgi php7.4-gd git htop curl htpdate php7.4-mbstring
The above command will install all the necessary packages
Goto any web browser and open “http://localhost”.You will see the default Ubuntu 18.04 / 20.04 Apache web page

sudo a2enmod userdir deflate expires
sudo nano /etc/apache2/mods-enabled/php7.2.conf
For Ubuntu 20.04 us the following command
sudo nano /etc/apache2/mods-enabled/php7.4.conf
comment these lines to enable php in userdir

To save and exit the nano text editor. hit ctrl+o
,then hit enter
, then hit ctrl+x
to exit
Create the web directory
mkdir ~/public_html
Restart Apache server for the new configuration to take affect.
service apache2 restart
Now goto the browser and open http://localhost/~YourUserName
In this case the username is bkm
You’ll see the following page

Set MySQL Password
sudo mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
MySQL password is set to ‘password’
mysql> FLUSH PRIVILEGES;
mysql> exit
Try logging in the terminal. Enter the following command
mysql -u root -p
