Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn EC2 Web Server | EC2 Overview
Introduction to Cloud Computing
course content

Course Content

Introduction to Cloud Computing

Introduction to Cloud Computing

1. Introduction to Cloud Technologies
2. AWS S3 Overview
3. EC2 Overview
4. RDS Management

book
EC2 Web Server

Typically, EC2 instances are used to host servers. These servers can carry out various functions; it could be a web application server, an online gaming server, or a server with computational power that you can use for your tasks.

In simple terms, you rent a computer that's located remotely and is consistently maintained. This means you don't have to worry about your server and can focus on other things.

What I'm getting at is that in this chapter, we'll see how to set up a web server on your instance and host our portfolio HTML page.

Setting Up a Web Server

Just like that, a computer can't become a server. As you might have already figured out, an instance is just a regular computer that we rent. We need to install a web server and turn our instance into a server where we can host our web application (website).

We'll be using the Apache web server called httpd.

To install the httpd server on your instance, run the following command:

To verify that everything has been installed correctly, run the following command:

Next, we need to make sure that httpd will start automatically after the instance reboots.

To do this, we must enable httpd with the following command:

And we will receive the response with the httpd file system and server location:

You've successfully set up the Apache httpd Server on your instance. Now, let's move forward with hosting HTML pages on the web server.

Transfering Files to Instance

Now we need to transfer the HTML file from our local device to the instance. To do this, we'll use the scp command for secure file transfer from the local machine to the server.

Open the terminal or command prompt on your computer and run the following command:

  • /path/to/your-key.pem: the path to your private key;
  • /local/path/to/your-file.html: the path to the HTML file you want to transfer;
  • ec2-user: the standard username for Amazon Linux AMI;
  • your-ec2-public-ip: the public IP address of your EC2 instance.

Let's use this command to transfer our portfolio HTML page.

Now, let's switch to our instance console and verify if the file has been transferred by using the ls command:

As you can see, the file has been successfully transferred to the directory we specified.

Placing the File in the Web Server Directory

By default, Apache HTTP Server on most Linux distributions stores web pages in the directory /var/www/html. You should move your HTML file to this directory using the mv command:

Now that our file is in the right folder, all that's left to do is rename the file and start the server.

Launch the Server

To rename the file, we can also use the mv command, specifying the old and new filenames. Let's navigate to the directory where our file is located and run the appropriate command:

You can also check the contents of the file using the cat command.

Now that our HTML file is in the desired directory, all we need to do is start the server.

This is done with the following command:

As you can see, the server is now active and ready to use.

To view our HTML page, you need to navigate to the public IPv4 address of your instance.

This is the website we've hosted:

So, we've set up a web server on our instance and hosted our HTML portfolio page on the server.

1. What software do you install on an EC2 instance to set up a web server?

2. How can you transfer an HTML file from your local computer to the EC2 instance?

3. Which directory is typically used by Apache HTTP Server to store web pages on most Linux distributions?

What software do you install on an EC2 instance to set up a web server?

What software do you install on an EC2 instance to set up a web server?

Select the correct answer

How can you transfer an HTML file from your local computer to the EC2 instance?

How can you transfer an HTML file from your local computer to the EC2 instance?

Select the correct answer

Which directory is typically used by Apache HTTP Server to store web pages on most Linux distributions?

Which directory is typically used by Apache HTTP Server to store web pages on most Linux distributions?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 6
We're sorry to hear that something went wrong. What happened?
some-alt