8 August 2020   |   by Naman Kumar   |   AWS, Blogs

Hosting website using nginx on aws

Host a react app using nginx on aws ec2 instance


Hosting your website is the best way to show the world your talent. but hosting a website can be a stressing and confusing task. you have make important decisions before hosting your website like what service to chose?, will that service have the support for the technology that is been used in that website?




Why AWS(Amazon Web Service)?

1. AWS enables you to select the operating system, programming language, web application platform, database, and other services you need.


2.AWS has a robust billing control,users pay only for the services and resources they use.


3.Storing data and applications in the cloud does not have to be a security risk. With AWS, all infrastructure is run from secure facilities and data centers. Moreover a aws user can configure custom setting for security.


4.The platform also allows for a high level of customization to meet the needs of individual businesses


5.AWS is one of the most dominant players in cloud computing today.


Starting with AWS.

1. Getting to AWS – lets start by going to the aws service. aws.amazon.com.This is the official aws page by amazon.


2. Create an account – on the website at top right corner there will be a sign into console button.


3. Sign up – then go to create a new aws account. and complete fill the detail.


4. Create a ec2 instance – after sign in is complete than aws console can be accessed. select the services on the header of the console. select ec2 under Compute.


5.Start a ec2 instance – select running instance in the list shown. on the right side of the content there would be launch instance option. then it will take you to a list of option for operating system. In this particular article we will be selecting amazon linux 64-bit.


6.ec2 instance – After selecting the amazon linux 64-bit. A list will be displayed showing you the different type of instance you can chose from. in this article we will be chossing the free tire eligible (t2.micro)


7.Create a key – a block will be displayed when you click launch instance. select the option create new key from the drop down and enter a sutaible name for the key file. Download that file name.pem


Connect to your ec2 instance

1. If you go to the instance list from the service on the top. You will see the a instance running.


2. If you right click on that running instance a list will be displayed select the first option saying connect.


3. then multiple option will be provided by aws to connect with your instance. in this particular article we will be going with A standalone SSH client

4. copy the example that will e provided in the same block.

5. open cmd as administration in the folder where u downloaded your .pem files

6. In the cmd terminal paste the command press enter and it will create a ssh connection with your instance

7. you are in the intance now install node, git bash ,nginx using the following command in exactly same order curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash,sudo nvm install node,sudo yum install git

8. pull your repository from git on the instance.

9. open your project folder type command npm install node that will install the deppendencies to your folder

10. type in npm start and your node project will start.

11. from aws concole copy the ip address type it in your brower and you have success fully hosted your first react app using aws ec2 instance