AWS EC2 Instance with Ubuntu Apache2 Web Server

This article explains how to launch an Ubuntu AWS EC2 instance, deploy a LAMP (Linux, Apache, MySQL, PHP) stack with a default website, and map the server with a domain registered with GoDaddy.

Create an EC2 Ubuntu Server Instance

  1. Open the AWS EC2 Management Console
  2. Click Launch Instance
  3. Select an Ubuntu Server instance (you may want to start with one that is “free tier eligible”)
  4. Choose an instance type
  5. Since we are launching a simple instance, you may skip all the steps and click Review and Launch
  6. In the Review Instance Launch page click Launch
  7. Select an existing key pair or create a new key pair

    Note: If you create a new key pair, AWS will generate a new private key (.pem file) to be downloaded to your computer. This file is essential in order to connect to the instance. If you lose the file, you may never be able to connect to that instance and you may need to terminate it a recreate a new one.
  8. Click Launch Instances
  9. Click View Instances to open the EC2 Management Console
    Note: The instance may take a few minutes to start up. You can give the instance a name (for example, the type of machine).
  10. Once the instance is up and running, you have to set up inbound rules in order to make it publicly available. In the Description tab, click the security group that was automatically generate during the creation of the instance.

    Note: You may specify the security group and inbound rules before launching the instance.
  11. In the Inbound tab, click Edit to add new rules
  12. You should have an SSH rule already create by default (this allows you to connect via the Secure Shell protocol). Add a rule for HTTP and HTTPS, both with Source set to “Anywhere” (or “” and “::/0”)
  13. The instance is now publicly accessible. The public IP address can be found in the EC2 Management Console in the Description tab

    Note: Public IPv4 addresses are reallocated each time you stop or restart an instance. To make the IP address persistent, use Elastic IPs to allocate a static address and associate it with your EC2 instance.


You can connect to a Linux machine using the SSH (Secure Shell) protocol using any SSH client. PuTTY is a example of SSH client for Windows.

Deploy LAMP Stack

LAMP stack is a popular open source web platform, commonly used to run dynamic web sites and servers. It includes Linux, Apache, MySQL, and PHP (or Python or Perl).

  1. Connect to your Ubuntu instance using PuTTY (or any other SSH client)
  2. Run the following commands to install the necessary packages:
    sudo apt-get update
    sudo apt-get install apache2
    sudo apt-get install libapache2-mod-php php
    sudo apt-get install mysql-server php-mysql
    sudo service apache2 restart
  3. If everything is installed correctly, you should be able to enter the IP address of your EC2 instance in any web browser, and see the Apache2 default page:

Connect EC2 Instance to GoDaddy Domain

Follow these instructions to connect your EC2 instance to a GoDaddy domain. Once mapped, you should be reaching the same Apache2 Ubuntu Default Page from either the public IP address or your domain.

Comments are closed.