Installing LAMP on cloud instance of Ubuntu

To setup basic LAMP server on your AWS or other cloud instance, you need to connect via SSH and need to do following things which are basically related to setup lamp environment on ubuntu (Linux), for other linux distributions commands can vary:


update ubuntu by executing:

sudo apt-get update


Then install apache using following command:

sudo apt-get install apache2

After installing apache try to hit on your server IP from browser to test if Apache is installed

To install MySQL, open terminal and type in these commands:

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

Then type command:

sudo mysql_install_db

After this MySQL installation will begin and user will be prompted to enter password twice

After doing these things you will be installing PHP, please note that user can also install PHP before MySQL:

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

Above will install PHP, then after installing PHP , restart apache using following command:

sudo service apache2 restart

Although we installed PHP5 mcrypt while installing PHP, but if still mcrypt is having problem then mcrypt is probably disabled and need to enable by doing:

sudo php5enmod mcrypt


and then again restart apache2 so that changes take place by doing:

sudo service apache2 restart


To install CURL lib.

sudo apt-get install php5-curl

And again restart apache2. And after installing any library or module required don’t forget to restart apache2

Then give www-data ownership of www root directory by using following command:

sudo chown -R www-data:www-data wwwrootdirectorypath

Share your thoughts