INTRODUCTION
In this blog, we are going to learn about deploying a react project on an AWS EC2 server.
PREREQUISITES
Create an AWS account.
Set up an Ec2 server of Ubuntu with a key pair if you are a beginner try getting a free tier server.
SETTING UP A SERVER
Open the AWS console. Click on Service and Select "EC2"
Click on Launch instance
Enter the name of your instance and Select the required AMI(Amazon Machine Index), Instance type.
Enter the name for key-pair and click on "Create a new key pair" and download the file.
Select your required Storage configuration and click on Launch Instance.
For this we will be using ubuntu micro free tier server.
DEPLOYING AND STARTING PROJECT
After setting up a server go to your instances _> start instance _> connect.
In connect go in the SSH client and copy the SSH link that will be present at the bottom, Copy that.
Open your Linux terminal and get into the directory where your key pair is present.
Change permissions of key pair by
chmod 400 keypair.pem
. (If required)To connect to the EC2 instance paste the ssh link we copied in a terminal. You should be in your server terminal by now.
Now, install the npm package required to start a project using
sudo apt install npm
Go into your project directory and run the command
npm install
to build the project.Now run the command npm install to run the project.
Now open a web browser and run the project URL replacing local host with your EC2 instance's public IP.
CONCLUSION
On completion of the reading and following all steps present in will blog by now you you have successfully deployed your Java React on an AWS EC2 instance.
Happy coding!! Happy Learning!!