How to Create a Ubuntu Virtual Server in AWS using EC2 and Login via SSH

If you're wanting to publish a PHP web app like Laravel or a WordPress site you might considering using a virtual server that people on the internet can connect to and use your service from. EC2, or Elastic Compute Cloud by AWS, is a common solution for this.

Setup your EC2 Instance

  • Go to the EC2 Service inside the AWS console and select your preferred region.
  • Click Launch Instance
  • Name your server
  • Choose Ubuntu as your Application and OS Image
  • You can also change the specs on your Instance
  • Be sure to click Create New Key Pair. The default settings should be fine. It will download automatically and select the key pair you just generated for you.
  • If you’re going to be hosting a website or app, be sure to check Allow HTTP traffic from the internet and Allow HTTPS traffic from the internet
  • Click Launch

SSH Into your Server from your Computer with Termius

From the list of Instanced in EC2, find the Public IPv4 address next to the instance you just created. You'll use this, your username, which is ubuntu since we're using Ubuntu, and your .pem key that you downloaded to connect via SSH into your server. I use a wonderful free tool called Termius. Here is some additional documentation on storing your key for later use here.

You'll find all the files distributed from your server live in /var/www. You'll want to replace these with your project files, such as the public directory of your Laravel Project.