WEB SERVER THROUGH CLI IN AWS

Rishabh Jain
4 min readOct 26, 2020

Hola! IT guys here comes a new blog for deploying every service in AWS just from the CLI and moreover integrating the created services and making a Web Server on which you will be able to host your website and that can be accessed by everyone.

Before starting the creation of Services if you are very new to the AWS CLI then you should first refer to the blog mentioned here.

I will be first starting creating the S3 service and after that accessing it with Cloudfront for implementing CDN Service in the setup.

1. Creating S3 Service

I am going to create the S3 bucket. Code for creating it is shown here.

Now if all goes right you will see this output as shown below.

You can also view this on the top of AWS Cloud in the S3 section as shown below.

After this you have also to upload the object in the S3 and then make it Public as shown below.

OBJECT UPLOADED

Now make it public by editing the bucket policy as shown here.

BUCKET POLICY UPDATED

It will now be public. You can access it with the Object URL as shown below.

OBJECT URL

You can access it through the CLI as shown below.

Create CloudFront Service

Now we have to create the CloudFront service. Code for creating this is shown below.

If all goes right you will be seeing the following output as shown below.

You can also view it in the cloud in the CloudFront section as shown below.

Now try to access with the URL of the CloudFront and you will be viewing the image in S3 as shown below.

3. Web Server

First switch to the Root User by a command as shown below.

Now install the Apache HTTPD Module through the command shown below.

Now once it is done go to the Root Document i.e. /var/www/html as shown below.

Now create a file with extension html and write the code you want.

For this use vi index.html

After writing the code save the file with :wq

In the file add the URL of the cloudfront with img tag as shown below.

Start the HTTP Service provided by this module by a command shown below.

You can check the status of the service by a command shown below.

Now copy the Public IP of the instance and paste it to the Browser and you will see that the html code output will be displaying there.

Your webserver is now configured!!

Thanks a lot!! Hope you learned and enjoyed a lot!

--

--

Rishabh Jain

I am a tech enthusiast, researcher and an integration seeker. I love to explore and learn about the right technology and right concepts from its foundation.