Install Lamp, PHPmyadmin on Ubuntu 18.04




Hi Guys,

In this blog,I will show you how to install lamp and phpmyadmin on ubuntu.we will talk about install lamp server and phpmyadmin in ubuntu 18.04.

this tutorial will give you install phpmyadmin on ubuntu. in this artical i am going to learn you how to install lamp server on ubuntu.

Step 1 – Launch New AWS ec2 Instance

First of all, you need to launch aws ec2 instance. If you have already launch new ec2 instance, so you can move next step.

Step 2 – Connecting your AWS EC2 Instance from SSH

In this step, you need to connect your aws ec2 instance from ssh terminal. If you are new to connect aws ec2 instance with windows, ubuntu and mac system.

Step 3 – Install Apache 2 on ubuntu 18.04

3.1 – Update Ubuntu System Repositories

sudo apt update

3.2 – Update Ubuntu System Repositories

sudo apt install apache2

3.3 – List the UFW application profiles

sudo apt install apache2

3.4 – sudo ufw allow ‘Apache Full’

sudo ufw allow 'Apache Full'

3.5 – Verify that the Apache service is running

sudo systemctl status apache2

3.6 – Open Browser and type EC2 intance IP

Finally, open your browser and type your AWS ec2 instance IP address. And, it will be looks like the Apache 2 page in the following picture:

Step 4 – Install MySQL

4.1 – Installing MySQL server

Now, open your ssh terminal and type the following command to install MySql Server:

sudo apt-get install mysql-server

4.2 – Securing MySQL server in Apache aws ec2

Then, secure MySql server by using the following command. So, you will need to set the root password of the database and secure it using the following command :

sudo mysql_secure_installation

After the password has been set you can check the whether MySQL is working correctly by logging into the database with the command :

sudo mysql -u root -p

Now, Type exit on ssh terminal to get out of MySql:


Install PHP 7.3

5.1 – Install PHP and Common Extensions

Now, install PHP with it’s common extensions. So open your ssh terminal and type the following command:

sudo apt-get install php libapache2-mod-php php-mysql php-curl php-gd php-json php-zip php-mbstring

5.2 – Edit dir.conf File

After successfully installed PHP on ubuntu amazon ec2 instance. Now, you need to configure dir.conf file by using the following sudo nano command:

sudo nano /etc/apache2/mods-enabled/dir.conf

It will look like this:

DirectoryIndex index.html index.cgi index.php index.xhtml index.htm

Move the PHP index file to the first position after the DirectoryIndex specification, like this:

DirectoryIndex index.php index.html index.cgi index.xhtml index.htm

Step 6 – Install, Configure and Access phpMyAdmin

6.1 – Installing phpmyadmin on amazon ec2 ubuntu

Open your ssh terminal and type the following command to install PHPMyAdmin on ubuntu amazon ec2 web server:

sudo apt install phpmyadmin

When you run this command. Then the selective option available for you on the prompt look like folloiwng:

When the first option is appear, you need to select apache2. Now it hasn’t been selected.

Use space bar to select apache2 web server. Then press Tab key that takes us to the Ok button. After that, press enter.

The next option is to configure the database for PHPMyAdmin with dbconfig-common. Select the Yes option here.

After that, password configuration is appear on your terminal screen. And it is asked for login to phpmyadmin. So, you can set your phpmyadmin access password here:

6.2 – Configure phpmyadmin in ubuntu ec2

Open again your ssh terminal and run the following command to configure phpmyadmin in apache2.conf file:

sudo nano /etc/apache2/apache2.conf

After that, add the following line into apache2.conf file and save it

Include /etc/phpmyadmin/apache.conf

6.3 – Enable MySQL root Login for phpmyadmin ubuntu aws

So, open your ssh terminal and type the following command to enable/allow mysql root login access for phpmyadmin on ubuntu aws web server:

sudo mysql -u root -p

Then type this following query:

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

After that type following query to changes into effect:


6.4 – Restart Apache Web Server

After successfully installed PHP MySQL and configure these on ubuntu amazon ec2 instance.

Finally, You need to restart Apache 2 server by using the following command:

sudo service apache2 restart

6.5 – Access phpmyadmin Amazon ec2

Finally, you can login as root from phpMyAdmin. So, open your browser and type the below url with your ec2 server ip:


It will help you....