|
| 1 | +Using jenkins we have to Deploy a war file on tomcat server |
1 | 2 |
|
2 | | -1: Install TOMCAT on linux box |
3 | | - |
4 | | -Step #1: Install Tomcat |
5 | 3 |
|
6 | | -1.1 Create a Linux machine // Ubuntu 20.X |
7 | | -Prereq: Install JAVA |
8 | 4 |
|
9 | | -1.2: down load the package --> google doneload Apache Tomcat --> Version 8 |
10 | | -Copy the link address |
11 | 5 |
|
12 | | -cd /opt |
13 | | -wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.81/bin/apache-tomcat-8.5.81.tar.gz |
14 | | -tar xzvf apache-tomcat-8.5.81.tar.gz |
15 | | -mv apache-tomcat-8.5.81 tomcat |
| 6 | +Jenkins --> compile --> unit testing ---> Package(.war file) |
16 | 7 |
|
17 | | -cd tomcat |
18 | | -cd bin/ |
19 | | -./startup.sh ---> Tomcat started. |
| 8 | +Using jenkins we have to take this .war file and deplpy it on a webserver |
20 | 9 |
|
21 | | -Enabling remote access |
22 | | -------------------- |
23 | | -cd /opt/tomcat |
24 | | -find / -name context.xml |
| 10 | +Webserver : tomcat |
25 | 11 |
|
26 | | -/opt/tomcat/webapps/manager/META-INF/context.xml |
27 | | -/opt/tomcat/webapps/host-manager/META-INF/context.xml |
| 12 | +Step 1: Create server on which we have to install tomcat 8 |
28 | 13 |
|
29 | | -Backup of the Orignal files: |
30 | | -cp -p /opt/tomcat/webapps/manager/META-INF/context.xml /opt/tomcat/webapps/manager/META-INF/context.xml_ORIG |
| 14 | +Step 2: Create another server on which jenkins is installed |
31 | 15 |
|
32 | | -cp -p /opt/tomcat/webapps/host-manager/META-INF/context.xml /opt/tomcat/webapps/host-manager/META-INF/context.xml_ORIG |
| 16 | +Step 3: We will create a free style job to deploy the package on a tomcat server |
33 | 17 |
|
| 18 | +plugin : deploy on container |
34 | 19 |
|
35 | | -vi /opt/tomcat/webapps/manager/META-INF/context.xml |
36 | | -vi /opt/tomcat/webapps/host-manager/META-INF/context.xml |
| 20 | +Step 4: we will create a pipeline job, in which we will write code to deploy on tomcats erver |
37 | 21 |
|
38 | | -Comment the below line over both the files: |
39 | | --------------- |
| 22 | +plugin : ssh agent |
40 | 23 |
|
41 | | -<!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve" |
| 24 | + |
| 25 | + |
| 26 | +Steps for deployment on a webserver: |
| 27 | + |
| 28 | + |
| 29 | + > on a server you are goign to install webserver |
| 30 | + |
| 31 | + > Start the tomcat service or start the webserver |
| 32 | + |
| 33 | + > Copy .war file (package) into the webapps directory of tomcat |
| 34 | + |
| 35 | + > restart tomcat -> so that application is deployed successfully |
| 36 | + |
| 37 | +Access the web application |
| 38 | + |
| 39 | + publicip:8080/packagename |
| 40 | + |
| 41 | + |
| 42 | +https://github.com/Sonal0409/DevOpsClassCodes |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +Step 1: Create server on which we have to install tomcat 8 |
| 48 | + |
| 49 | + |
| 50 | +Pre-req: Install java8 on the server |
| 51 | + |
| 52 | +Install tomcat |
| 53 | + |
| 54 | +$ cd /opt |
| 55 | + |
| 56 | +$ wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.78/bin/apache-tomcat-8.5.78.tar.gz |
| 57 | + |
| 58 | +$ tar -xvzf apache-tomcat-8.5.78.tar.gz |
| 59 | + |
| 60 | +$ mv apache-tomcat-8.5.78.tar.gz tomcat |
| 61 | + |
| 62 | +$ cd tomcat |
| 63 | + |
| 64 | +$ cd bin |
| 65 | + |
| 66 | +$ ./startup.sh ==> tomcat will be up and running |
| 67 | + |
| 68 | +go to browser |
| 69 | + |
| 70 | +public ip:8080 ==> you will see tomcat |
| 71 | + |
| 72 | + |
| 73 | +Do the desired config changes in context.xml file for access manager APP |
| 74 | + |
| 75 | + |
| 76 | +Apply the changes in these 2 context.xml file of tomcat |
| 77 | + |
| 78 | + |
| 79 | +vim /opt/tomcat/webapps/host-manager/META-INF/context.xml |
| 80 | +vim /opt/tomcat/webapps/manager/META-INF/context.xml |
| 81 | + |
| 82 | + |
| 83 | +comment this line in the contxt.xml |
| 84 | + |
| 85 | +<Valve className="org.apache.catalina.valves.RemoteAddrValve" |
| 86 | + allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> |
| 87 | + |
| 88 | +commented in both the files |
| 89 | + |
| 90 | + <!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve" |
42 | 91 | allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> --> |
43 | 92 |
|
44 | | -Restarted Tomcat: |
45 | | --------------- |
46 | | - |
47 | | -cd /opt/tomcat/bin |
48 | | -./shutdown.sh |
49 | | -./startup.sh |
50 | | - |
51 | | -Create users: |
52 | | -vi /opt/tomcat/conf/tomcat-users.xml |
53 | | - |
54 | | -Addd these Roles and users at the end of the file: |
55 | | ----------- |
56 | | -<role rolename="manager-gui" /> |
57 | | -<role rolename="manager-script" /> |
58 | | -<role rolename="manager-jmx" /> |
59 | | -<role rolename="manager-status" /> |
60 | | -<user username="admin" password="admin" roles="manager-gui, manager-script, manager-jmx, manager-status" /> |
61 | | -<user username="deployer" password="deployer" roles="manager-script" /> |
62 | | -<user username="tomcat" password="s3cert" roles="manager-gui" /> |
63 | | - |
64 | | -Restarted Tomcat: |
65 | | --------------- |
66 | | -cd /opt/tomcat/bin |
67 | | -./shutdown.sh |
68 | | -./startup.sh |
| 93 | + |
| 94 | +Create roles & credentials |
| 95 | +**** |
| 96 | + |
| 97 | +$ cd conf |
| 98 | + |
| 99 | +$ vim tomcat-users.xml |
| 100 | + |
| 101 | +at the end before </tomcat-users> add these roles |
| 102 | + |
| 103 | + <role rolename="manager-gui"/> |
| 104 | + <role rolename="manager-script"/> |
| 105 | + <role rolename="manager-jmx"/> |
| 106 | + <role rolename="manager-status"/> |
| 107 | + <user username="admin" password="admin" roles="manager-gui, manager-script, manager-jmx, manager-status"/> |
| 108 | + <user username="deployer" password="deployer" roles="manager-script"/> |
| 109 | + <user username="tomcat" password="s3cret" roles="manager-gui"/> |
| 110 | + |
| 111 | + |
| 112 | +Save the file |
| 113 | + |
| 114 | +$ cd bin |
| 115 | + |
| 116 | +$ ./shutdown.sh |
| 117 | + |
| 118 | +$ ./startup.sh |
| 119 | + |
| 120 | + |
| 121 | +publicip:8080 |
| 122 | + |
| 123 | +click on managerapp |
| 124 | + |
| 125 | +username: tomcat |
| 126 | +password:s3cret |
| 127 | + |
| 128 | +you can now see the manager app |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | +Step 2: Create another server on which jenkins is installed - complete |
| 133 | + |
| 134 | + |
| 135 | +Start jenkins |
| 136 | + |
| 137 | +publicip:8080 |
| 138 | + |
| 139 | + |
| 140 | +Install a plugin : Deploy to container Plugin |
| 141 | + |
| 142 | +Create a free style job |
| 143 | + |
| 144 | +give the repo name |
| 145 | + |
| 146 | +give the trigger |
| 147 | + |
| 148 | +build step --> invoike top level maven target |
| 149 | + |
| 150 | +goal as : clean install package |
| 151 | + |
| 152 | +Post build actions |
| 153 | + |
| 154 | +select deploy war/ear on container |
| 155 | + |
| 156 | +WAR/EAR files : **/*.war |
| 157 | + |
| 158 | +Containers: |
| 159 | + |
| 160 | +click on add container--> select tomcat 8 |
| 161 | + |
| 162 | +Select credentials |
| 163 | + |
| 164 | +and give tomcat URL |
| 165 | + |
| 166 | +Build the job |
| 167 | + |
| 168 | +Deployment complete |
| 169 | + |
| 170 | +**************************************** |
0 commit comments