Delete Java if Java version is not over 1.8 Install Java
sudo su -
java -version
java version "1.7.0_211"
yum remove java -1.7.0*
Install Java
yum install java-1.8*
Confirm Java Version and set the java home
find /usr/lib/jvm/java-1.8* | head -n 3
/usr/lib/jvm/java-1.8.0
/usr/lib/jvm/java-1.8.0-openjdk
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.amzn2.0.1.x86_64
Open .bash_profile
vi ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.amzn2.0.1.x86_64
PATH=$PATH:$JAVA_HOME
export PATH
./startup.sh
Using CATALINA_BASE: /opt/apache-tomcat-8.5.58
Using CATALINA_HOME: /opt/apache-tomcat-8.5.58
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.5.58/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/apache-tomcat-8.5.58/bin/bootstrap.jar:/opt/apache-tomcat-8.5.58/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
/opt/apache-tomcat-8.5.58/bin
Security Group 8080 is opened. So, You can access.
By default Tomcat Server allows to access local system
vi /opt/apache-tomcat-8.5.58/webapps/manager/META-INF/context.xml
vi /opt/apache-tomcat-8.5.58/webapps/host-manager/META-INF/context.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
<http://www.apache.org/licenses/LICENSE-2.0>
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<Context antiResourceLocking="false" privileged="true" >
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\\.\\d+\\.\\d+\\.\\d+|::1|0:0:0:0:0:0:0:1" />
<Manager sessionAttributeValueClassNameFilter="java\\.lang\\.(?:Boolean|Integer|Long|Number|String)|org\\.apache\\.catalina\\.filters\\.CsrfPreventionFilter\\$LruCache(?:\\$1)?|java\\.util\\.(?:Linked)?HashMap"/>
</Context>
After re-setting the configuration, tomcat server restart /opt/apache-tomcat-8.5.58/bin
$ ./shutdown.sh
Using CATALINA_BASE: /opt/apache-tomcat-8.5.58
Using CATALINA_HOME: /opt/apache-tomcat-8.5.58
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.5.58/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/apache-tomcat-8.5.58/bin/bootstrap.jar:/opt/apache-tomcat-8.5.58/bin/tomcat-juli.jar
Using CATALINA_OPTS:
$ ./startup.sh
Using CATALINA_BASE: /opt/apache-tomcat-8.5.58
Using CATALINA_HOME: /opt/apache-tomcat-8.5.58
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.5.58/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/apache-tomcat-8.5.58/bin/bootstrap.jar:/opt/apache-tomcat-8.5.58/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
After re-setting the configuration, tomcat server restart /opt/apache-tomcat-8.5.58/bin
$ ./shutdown.sh
Using CATALINA_BASE: /opt/apache-tomcat-8.5.58
Using CATALINA_HOME: /opt/apache-tomcat-8.5.58
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.5.58/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/apache-tomcat-8.5.58/bin/bootstrap.jar:/opt/apache-tomcat-8.5.58/bin/tomcat-juli.jar
Using CATALINA_OPTS:
$ ./startup.sh
Using CATALINA_BASE: /opt/apache-tomcat-8.5.58
Using CATALINA_HOME: /opt/apache-tomcat-8.5.58
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.5.58/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/apache-tomcat-8.5.58/bin/bootstrap.jar:/opt/apache-tomcat-8.5.58/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
Install Deploy to container in Jenkins Server
Manage Jenkins → Manage Plugins → Available
[ ] Deploy to container**ArtifactUploaders**This plugin allows you to deploy a war to a container after a successful build.Glassfish 3.x remote deployment1.151 yr 1 mo ago
새로운 Item(New Item) → Enter an item name(Maven Project) → Edit Description
Deploy war/ear to a container WAR/EAR files: /.war
Containers:
Tomcat 8.x Remote
Credentials: add Jenkins → ex) Username deployer Password deployer ID deployer_user Description user to deploy on tomcat VM: Check in tomcat server (tomcat-users.xml)
Tomcat URL: http://<Public_IP>:8080
Apply & Save
Build Jenkins Job, and Jenkins will copy the war file to the target server and delivers it. (Tomcat Server)
Tomcat Server usually default location is webapps
/opt/apache-tomcat-8.5.58/webapps
Build Jenkins & Check Tomcat Server
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.146 s
[INFO] Finished at: 2020-09-17T03:27:55Z
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /var/lib/jenkins/workspace/Deploy_on_Tomcat_Server/webapp/pom.xml to com.example.maven-project/webapp/1.0-SNAPSHOT/webapp-1.0-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/Deploy_on_Tomcat_Server/webapp/target/webapp.war to com.example.maven-project/webapp/1.0-SNAPSHOT/webapp-1.0-SNAPSHOT.war
[JENKINS] Archiving /var/lib/jenkins/workspace/Deploy_on_Tomcat_Server/server/pom.xml to com.example.maven-project/server/1.0-SNAPSHOT/server-1.0-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/Deploy_on_Tomcat_Server/server/target/server.jar to com.example.maven-project/server/1.0-SNAPSHOT/server-1.0-SNAPSHOT.jar
[JENKINS] Archiving /var/lib/jenkins/workspace/Deploy_on_Tomcat_Server/pom.xml to com.example.maven-project/maven-project/1.0-SNAPSHOT/maven-project-1.0-SNAPSHOT.pom
channel stopped
[DeployPublisher][INFO] Attempting to deploy 1 war file(s)
[DeployPublisher][INFO] Deploying /var/lib/jenkins/workspace/Deploy_on_Tomcat_Server/webapp/target/webapp.war to container Tomcat 8.x Remote with context null
[/var/lib/jenkins/workspace/Deploy_on_Tomcat_Server/webapp/target/webapp.war] is not deployed. Doing a fresh deployment.
Deploying [/var/lib/jenkins/workspace/Deploy_on_Tomcat_Server/webapp/target/webapp.war]
Finished: SUCCESS