How To Install LAMP Stack on Ubuntu 14.04 on AWS EC2

First off, installing the LAMP (Linux, Apache, MySQL, PHP) stack on an AWS EC2 instance is super easy. But you need the right set of instructions to do it. If you follow an instruction that tells you to use something like tasksel, you will quickly find that you can’t ssh in anymore to your EC2 instance.

Once you start up an Ubuntu 14.04 LTS instance, (I’m onĀ 14.04.03 LTS) the first command to run is:

This will make sure you’re OS is up to date. Next up, let’s install Apache. Make sure your security settings are set to have HTTP (port 80) open.

Let’s install MySQL now:

And last but not least, PHP 5 and 2 modules:

Optional install, phpMyAdmin:

Now if you go to the public IP of your EC2 instance, you will be able to see the following:

That’s it! Your LAMP stack on your AWS EC2 is installed and running. You may now proceed to edit your virtual host config to setup your app/domain. More on that later. Until next time, peace!


  • olidev

    February 28, 2017 at 6:20 pm

    Since this post is little old now, I would like to add something to it. It also possible now to install PHP on EC2 without going directly to AWS. You can a PaaS which makes the process much easier and quicker. Here is an example: This method is much better as it saves developers time which would have otherwise spent in setting up the server, OS and stack. This way developer spend their time and efforts on building the app instead of worrying about server.

  • Francis Kim

    February 28, 2017 at 11:03 pm

    Thanks Oli!

  • sanju

    May 12, 2017 at 10:29 pm

    i followed all the steps, but i am not able to see apache page in browser

  • Rahul Chandra

    June 1, 2017 at 10:01 pm

    Thanks a lot! Worked perfectly!

  • Miguel Lopez Ariza

    December 20, 2017 at 4:49 am


Write a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.