Step 1: Prepare the LAMP Server

A) Connect with instance

Command:  chmod 400 pemfile_name.pem
          ssh -i "pemfile_name.pem" [email protected]_dns
Example:  ssh -i "pemfile_name.pem" [email protected]

B) Now check software is updated 

Command: sudo yum update -y

C) Now we need to install apcahe server, MySql, and and PHP software packages.  

Command: sudo yum install -y httpd24 php70 mysql56-server php70-mysqlnd

D) start Apcahe web Server

Command: sudo service httpd start

E) Now run chkconfig command to configure the Apache web server to start at each system boot.

Command: sudo chkconfig httpd on

you can verify that httpd is on by running the following command:

Command: chkconfig --list httpd

To set file permissions

Add your user 

sudo usermod -a -G apache ec2-user

Change the group ownership of /var/www and its contents to the apache group.

sudo chown -R ec2-user:apache /var/www

Step 2: Test Your Lamp Server

Create php file with var/www/html folder
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php

Now check on browser 

Step 3: Secure the Database Server

A) Start the MySql Server

sudo service mysqld start

B) Run mysql_secure_installation

 sudo mysql_secure_installation

C) Run MySql Server

sudo chkconfig mysqld on

Step 4: Install phpMyAdmin

Install the required dependencies.

sudo yum install php70-mbstring.x86_64 php70-zip.x86_64 -y

Restart Service

sudo service httpd restart

Navigate to Apache document root at /var/www/html.

cd /var/www/html

Select a source package for the latest phpMyAdmin release from To download the file directly to your instance, copy the link and paste it into a wget command, as in this example:


Create a phpMyAdmin folder and extract the package into it using the following command.

mkdir phpMyAdmin && tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1

Delete the phpMyAdmin-latest-all-languages.tar.gz tarball.

rm phpMyAdmin-latest-all-languages.tar.gz

If the MySQL server is not running, start it now.

sudo service mysqld start

Now check phpmyadmin

Leave a Comment