how to setup nginx on aws and pull the code from GITHUB , static code

This article is to describe the quick steps to configure the static website on the nginx stack running on AWS EC2.

to know about nginx please visit , https://serverguy.com/comparison/apache-vs-nginx/

Select amzong linux AMI for the image

i aI am using t2.micro for testing purpose

to save my money i have selected the spot instance

you can create EC2 without the key and continue with default user id and password

you need wait for a while till your instance is full initialed

once the EC2 is ready connect using browser based ssh , you can also use tool like putty

Run the following command to install the nginx on the server

#sudo amazon-linux-extras install nginx1

to check status nginx

# systemctl status nginx.service

to enable nginx service

#systemctl enable nginx.service

to start the service

#systemctl Start nginx.service

make sure the status is running

browe the public ip address and make sure nginx welcome screen is visable

now its time to pull your code

usally default webpage is running from the following location, in these test i will use same location to replace with my sample source code (default location /usr/share/nginx/html)

first i will remove the default webpage with help of

#rm -rf *

to confirm you can try to access with the same public ip adderss and you will see that default page is not there

for testing purpose i am using Microsoft demo html page

https://github.com/microsoft/project-html-website.git

install package to run the git command on the linux

# sudo yum install git

naviate to /usr/share/nginx/html and clone the code from the git

# sudo git clone https://github.com/microsoft/project-html-website.git

after the clone, you can check # ls to make sure code is pulled well ,

# sudo mv project-html-website/* .

run above command to mv the files on the correct location

onces copy is done you can try to access new website from the public ip address

now you can point your A record to public address

THANKS