How to install Apache and MySQL Server (LAMP STACK ) on Ubuntu 20.04 LTS Linux Distribution

Hello Developers , so if you’re a developer and you’re going to build Webapplications on Ubuntu then the most important thing is in our development environment is a Database Server and a Localhost

So for that we are going to install the the Apache & My SQL Server both in Ubuntu 20.04 Linux Distribution ,

Let’s Start

Open Terminal or press CTRL + ALT + T

and then type the following commands

sudo apt-get update
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 necessary packages , some are listed below

  • Apache
  • mySQL Server PHP 7.4
  • php 7.4 mySql
  • php 7.4 json
  • php 7.4 curl
  • php 7.4 mbstring

and more

Now Goto any web browser and open “http://localhost”.

You will see the default Ubuntu 20.04 Apache web page

apache default webpage

Now the following commands allows the user directory for apache and web applications

sudo a2enmod userdir deflate expires

Now edit the php conf file enable it using nano editor

sudo nano /etc/apache2/mods-enabled/php7.4.conf

comment this lines to enable photo in user directory


after commenting all this lines , just press CTRL+O and Hit Enter and Press CTRL+X

to create the web directory anter the following command

mkdir ~/public_html
service apache2 restart

above command will restart the Apache for new configuration

now go to any web browser and enter the url with your username : http://localhost/~YourUserName

Set mySql password

sudo mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

So the default MySQL password is set to ‘password’ you can change the password as you want just replace the value between ‘password’


mysql> exit
sudo apt-get install php-xml

above command will install the php XML Extension

Then you need to restart apache so it takes effect

sudo service apache2 restart

Setup phpMyAdmin

Now go to and click on download

It will automatically download the .Zip file of phpmyadmin

then extract the downloaded file in the public_html folder and rename it as PMA or as you want

now go to the web browser and in localhost navigate to the folder that you extracted


Now you have a powerful development environment for the web applications

Thank you so much

Scroll to Top