Launch your Own Web Server Using AWS
According to Amazon’s website, Amazon Elastic Compute Cloud (AWS EC2) is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers.
How to Launch AWS EC2?
The following steps will show you how to launch your own server:
- Go to http://aws.amazon.com
- If you haven’t done already, go ahead and sign up.
- Log in to your account and click on EC2 under Compute
- Before launching your server, you are going to need a Key Pair that would enable you to access your server after launching it. Normally, AWS will ask you to create one during the launch process. But we will go ahead and create one now.
- Under Resources, click Key Pairs.
- Click on Create Key Pair.
- Give the key a name then hit Create.
- You will be prompted to save a .PEM file.
The .PEM file is very important! Save it in a secure place and in multiple locations where no one can access it. Losing this file means losing your server! I’d save it in 3 different locations. On my personal computer, in an external hard drive or flash drive, and in a secured file hosting cloud like DropBox or Google Drive.
- Now, go back to EC2 Dashboard and click Launch Instance to start launching your AWS EC2 server.
- Select the server and operating system. The first one is a great fit for our needs because it has PHP and MySQL repositories.
- Now choose the specifications that you need. The greater the specifications are, the more expensive it’s going to be. For the purpose of this tutorial, I am going to choose type t2.micro
- w click Next: Configure Instance Details
- On Step 3: Configure Instance Details, I just left everything as they are. You can change them to whatever you want depending on your needs.
- Click Next: Add Storage
- On this page, I also left everything as they are. You might need to change the storage to have more space depending on your needs.
- Click Next: Add Tags
- I didn’t change anything on this page. Click Next: Configure Security Group
- On this page, you will need to choose a Security Group. This basically means do you want people to be able to see this website or not. Just give the security group a name and add the following rule if you want your server to be public:
- Click Review and Launch
- Click Launch
- Now, this step is very important. Remember the Key Pair we created earlier? We are putting it use now. In the first drop-down box, select Choose an existing key pair. In the second drop-down box, select the name of the key pair you created. Now check the box after reading and understanding the description in the dialog and then click Launch Instance.
- You’re done. It might take up to 2 minutes for your server to be up and running. If it says “2/2 checks passes” under Status Checks and “running” under Instance State, this means your server is up and running.
How to access your AWS EC2 server via SSL?
If you want to access your server via SSL, you can use a great tool called PuTTY.
- Download and install PuTTY.
- in your AWS, select the instance (server) you have just created. Below you will find some information about the instance. You will need the link that says Public DNS (IPv4) or you can also use the IPv4 Public IP. They both should work fine.
- Open up PuTTY.
- Paste the link in Host Name (or IP address). Keep post as 22.
- Now in the left navigation panel, go to Connection >> SSH >> Auth.
- Now select the ec2-user file you downloaded by clicking Browseunder Private key file for authorization.
- Click Open.
- You will be asked to login. Use ec2-user for your login username then press Enter.
- You are all set and now logged in to your server.
You’re all done. Enjoy your server.
How to access your AWS EC2 server via FileZilla (FTP)?
You might also need to access your server via FileZilla (FTP) to upload your files easily. But before we start, FileZilla can only read PPK for your Key pair. You currently have a PEM Key pair. You are going to have to convert your PEM file to PPK. Here is how you do that:
- Download PuTTY Key Generator
- Use puttygen to convert PEM file to PPK file.
- Start puttygen and select “Load”
- Select your PEM file.
- PuTTY will convert the PEM format to PPK format.
- Select “Save Private Key” A passphrase is not required but can be used if additional security is required.
Here is how you can access your server via FTP:
- Download and install FileZilla Client.
- Open FileZilla.
- Go to File > Site Manager
- Click New Site
- Give your connection a name.
- Under the General tab, type in the AWS URL or IP in the Host field.
- Choose SFTP – SSH File Transfer Protocol for the protocol.
- Logon Type should be Key file.
- User should be ec2-user
- Under key file, choose your converted PPK file.
- Click OK.
- Now you can connect to your AWS server by clicking on the top right Open the Site manager icon arrow then select your website.
- Connecting to your server will land in the root directory of your server. To upload your files (e.g. PHP scripts) you need to navigator to /var/www/html
Things You Need to Know About your AWS Server:
- Pricing varies from server to server depending on your use. For pricing details, visit the Amazon EC2 Pricing page.
- Keep your .PEM in a safe place in three different locations. A good practice is saving the Pair Key in your document folder, a flash drive, and a file hosting service like Dropbox or Google Drive.
- Stopping your instance and then restarting it will result in a new Public DNS (IPv4) and IPv4 Public IP being assigned. However, you can assign an elastic IP to avoid that