Creating an AWS Instance with Apache2

 

In this tutorial, we will learn how to create our very own AWS (Amazon Web Services) Instance, how to connect to it and how to install an Apache2 service.

Please note that there is one prerequisite that you need to fulfill before you can move forward:

  • You need to have a valid credit/debit card to create your very own AWS account. Don’t worry, you won’t be charged for your first year of use.

Alright, let’s get started.

 

Tutorial

Step 1: Create your AWS account

Head over to https://aws.amazon.com/. From there, follow the steps to create your free account. This is not covered here, as it is not that hard to do.

Once you have finished, head over to the Management Console.

 

Step 2: Switch region

Since we live in Europe, it is best to choose a server that is closer to our physical location, in order to decrease PING time between you and your server.

Look at the top-right corner of your browser. There, to the right of your username, you will see a drop-down representing the available regions. For our case, select Frankfurt.

region

If you live in a different region, select what is most appropriate for you.

 

Step 3: Getting an instance up and running

We must now navigate to where we can create a new instance. From to the top-left corner of your browser click on Services, then, from the drop-down menu, under the Compute section, select EC2.

selection

From the new screen, click on the blue Launch Instance button found in the center of the page.

launch.PNG

Now, scroll down the page if necessary, until you see an option named Ubuntu Server 16.04 LTS … and click on the blue Select button to the right of it.

instance_type

In this section, you don’t need to make any changes, the default values are the right ones. To move to the next required step, click on the blue 6. Configure Security Group link at the top side of the page.

cpu & next.PNG

We will need to add a new security rule in order to allow HTTP connections to our instance. By default, we only have an SSH rule set up. In order to add a new one, click on the gray Add Rule button, then, from the new entry that appears, just select HTTP from the available drop-down. No other changes are required. Once this is done, click on the blue Review and Launch button at the bottom-right of the page.

http & next.PNG

In the review section, all we need to do is click on the blue Launch button at the bottom-right of the page.

finish.PNG

Once you’ve done this, the final thing we need to do in our set-up is to get our connection key. This will be used in order to connect through SSH to our instance. Be very careful with this file, DO NOT LOSE IT! It is the only copy you will get.

In order to get the file, from the drop-down select Create a new key pair. In the Key pair name textbox, just add a name to your file. It can be whatever you want. Click on Download Key Pair to save the file, then click on Launch Instances.

key & next.PNG

Next, click on View Instances in order to get back to our management console.

view.PNG

Here you will see your newly created instance. Please wait until the Instance State column displays the green dot and the running message.

running.PNG

 

Step 3: SSH connection set-up

This step will have two sub-parts, one related to set-up in a Windows environment, while the other is for UNIX systems.

 

Step 3.1: Windows

In this section, we will cover the set-up of creating a connection to our instance in Windows.

First of all, you will need to download two tools. They are PuTTYPuTTYGen. Depending on your Windows version, here are the direct links for download for:

Using these tools we will be able to modify our previously downloaded key file in order to support PuTTY, and then connect to our instance.

First, we will start PuTTYGen. In it click on the Load button.

puttygen 1.PNG

Navigate to where you downloaded your key file. Make sure you have All Files (*.*) selected on the bottom-right, in order to see it.

puttygen 2.PNG

Finally, click OK on the notice message box, then Save private key to save your new, usable, key somewhere on your PC.

puttygen 3.PNG

Now, we are done with PuTTYGen and need to move to PuTTY. Start the application up.

putty.PNG

In this main interface, we need to add our Host Name as well as the user we are using to connect. In that textbox add ubuntu@ immediately followed by your instance address. You can get that by going back to your browser, in the management console, on your instance you will see a column named Public DNS (IPv4). Just copy that here, so it looks something like this:

putty2.PNG

Next, we will add our newly created key file. In the navigation menu on the left of the app, go to Connection -> SSH -> Auth. There, click on Browse and add your .ppk key file. Click on Open to start the connection.

putty3

You will be asked if you want to accept the server key. Click on Yes.

putty4

Once that is done, you are connected!

ssh

 

Step 3.2: UNIX

In this section, we will cover the set-up of creating a connection to our instance in macOS or Linux.

We will not need anything special installed, as everything we need is already available.

Open a new Terminal window, navigate to where your key file is stored, then run the following commands:

chmod 400 <key_file>

ssh -i <key_file> ubuntu@<host_dns_address>

Make sure to replace the command with the proper data you have. If you are asked if you want to continue, write yes and press Enter.

Screen Shot 2018-03-17 at 4.44.06 PM

You are now connected!

 

Step 4: Updating Ubuntu

We will need to update Ubuntu in order to have access to the latest versions of everything need installed. This is simple. All we need to do is run the following commands:

sudo apt-get update

sudo apt-get upgrade -y

If at any point, you are asked to make any selections/configurations, just press Enter to skip and use defaults.

 

Step 5: Installing Apache2

In our last step, we will finally install Apache2. To do this, just simply run this command:

sudo apt-get install apache2 -y

 

Step 6: Verifying our installation

All that is left to do is open your browser and go to the host DNS address you previously used to connect with SSH.

If something like this shows up, congratulations! You are done.

done

 

Final thoughts

We will continue this tutorial in the future, with installing and using things such as Python3PHPMySQL and more. Stay tuned!

If you did not manage to reach the result in the above image, leave a comment and we will see how to fix it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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