0

I have created Java Web Application that is running on Apache Tomcat. Now, I need to upload it on a remote server. I want to use AWS. I'm new to AWS. I created EC2 instance and copy my .war file to it using this command:

scp -i mykey.pem /Path/to/my/app.war  ec2-user@ec2-54-187-202-41.us-west-2.compute.amazonaws.com:/var/www/html/

the file is copied to the /var/www/html/. However, when I tried to access the website content it doesn't show my app content, it downloads the .war file to local machine in downloads folder. Could anyone told me what is wrong? How I can run my web application on EC2?

F. Fo
  • 123
  • 6
  • 18

1 Answers1

0

One easy way is:

Copy the war file to (TOMCAT_HOME/webapps/) folder and restart Tomcat . 
WannaBeGeek
  • 979
  • 14
  • 32
  • where is the TOMCAT_HOME/webapps/ located?? – F. Fo Apr 30 '16 at 06:23
  • look for it at this path : usr/share/tomcat – WannaBeGeek Apr 30 '16 at 06:27
  • on EC2 . You need to look for the path at Ec2 and copy the war file there . and then Restart the tomcat at Ec2. – WannaBeGeek Apr 30 '16 at 06:33
  • There is no tomcat under share !! – F. Fo Apr 30 '16 at 06:33
  • I found this line on AWS tutorial **Apache httpd serves files that are kept in a directory called the Apache document root. The Amazon Linux Apache document root is /var/www/html, which is owned by root by default.** However, if I copied the .war to html is not work. – F. Fo Apr 30 '16 at 06:36
  • http://stackoverflow.com/questions/12280372/where-can-i-find-the-tomcat-7-installation-folder-on-linux-ami-in-elastic-beanst look this question – WannaBeGeek Apr 30 '16 at 06:37
  • Thank you. I found it and I copied the .war file to it. However, it is still download the .war instead of opening the pages. if I use the url dns/MyApp/ it shows the requested url was not found. And if I used dns/MyApp.war it download the .war file. – F. Fo Apr 30 '16 at 06:56
  • You need to restart the tomcat so that the war file gets deployed. – WannaBeGeek Apr 30 '16 at 07:06
  • I really appreciate your collaboration. I got it running. However, I'm getting the HTTP Status 404 error the request resource is not available. Do you have any idea about what may cause this problem? – F. Fo Apr 30 '16 at 07:41
  • You might not be accessing it correclty . You need to access it as : DNS/webappName – WannaBeGeek Apr 30 '16 at 08:08
  • Yes i access it as DNS/webappName but either gave me the 404 error or this error HTTP Status 500 - java.lang.ClassNotFoundException: org.apache.jsp.index_jsp – F. Fo Apr 30 '16 at 08:22
  • are you able to access tomcat ? – WannaBeGeek Apr 30 '16 at 08:23
  • If I tried to access tomcat main page using DNS:8080 I got the same errors 404 and 500 – F. Fo Apr 30 '16 at 08:26
  • you need to make tomcat accessible by adding the rules to security firewall. – WannaBeGeek Apr 30 '16 at 08:27
  • I have added the port 8080 to security group on EC2 instance – F. Fo Apr 30 '16 at 08:29
  • tomcat is not started then. Debug a little what might be causing it. – WannaBeGeek Apr 30 '16 at 08:32
  • I have started it using this command sudo service tomcat7 start. Isn't correct?? – F. Fo Apr 30 '16 at 08:35
  • look here :http://stackoverflow.com/questions/21966082/cannot-access-tomcat-instance-installed-in-ec2 and http://stackoverflow.com/questions/6863063/how-to-make-tomcat-on-aws-ec2-available-from-outside-localhost. and here also :http://serverfault.com/questions/391179/how-to-access-amazon-ec2-instance-by-http – WannaBeGeek Apr 30 '16 at 08:44
  • 1
    WannaBeGeek I really appreciate your help. It really helped me. I finally got it work. Thank you very much. – F. Fo Apr 30 '16 at 20:49