Relase Management: Setup Tomcat Application Server

Release Management: Setup Tomcat Application Server

In this blog i will help you to set up a brand new application server.

Assumptions

  • You have a Linux Machine or VM (with root access)
    • I have used a Centos 6.5 VM for this demo
  • You know how to use Putty and WinScp
  • You have a basic understanding of Linux
  • You have a 64 bit operating system

 

1. Setup the account that will be running the tomcat and log in to the Machine

If you are using a Brand new machine you may need to create a new user Account

Create a brand new user account and group.

# groupadd tomcat
# useradd tomcat -g tomcat
# passwd tomcat
Changing password for user tomcat.
New password:
Retype new password:
# su – tomcat
$

2. Download and Setup Java

This will take a few steps. Ideally we want to use the latest JDK from Oracle. Your download screen should look something similar to the image below.

We used “jdk-8u65-linux-x64.gz”

Refer to the steps below for more details.

$ pwd
/home/tomcat
$ ls -lrt
-rw-rw-r–. 1 tomcat tomcat 181260798 Jan 18 13:33 jdk-8u65-linux-x64.gz
$ tar -xvf jdk-8u65-linux-x64.gz
$ ln –s jdk1.8.0_65 JDK
$ ~/JDK/bin/java -version
java version “1.8.0_65”
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
$

RM_Tomcat_files_image001

 

3. Download Tomcat

We used  apache-tomcat-7.0.67.tar.gz  ( See image below for more details)

RM_Tomcat_files_image002

 

4. Unizp Tomcat Tar File
$ pwd
/home/tomcat
$ ls
apache-tomcat-7.0.67.tar.gz
$ tar -xvf apache-tomcat-7.0.67.tar.gz
::::
$ ln -s apache-tomcat-7.0.67  TOMCAT
## Update the ports at ~/TOMCAT/conf/server.xml if needed

 

5. Set up Tomcat Environment

You need to add below lines to the “.bash_profie” and then source them using the “.” command.
vi ~/.bash_profile
export JAVA_HOME=/home/tomcat/JDK
export CATALINA_HOME=/home/tomcat/TOMCAT
export PATH=$PATH:$JAVA_HOME:$JAVA_HOME/bin:$CATALINA_HOME/bin:$HOME/bin
. ~/.bash_profile

 

6. Start Tomcat
$ startup.sh
Using CATALINA_BASE: /home/tomcat/TOMCAT
Using CATALINA_HOME: /home/tomcat/TOMCAT
Using CATALINA_TMPDIR: /home/tomcat/TOMCAT/temp
Using JRE_HOME: /home/tomcat/JDK
Using CLASSPATH: /home/tomcat/TOMCAT/bin/bootstrap.jar:/home/tomcat/TOMCAT/bin/tomcat-juli.jar
Tomcat started.

 

7. Verify that Tomcat is working on CentOS

We will have to use the Browser in the Unix Machine for this.
If you do not have a browser on the Unix Machine then go to the next step.
Below Screen Shot is NOT from Windows , it is from Linux/Centos.

RM_Tomcat_files_image003

 

8. Find the IP Address of the Linux Host
$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:30:bb:2e brd ff:ff:ff:ff:ff:ff
inet 192.168.1.9/24 brd 192.168.1.255 scope global eth1
inet6 fe80::a00:27ff:fe30:bb2e/64 scope link
valid_lft forever preferred_lft forever
$

 

9. Open ports so that we can access our VM from Windows (you will need root Access)
# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
# service iptables status
iptables: Firewall is not running.
# chkconfig iptables off
# chkconfig iptables –list
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
#

10. Verify that Tomcat is working ( from Windows / Host OS)

Below screen shot is from Windows or Host Operating System. Note you will need to use the IP that you found initially.

Refer to https://jenkins-ci.org/ for more details

RM_Tomcat_files_image004

11. Setup Tomcat Security so that we can deploy from Jenkins ( or other sources)

Ref: http://www.jdev.it/deploying-your-war-file-from-jenkins-to-tomcat/

You need to setup a user Id and Password so that other applications  can use the same to deploy and undeploy applications.
Please restart tomcat after making the change.
$ vi ~/TOMCAT/conf/tomcat-users.xml
$ cat ~/TOMCAT/conf/tomcat-users.xml
<?xml version=’1.0′ encoding=’utf-8′?>
<tomcat-users>
<user username=”deployer” password=”secret-deployer” roles=”manager-script”/>
</tomcat-users>
$
$ ~/TOMCAT/bin/catalina.sh stop
:::
$ ~/TOMCAT/bin/catalina.sh start
::::
Tomcat started.
$

Please let me know if you need more details on some sections of this page.

Author: Pathik Paul

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *