Dec 9, 2012

Posted by in Others | 7 comments

Installing and Configuring PHP, MySQL, Apache in Amazon EC2

As we know Amazon EC2 provides us a fresh new linux installation, we often find it difficult to do this as a newbie. Here I will try to guide you and make it easy for you. Follow the steps.

1- Go to and login with your Email ID and Password.

2- Then click on Launch Instance

3- See the image below, it explains it all. Use the quick launch wizard as shown, select the “Create New” radio button as shown, Provide a name for your instance, provide the name for key pair (This will be used to connect to Amazon EC2 using SSH later), download the key and save it.

Then the continue button will be active. Select “More Amazon Machine Images” as shown and click continue.

4- In the next step, Select image – ubuntu-precise-12.04-amd64-server-20121001 You may select other images, but I have not tested them. See the picture below.

5- Follow the steps and “Launch The Instance”.

Now, connect to your newly launched Amazon EC2 instance. Your username will be ubuntu, you dont need any password to connect, the key which you have downloaded will take care of it. You can refer this article from Amazon EC2 here –

Install LAMP-Stack

Run the following commands

1- $ sudo apt-get update

2- $ sudo apt-get install tasksel

3- $ sudo tasksel install lamp-server
setup password for mysql root user and follow the required steps

Bravo !!! — We are Done with Apache, PHP5 and Mysql setup.

Install PHP Myadmin

1- $ sudo apt-get install phpmyadmin

Say [Y] for After this operation, 23.0 MB of additional disk space will be used. – input Y [Enter]

2- Select apache2 as the webserver and press OK

When prompted Set the admin password for root user to login

DONE Phpmyadmin is installed now – Thats it.. you can enjoy

Installing FTP server

$ sudo apt-get install vsftpd

Edit vsftp configuration file (usually located at /etc/vsftpd.conf).

Disable anonymous access:

Enable local access:
By default, local system users are not allowed to login to FTP server. To change this setting, you should uncomment the following line:

Enable writing:
By default, users are allowed to download files from FTP server. They are not allowed to upload files to FTP server. To change this setting, you should uncomment the following line:

Chown user:
chown_username=your user name (! not root)

After you finish configuring FTP server you need to restart it:

$ sudo service vsftpd restart

Changing Directory Permission for /var/www in Amazon EC2

check your group from root – gruop [username]

1. change the directory’s group to a group you are a member of

$ sudo chgrp anygroup /var/www

2. make the directory group writable

$ sudo chmod g+wr /var/www

3. set the sticky bit for the group so that all files will be written as members of that group

$ sudo chmod g+s /var/www

  1. Thank you for this write up, it helped me.

  2. more tips

    1. use a proper terminal to connect to your SSH
    i used bitvise

    2. How do you access phpmyadmin after you installed
    the link is here

    If it doesn’t work type In a terminal:
    sudo vi /etc/apache2/apache2.conf
    Or download and edit with code editor

    Add the following line to the end:
    Include /etc/phpmyadmin/apache.conf

    then type
    sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf

    and restart the apache:
    sudo /etc/init.d/apache2 restart

    Then you’ll have access to phpmyadmin

    sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf

  3. and Dharam thanks very much for your article,

    check your group from root – gruop [username]
    Was another thing I got stuck with, it is ubuntu
    If you don’t change it

  4. Super. It really helpful lot for me.


  5. Thanks dude!

  6. Thanks so much, i have question :

    1. how i can install joomla ?

    2. to install few different site on different ip, i need to open new instance in amazon for each site?


  7. @uriel Installing Joomla directly to AWS is really time consuming. I would suggest you to use a managed cloud platform for it. Here is a guide to install Joomla on AWS on managed platform:

Leave a Reply