How To Install Linux, Apache, MySQL, PHP (LAMP) on Ubuntu AWS Server


The ” LAMP ”  is a group of open source software which Include Linux , Apache , Mysql and PHP which install together on a server to host dynamic PHP based websites on server.If you  want to host PHP based website on your AWS server then in this article i will guide you that how to install Linux, Apache, MySql and PHP on Ubuntu Server.


First of all you have to connect your AWS server with ssh. after login into your ec2 instance then follow the following steps

Step 1. Install Apache on Ubuntu AWS Server :

The Apache is most popular and open source  web server in the world so it is a default choice for the all PHP lovers.You can install Apache using Ubuntu’s Repository because Apache is manage by Ubuntu’s Package Manager.

Please run following commands on ssh and say yes for all questions.

sudo apt-get update
sudo apt-get install apache2

If you are not using super user then run sudo su to change your role.

Now visit to your server and you will see the default Apache web server page.

visit  http://www.yourdomainname or visit to your server IP address



Step 2. Install MySql on Ubuntu AWS Server

MySQL is open source data management system and you have to install MySQL on your web server to store your customer information or run your database on the server.

Please run following commands on ssh

sudo apt-get install mysql-server php5-mysql

During the installation of MySQL on your server the ssh will ask you for MySQL password for root user.Please enter your password and keep it safe.This is the master root password of  your all database for root user.

And now run this command to install database on your MySQL

sudo mysql_install_db

Now run the following command for secure your database

sudo mysql_secure_installation 

It will ask you for MySQL password.Here type your password and then ssh will ask you to change password option. if you don’t want to change your password then type ‘n’ for ‘no’ and hit enter

For all next option just press enter for default values.


Step 3. Install PHP on Ubuntu AWS Server:

PHP is word most popular and open source programming language will help to create dynamic pages on your server.In this step we will install the PHP component set on the server to run PHP code on the server.

Run the following command on the ssh to install php

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Now set the default Apache page as php page and run the following command

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

It will look like this:

<IfModule mod_dir.c>
    DirectoryIndex index.html index.cgi index.php index.xhtml index.htm

Add index.php file in the index list it is not there

Save the file using Ctrl+X and hit Enter for next option
Now restart the server with the following command and enjoy :)
sudo service apache2 restart 

Now you also need to install few more php libraries to run your is the
common php libraries required for your website.

sudo apt-get install libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap php5-cli php5-cgi libapache2-mod-fcgid apache2-suexec php-pear php-auth php5-mcrypt mcrypt php5-imagick imagemagick libapache2-mod-suphp libruby libapache2-mod-ruby libapache2-mod-python php5-curl php5-intl php5-memcache php5-memcached php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl memcached


Now again restart your server and enjoy 🙂

For next step of your website setup on Ubuntu AWS server please my other article.

How to install php on Ubuntu aws server

How to install Linux on Ubuntu aws ec2 server

How to install Mysql on Ubuntu aws ec2 server

Sign up for our newsletter to get Daily Updates

It is main inner container footer text