| by Arround The Web | No comments

How to Deploy war File in AWS

Developers often create the application on a separate computer (non-server, which can be their personal computer or a dedicated development computer). Once the development process is done, the application is moved onto the server. As for the server, the developers can use AWS services, as AWS provides the facility to deploy the war file on its EC2 service. This post will discuss the process of deploying the war file in AWS.

Let’s start with how to deploy a war file in AWS:

Deploy war File in AWS

To deploy a war file in AWS, create an EC2 instance by clicking on the “Launch Instances” button from the EC2 management console:

Set the name of the instance and select the Amazon Machine Image for the EC2 instance:

Scroll down the page and choose the type of the instance and click on the “Create new key pair” link:

On the key pair file creation window, type the name of the file and select its type and format. Complete the process by clicking on the “Create key pair” button:

After the configurations of the instance, click on the “Launch Instance” button to create an EC2 instance:

After that, click the “Connect” button after selecting the EC2 instance:

On the Connect page, select the SSH client tab and copy the command from the page:

Paste the command on the Command Prompt or PowerShell and change the path of the private key pair:

Install Java JDK using the following command:

yum install java -y

Running the following command will install the Java JDK:

Download the Tomcat server file using the following command:

wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.84/bin/apache-tomcat-8.5.84.tar.gz

The above command will download the Tomcat server:

The Tomcat file is downloaded in “tar” format. The user needs to untar it using the following command:

tar -xzf apache-tomcat-8.5.84.tar.gz

File has been untarred using the above command:

Rename the file to the “Tomcat” and head into the local directory using the following command:

cp -R tomcat /usr/local/

Running this command will display the following command:

After that head into the Tomcat folder using the following command:

cd tomcat/

The user is inside the tomcat folder using the above command:

Head inside the bin folder using the following command:

cd bin/

Running the above command will display the following output:

Start the Tomcat server using the following command:

./catalina.sh start

The above command will start the tomcat server:

Head into the web app folder and download the war file using the following command:

wget https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war

Running this command will download the war file:

Again, start the tomcat server after deploying war file using the following command:

./catalina.sh start

The above command will start the tomcat server running the war file:

Use the following command on the web browser to check the war file deployed:

http://54.179.234.137:8080/sample

The syntax for the above command is following:

<Protocol>://<Public IP>:<Port>/<war file>

Side Note: This is the Public IP of your EC2 instance

Running this command will display the war file on the web browser:

You have successfully deployed the war file in AWS:

Conclusion

A war file can be deployed in AWS by creating the EC2 instance from the EC2 console page. After that, connect to it using the SSH client and paste the command on the Command Prompt or PowerShell. Once the user is connected to the instance, download the Tomcat server and start its services. After that, download the war file inside the tomcat server, and the file is deployed. Use the public IP and port number with the file name on the web browser to display the war file.

Share Button

Source: linuxhint.com

Leave a Reply