i want to know ,
generally in which scenario we directly create AWS cloud instance by directly uploading java war file
and in which scenario we first setup and ready server first , by installing all softwares like java,tomkat and then deploy code in AWS
Question posted in Amazon Web Sevices
The official Amazon Web Services documentation can be found here.
The official Amazon Web Services documentation can be found here.
2
Answers
Based on your question (it’s not that clear) sounds like you want to deploy a Java app to AWS Cloud. One way is to write a Spring Boot web app and then bundle that project into a FAT JAR that contains all of the depedencies. Then you can use Elastic Beanstalk to deploy the app to the cloud.
See this Java Developer example, in the AWS Code Library, to learn how to perform these tasks. This example app is a basic web app that stores submitted data into an Amazon DynamoDB table. This example walks you step by step through the process.
Build an application to submit data to a DynamoDB table
To deploy Java .war file on an Apache server running on an EC2 instance, you must utilize a combination of Apache Tomcat (as the application server) and the Apache HTTP Server (as the web server) to deploy a.war file. Follow these steps
example, Amazon Linux, Ubuntu).
IMP: Check that the EC2 instance’s
security group enables inbound traffic on ports 22 (SSH), 80 (HTTP),
and 443 (HTTPS).
client such as PuTTY (Windows users) or use can use AWS cloudshell.
‘sudo apt update‘ (for Ubuntu) or ‘sudo yum update‘ (for Amazon
Linux) to update the package list.
‘sudo apt install tomcat9‘ (for Ubuntu) or ‘sudo yum install tomcat‘ (for
Amazon Linux).
‘sudo systemctl start tomcat‘ (for Ubuntu) or ‘sudo service tomcat start‘
(for Amazon Linux).
‘sudo systemctl status tomcat’ or ‘sudo service tomcat status’. Make sure
it’s running correctly.
Copy your .war file to the Tomcat webapps directory. Assuming your .war file
is named "myapp.war" and Tomcat 9 is installed, use the following
command:
sudo cp /path/to/myapp.war /var/lib/tomcat9/webapps/
After copying the .war file, restart Tomcat to deploy the application:
sudo systemctl restart tomcat
you can set up Apache HTTP Server as a reverse proxy. This allows you to use
Apache as a frontend while forwarding requests to Tomcat in the backend.
‘sudo yum install httpd‘ (for Amazon Linux).
create a file named myapp.conf in the ‘/etc/apache2/sites-available/’
directory for Ubuntu:
Your .war file should now be deployed and accessible through either the Apache HTTP Server or directly via Tomcat, depending on your configuration choices.
Hope this solution Helps.