How to Setup Amazon Web Services EC2 Instance with Apache, PHP, MySQL

How to Setup Amazon Web Services EC2 Instance with Apache, PHP, MySQL

Go to and create a new account if you do not have an account already.
A credit card or debit is required.

Sign into your AWS account under console management.

Select EC2 and create a new instance.

Choose one of the Ubuntu AMIs, and leave everything default. Under Security groups, create a new security group with SSH and HTTP.
Name your key and download.

Under the terminal, maneuver to the key and chmod 400 to make sure that the permissions are correct.
Under windows, you may have to run as administrator the command prompt or cygwin to chmod properly.
Or you can use the command that I did, which was:
chown :Users testTutorial.pem
Then I did:
chmod 400 testTutorial.pem
Allows only me to read
ssh -i testTutorial.pem ubuntu@…(public IP)

Once you are on the Ubuntu AMI, you can start to mess around with the packages to install.
I recommend the following:
Run the command:
sudo apt-get install apache2 libapache2-mod-php5 php5 mysql-server mysql-php5
You can also get phpadmin if you would like.
Remember to restart the apache service:
service apache2 restart

Then, run a secure installation of mysql:

Go put in your browser the public IP. It works! But what if you want to change the index.html

Well, go cd ../../var/www
In this directory www, you can edit the index.html
sudo vim index.html
You can change the index.html to anything you want using the editor of your choice.

The site changes.

Extra tags: How,to,Setup,Install,Use,Amazon,Web,Services,EC2,Instance,with,Apache,PHP,MySQL,Amazon Web Services,Amazon EC2,Elastic Compute Cloud,How to Setup Amazon Web Services EC2,How to Install Amazon Web Services EC2,How to Use EC2,Beginner,Tutorial,How to Install Amazon EC2,How to Setup Amazon Web Services EC2 Instance with Apache,AWS EC2 Instance,Amazon Web Services EC2 instance

Share the knowledge

25 thoughts on “How to Setup Amazon Web Services EC2 Instance with Apache, PHP, MySQL

  1. Pretty good video, but pro tip: it doesn’t look good to have all that
    pirated software in your downloads folder when you show a demo

  2. Am I “too old to become a developer”? Maybe yes. So far I can speak 3
    “humanly” languages pretty fluently, which are English, French and German
    and my native language of course. (plus basic html, php, etc because I had
    to to communicate with your so called TUTORIALS…)

    Oh boy, coding = boring!
    Do coders believe they belong to some sort of secret mason cult that no
    simple man is invited? Really? WAKE UP no, you don’t!

    Simple men don’t code! If we ever want to open our calculator (which is
    also easy for simple man), we simple press start and select CALCULATOR!
    Voila! The magic happens and there it is! What do we do when we want to
    move a file into a folder on our desktop? we do it with MOUSE!
    Easy right? No need to press 0’s or 1’s dots or ciggles or caggles or
    terminals or any other sillyness. When we launch an AWS intance? We go to
    companies like Bitnami.

    Again, EASY RIGHT? But when we need a deeper understanding or help or any
    kind of aid about something difficult for us (ppl with non or basic coding
    knowledge), like our website launch at AWS or Google Cloud, we come to
    Youtube. But we see OTHER CODERS like you explaining every piece of sh.t
    with CODES again!

  3. To see the User you have to use for your EC2-Instance, only mark it, and
    click on the Button “connect”. If you click, a popup shows the connection
    In this way, no need to remember which image use which name.

  4. realy liked you Video you have a very good mind and it shows in your
    naritive and how you used the Zoom feature to show us what you just typed,
    if only more “Gurus” out there would understand that there is more
    Comprehension Displayed by helping some one lear than demonstrating
    knowlage. good work.
    I’m checking out your other vids to see what else you can teach me.
    done any work on having DNS worked into the above method? I own a domain
    and it’s curently pointing at a placeholder.html in an AWS-S3 bucket.
    Trying to scrape together a learning enviroment on the Cheap. any
    sugestions appriciated.
    again thanks!

  5. Great video! I followed your steps and got the same UNPROTECTED PRIVATE KEY
    FILE error but when I tried your solution it did not work. Any suggestions?

  6. Thanks MicrowaveSam! I’m a Mac/Linux guy but learned a lot. You make it
    look easy…I think AWS remains superior to Google Cloud at the
    moment–even as GCE/GAE are pulling up close behind with lots of momentum.
    I appreciate your making this video.

  7. Could you also show how to setup Ubuntu Snappy on AWS EC2? I have feeling
    you can deliver a more in depth look in comparison to that Ubuntu guy with
    his Chopin music and silent treatment

  8. got an error
    could not create directory ‘/home/user/.ssh’
    the authenticity of host ‘’ cant be

  9. hey nice tutorial, i am having a problem while running ssh, it shows me
    connection timeout ( I am using the public IP of my server ) what could be
    possible issues.

  10. I’ve used both Windows Azure and Amazon EC2 and have issues with running
    MySQL on the cheaper instances. Just running a basic blog like WordPress
    will eventually cause MySQL to eat up all the instances’ resources.
    Eventually you’ll go to your site and see an error screen like “Can not
    connect to Database”. Restarting MySQL fixes the issue, but its constantly
    going down. What can I do to fix that?

Leave a Reply

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