-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
Installing TOMCAT on amazon linux ec2 machine | ||
prerequisites JAVA 1.8* | ||
Download the java and set the environment path in /etc/profile - it will set for permanently for all users access | ||
#yum install java-1.8* -y | ||
#vi /etc/profile | ||
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.amzn2.x86_64 | ||
:wq | ||
|
||
#source /etc/profile | ||
#echo $JAVA_HOME | ||
|
||
now download the tomcat file into os from below link | ||
https://tomcat.apache.org/download-80.cgi | ||
# cd /opt/tomcat | ||
|
||
#wget http://mirrors.fibergrid.in/apache/tomcat/tomcat-8/v8.5.35/bin/apache-tomcat-8.5.35.tar.gz | ||
#tar -zxvf apache-tomcat-8.5.35.tar.gz | ||
check whether the tomcat is running or not | ||
#ps -ef | grep tomcat | ||
#cd /bin | ||
[root@usmanshariff2c apache-tomcat-8.5.35]# echo $PATH | ||
/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/rvm/bin | ||
|
||
now set the link file for auto start and stop the tomcat server | ||
ln -s /opt/tomcat/apache-tomcat-8.5.35/bin/startup.sh /usr/bin/tomcatup | ||
ln -s /opt/tomcat/apache-tomcat-8.5.35/bin/shutdown.sh /usr/bin/tomcatdown | ||
|
||
#tomcatup | ||
[root@usmanshariff2c bin]# tomcatup | ||
Using CATALINA_BASE: /opt/tomcat/apache-tomcat-8.5.35 | ||
Using CATALINA_HOME: /opt/tomcat/apache-tomcat-8.5.35 | ||
Using CATALINA_TMPDIR: /opt/tomcat/apache-tomcat-8.5.35/temp | ||
Using JRE_HOME: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.amzn2.x86_64 | ||
Using CLASSPATH: /opt/tomcat/apache-tomcat-8.5.35/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-8.5.35/bin/tomcat-juli.jar | ||
Tomcat started. | ||
|
||
#tomcatdown | ||
[root@usmanshariff2c bin]# tomcatdown | ||
Using CATALINA_BASE: /opt/tomcat/apache-tomcat-8.5.35 | ||
Using CATALINA_HOME: /opt/tomcat/apache-tomcat-8.5.35 | ||
Using CATALINA_TMPDIR: /opt/tomcat/apache-tomcat-8.5.35/temp | ||
Using JRE_HOME: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.amzn2.x86_64 | ||
Using CLASSPATH: /opt/tomcat/apache-tomcat-8.5.35/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-8.5.35/bin/tomcat-juli.jar | ||
|
||
now goto server.xml and change the port number - by default it will be having 8080 now change it to 8081 and save | ||
#cd /opt/tomcat/apache-tomcat-8.5.35/conf/server.xml | ||
|
||
<Service name="Catalina"> | ||
|
||
<!--The connectors can use a shared executor, you can define one or more named thread pools--> | ||
<!-- | ||
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-" | ||
maxThreads="150" minSpareThreads="4"/> | ||
--> | ||
|
||
|
||
<!-- A "Connector" represents an endpoint by which requests are received | ||
and responses are returned. Documentation at : | ||
Java HTTP Connector: /docs/config/http.html | ||
Java AJP Connector: /docs/config/ajp.html | ||
APR (HTTP/AJP) Connector: /docs/apr.html | ||
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080 | ||
--> | ||
<Connector port="8081" protocol="HTTP/1.1" | ||
connectionTimeout="20000" | ||
redirectPort="8443" /> | ||
<!-- A "Connector" using the shared thread pool--> | ||
|
||
|
||
:wq! | ||
|
||
now to goto browser and check the url like below wethere the tomcat is up and running or not | ||
http://<ip-addr>:8081 | ||
|
||
now goto tomcat-users.xml file and provide the users roles and groups | ||
#vi /opt/tomcat/apache-tomcat-8.5.35/conf/tomcat-users.xml | ||
note: from the below of the file - insert the new users and roles at 7th line from below | ||
|
||
<role rolename="manager-gui"/> | ||
<role rolename="manager-script"/> | ||
<role rolename="manager-jmx"/> | ||
<role rolename="manager-status"/> | ||
<user username="admin" password="admin" roles="manager-gui, manager-script, manager-jmx, manager-status"/> | ||
<user username="deployer" password="deployer" roles="manager-script"/> | ||
<user username="tomcat" password="s3cret" roles="manager-gui"/> | ||
|
||
:wq! | ||
|
||
now check for context.xml | ||
#find / -name context.xml | ||
#vi /opt/tomcat/apache-tomcat-8.5.35/webapps/host-manager/META-INF/context.xml | ||
note : do the changes like do uncomment like shown below | ||
--> | ||
<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> | ||
:wq! | ||
|
||
note: also do the changes in the below file : | ||
vi /opt/tomcat/apache-tomcat-8.5.35/webapps/manager/META-INF/context.xml | ||
--> | ||
<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> | ||
:wq! | ||
|
||
Now you can go to browser and and check the url | ||
http://<ip-addr>:8081 | ||
http://<ip-addr>:8081/manager/html { - here it will ask for credentials to login - user : tomcat, passwd : s3cret } | ||
|
||
========== | ||
|
||
the user called deployer in tomcat-users.xml is to be taken into credentials for jenkins | ||
|
||
Jenkins -> credentials -> global -> add credentials -> | ||
user : deployer | ||
password : deployer | ||
ID/DESCR : (anything) like TomcatCredentials | ||
-> save | ||
|
||
|
||
Now go to jenkins Home page | ||
Jenkins -> manage jenkins -> manage plugins => available -> Deploy to Container -< install without restart | ||
Now create a new item/new job -> configure -> add the repository -> git -> clone and paste it here and ( https://github.com/usman6745/hello-world_test.git ) | ||
|
||
BUILD | ||
Root POM pom.xml | ||
Goals and options clean install package | ||
|
||
Post-Build Actions | ||
- Deploy war/ear to Container | ||
war/ear files : **/*.war | ||
select tomcat8 | ||
credentials -> deployer(TomcatCredentials) | ||
Tomcaturl : http:<ip-addr>:8081 | ||
|
||
|
||
|
||
Build Now | ||
|
||
|
||
the war/ear file will be deployed into following path : /opt/tomcat/apache-tomcat-8.5.35/webapps | ||
#cd /opt/tomcat/apache-tomcat-8.5.35/webapps | ||
#ls | ||
docs examples host-manager manager ROOT webapp webapp.war | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|