Deploy a React app on EC2

Services Covered

  • React React

Lab description

On the provided EC2 instance create and host a React app.

Learning Objectives

  • Creating and hosting a React app

Lab date



  • AWS account
  • This lab comes with IDE environment on a EC2 instance (but you can create React app locally and the host it on EC2)

Lab steps

  1. In you IDE in the project folder run:
    npx create-react-app react-app


    cd react-app && ls -la
    yarn start
  2. Then after making some changes to the apps code create and compile production build:
    yarn build --production

    To serve these files up, install Apache HTTP web server

    sudo yarn global add http-server

    Navigate into the new build directory and examine the contents

    cd build && ls -la

    Start the http-server

    http-server -p 8090 -a

    Browsing to the public ip of the instance on port 8090 returns the website:

    The apache server in the backend loggs the calls against it:

  3. Then I repeated the process with the [voting app]()./voting-app:

    And voting API calls works to:

Lab files