Installing a basic LAMP stack dengan Amazon AWS EC2 instance

Kebetulan lagi nangani soal cloud service. Jadi langsung aja basic knowlegde tentang ini. First off you will need to create an account with Amazon AWS I will assume you have done that successfully and navigated your way to the AWS Management Console.

I will also assume that you are running in windows on your local machine but that will only affect which program you use for SSH.

AWS Management Console

AWS Managment Console

You will see on the above screen shot that I am running in region EU West, this tutorial will work in any region but that one is closest to me, so select the one closest to you.


Fist you will need to create a security Key pair so under the Navigation group (on the left) Network & Security select Key Pairs and click create a key pair, I called mine businessPhonebook (for reasons that I wont go into here) but call yours what you like.

Click instances under the Navigation menu.

Click the Launch Instance Button

Launch Instance AWS

Select the top one “Amazon Linux includes the EC2 AMI tools” and continue.

Create AWS Instance

You can edit the details here to change security groups etc but I will assume this is your first time so just click Launch. Note that the key pair has selected the only existing one, in my case businessPhonebook.

Return to the Instances menu and you will see your new Server/Instance running there. It’s not actually of much use at the moment, we need to create our LAMP stack (Linux Apache MySQL PHP)

If you highlight your instance and scroll down in the window below you will see that it has a Private IP Address but this is of little practical use to you at this stage. It also has a Public DNS and a Private DNS, you can use the Public DNS to access your server from the net but it is best to associate an Elastic IP with your instance, this will allow you to switch server very quickly a key part of running in the cloud, so we will do that now.

in the Navigation/Network & Security menu select Elastic IP and click allocate New Address (“EIP used in” should be EC2) you will then see that an IP address that has been allocated to your account (note if you leave one of these ip’s vacant ie not attached to a running instance they charge you, not huge but it adds up)

Highlight the new IP address and click associate address, select the instance you want to associate this ip to. We then return to the IP menu and you will see that it has been attached to your running instance. If you stop your instance you will probably need to re associate your ip once again on restart.

Go back to instances page and note the name of the security group your instance has been assigned to, this was very likely newly created when you launched your instance.

Lets just check that you have the necessary settings in your security group select Navigation/Network & Security/Security Groups. Select the group and click Inbound.

AWS security Group

If it does not appear like that make the necessary changes, by adding new rules you must click the Apply Rule Changes to invoke them after you are done adding.



Download PuTTY & PuTTYgen from the net, putty will allow you to SSH to your remote sever and do the necessary set up for your LAMP stack, now this bit can be tricky so pay attention.

You are going to need Puttygen as this will allow you to convert you key file (.PEM) as created when you saved it to a secure location via AWS to a (.PPK) file as used by Putty

Run Puttygen do file/Load Private Key and locate the security key created via AWS, follow the instructions and then export using the save Private key option.

Now close PuttyGen and open Putty.

Enter in your elastic ip address into the IP address box set the port to 22 and make sure the SSH connection type radio button is checked, then under the category menu select SSH/Auth, browse to your private key select it then click open, it should then load SSH on your instance.

At login enter “ec2-user” and any password security key if you set one (not explained here).

Kalau dengan Mac OS X contoh:

ssh -i CustomerDashboard.pem

Dimana  CustomerDashboard.pem didapat dari installing Instance pada tahap awal.

Now the Fun Bit we need to create MySQL and PHP

set your privileges to root using

sudo -i

install MySQL

yum install mysql mysql-server mysql-libs

Start MySQL

/sbin/service mysqld start

then set MySQL it to auto start at boot time

chkconfig –levels 235 mysqld on

Now set a MySQL root password

mysqladmin -u root password ‘my-password’

Then we install PHP and Apache

yum install httpd php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

That will give you a basic installation of PHP with mySQL support you can add more components later if required.

Restart Apache

/etc/init.d/httpd restart

Set Apache to auto load on restart

chkconfig –levels 235 httpd on

then open a browser to http://<your IP>/

and the Apache test page should load.

Apache Default

you now have a Lamp stack your publicly accessible internet root directory (where you put your webpage) is at /var/www/html

You can configure an FTP application that supports SSH to upload files, something like Core-FTP LE will do the trick, you will need to set it up to use your security keys etc



PHPMyAdmin is useful, so to install that do the following

Run Putty again as above

set root privileges

sudo -i

download phpmyadmin


rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

Install phpmyadmin

yum install phpmyadmin

now using nano we set the configuration file I am going to allow access to this instance of MySQL from anywhere but it is not really best practice so I suggest you modify this when you do a release of your site, but for test purposes this will be fine.

nano /etc/httpd/conf.d/phpmyadmin.conf

where it says “Deny from All” change it to “Allow from All” close nano using <control> X and follow the instructions to save the file.

then edit the config file using

nano /usr/share/phpmyadmin/

where it says $cfg[‘Servers’][$i][‘auth_type’] = ‘cookies’; change ‘cookies’ to ‘http’ and close nano again using <control> X

Restart apache

/etc/init.d/httpd restart

load phpmyadmin with

http://<your IP>/phpmyadmin

And you are now at home on your new LAMP server with phpmyadmin support.


Hope that helped



Leave a Reply

Your email address will not be published. Required fields are marked *

S3 backups using BACKUP-Gem

Basic Linux Privilege Escalation