Install (LAMP) Apache, MySQL, PHP, phpMyAdmin AWS EC2 Instance

Steps to install Apache, PHP, MySQL, phpMyAdmin on AWS :- 

Install Apache, MySQL, PHP on Linux generally called LAMP which needs to install together to host websites and dynamic web applications on server. Where Linux is operating system, Apache is web server, MySQL is database and content is processed with PHP scripting language.

Connect EC2 Instance

If you need to setup EC2 Instance then follow this blog.

To Connect EC2 Instance, either we can use Terminal, VSSH or PUTTY application. Make sure you have SSH Key (PEM file) is handy. Which is provided by AWS at the time of creating instance. 

On AWS > EC2 Instance > Select the instance and click on connect. Which will provide you instructions to connect the instance. 

Install Apache2

Apache is widely used web server since many years. It’s very popular and well documented web server. We can easily install apache using ubuntu’s package manager “apt”. Use below commands to install Apache.

sudo apt-get update
sudo apt-get install apache2

Enable Required apache2 modes

sudo a2enmod headers proxy_http xml2enc proxy ssl proxy_wstunnel rewrite

Note: rewrite  // this mode is to enable htaccess

for .htaccess to work enabled mode rewrite

    sudo nano /etc/apache2/apache2.conf

    <Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All  //------ this will be none and should be All
        Require all granted

Install PHP 7.2

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2
sudo apt-cache search php7.2-*
sudo apt-get install php7.2-fpm
sudo apt-get install php7.2-mbstring php7.2-curl php7.2-json php7.2-xml php7.2-mysql php7.2-zip
sudo apt-get install php-pear php7.2-dev

sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.2-fpm
sudo apt-get install libapache2-mod-php7.2

pear config-set php_ini /etc/php/7.2/apache2/php.ini
pecl config-set php_ini /etc/php/7.2/apache2/php.ini

Install MySQL phpMyAdmin

sudo apt-get install mysql-server mysql-client
sudo apt-get install phpmyadmin

Please add respective password of root user when asked in terminal for mysql root user.

Check the Server

You can verify the server installation right away. Just open the web browser and insert your server ip address it should have apache default web page and display something like below image.


Access PhpMyAdmin

To Access PhpMyAdmin type your server’s IP address /phpmyadmin it will display phpmyadmin login screen. 

Login with root user and use password which you set at the time of installation. 

Free SEO Checker |
Test your website for free with

Get Your SEO report!

Don’t miss the next post!


Related Posts