tomcat_installation

Overview

Apache tomcat is application server, as such is servers as a middle level between the client and the database system. The installation system is rather simple

Download release

Locate the most recent release, the current one is: 8.5.31 and I will install it on Centos 6.9(Final) - I like Centos 6 :) You can find it on the following location: https://tomcat.apache.org/download-80.cgi

We have to firstly install Java and couple other things though:

[root@localhost jasper]# yum install java
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.coreix.net
 * extras: mirrors.coreix.net
 * updates: mirrors.coreix.net
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.171-8.b10.el6_9 will be installed
--> Processing Dependency: java-1.8.0-openjdk-headless = 1:1.8.0.171-8.b10.el6_9 for package: 1:java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.x                                  86_64
--> Processing Dependency: xorg-x11-fonts-Type1 for package: 1:java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.x86_64
--> Processing Dependency: libpng12.so.0(PNG12_0)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.x86_64
--> Processing Dependency: libjvm.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.x86_64
--> Processing Dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.x86_64
--------------------------------------
Installed:
  java-1.8.0-openjdk.x86_64 1:1.8.0.171-8.b10.el6_9

Dependency Installed:
  alsa-lib.x86_64 0:1.1.0-4.el6      fontconfig.x86_64 0:2.8.0-5.el6                            freetype.x86_64 0:2.3.11-17.el6
  giflib.x86_64 0:4.1.6-3.1.el6      java-1.8.0-openjdk-headless.x86_64 1:1.8.0.171-8.b10.el6_9 jpackage-utils.noarch 0:1.7.5-3.16.el6
  libICE.x86_64 0:1.0.6-1.el6        libSM.x86_64 0:1.2.1-2.el6                                 libX11.x86_64 0:1.6.4-3.el6
  libX11-common.noarch 0:1.6.4-3.el6 libXau.x86_64 0:1.0.6-4.el6                                libXext.x86_64 0:1.3.3-1.el6
  libXfont.x86_64 0:1.5.1-2.el6      libXi.x86_64 0:1.7.8-1.el6                                 libXrender.x86_64 0:0.9.10-1.el6
  libXtst.x86_64 0:1.2.3-1.el6       libfontenc.x86_64 0:1.1.2-3.el6                            libjpeg-turbo.x86_64 0:1.2.1-3.el6_5
  libpng.x86_64 2:1.2.49-2.el6_7     libxcb.x86_64 0:1.12-4.el6                                 ttmkfdir.x86_64 0:3.0.9-32.1.el6
  tzdata-java.noarch 0:2018e-3.el6   xorg-x11-font-utils.x86_64 1:7.2-11.el6                    xorg-x11-fonts-Type1.noarch 0:7.2-11.el6

Complete!

Now we have to create the users and directory:

[root@localhost jasper]# groupadd tomcat
[root@localhost jasper]# mkdir /opt/tomcat tomcat
[root@localhost jasper]# useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat

Finally, we can download and install it :)

[root@localhost jasper]# cd /opt/tomcat
[root@localhost opt]# wget http://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.31/bin/apache-tomcat-8.5.31.tar.gz
--2018-06-20 15:53:28--  http://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.31/bin/apache-tomcat-8.5.31.tar.gz
Resolving www-us.apache.org... 40.79.78.1
Connecting to www-us.apache.org|40.79.78.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9552281 (9.1M) [application/x-gzip]
Saving to: “apache-tomcat-8.5.31.tar.gz”

100%[==================================================================================================================================>] 9,552,281   3.12M/s   in 2.9s

2018-06-20 15:53:31 (3.12 MB/s) - “apache-tomcat-8.5.31.tar.gz” saved [9552281/9552281]
Saving to: “apache-tomcat-8.5.31.tar.gz”

100%[==================================================================================================================================>] 9,552,281   3.12M/s   in 2.9s

2018-06-20 15:53:31 (3.12 MB/s) - “apache-tomcat-8.5.31.tar.gz” saved [9552281/9552281]

[root@localhost tomcat]#
[root@localhost tomcat]# ls -lart
total 9344
-rw-r--r--.  1 root   root   9552281 Apr 27 22:47 apache-tomcat-8.5.31.tar.gz
dr-xr-xr-x. 22 root   root      4096 Jun 20 15:00 ..
drwxr-xr-x.  3 root   root      4096 Jun 20 15:53 .

[root@localhost opt]# tar -xzvf apache-tomcat-8.5.31.tar.gz
apache-tomcat-8.5.31/conf/
apache-tomcat-8.5.31/conf/catalina.policy
apache-tomcat-8.5.31/conf/catalina.properties
apache-tomcat-8.5.31/conf/context.xml
apache-tomcat-8.5.31/conf/jaspic-providers.xml
apache-tomcat-8.5.31/conf/jaspic-providers.xsd
apache-tomcat-8.5.31/conf/logging.properties
apache-tomcat-8.5.31/conf/server.xml
apache-tomcat-8.5.31/conf/tomcat-users.xml
apache-tomcat-8.5.31/conf/tomcat-users.xsd
apache-tomcat-8.5.31/conf/web.xml
apache-tomcat-8.5.31/bin/
apache-tomcat-8.5.31/lib/
apache-tomcat-8.5.31/logs/
--------------------------------
[root@localhost opt]# ls -alrt
[root@localhost apache-tomcat-8.5.31]# ls -alrt
total 120
drwxr-x---. 2 root root  4096 Apr 27 22:24 work
drwxr-x---. 2 root root  4096 Apr 27 22:24 logs
drwxr-x---. 7 root root  4096 Apr 27 22:24 webapps
-rw-r-----. 1 root root 16246 Apr 27 22:26 RUNNING.txt
-rw-r-----. 1 root root  7138 Apr 27 22:26 RELEASE-NOTES
-rw-r-----. 1 root root  1723 Apr 27 22:26 NOTICE
-rw-r-----. 1 root root 57092 Apr 27 22:26 LICENSE
drwx------. 2 root root  4096 Apr 27 22:26 conf
drwxr-xr-x. 4 root root  4096 Jun 20 15:53 ..
drwxr-xr-x. 9 root root  4096 Jun 20 15:53 .
drwxr-x---. 2 root root  4096 Jun 20 15:53 lib
drwxr-x---. 2 root root  4096 Jun 20 15:53 temp
drwxr-x---. 2 root root  4096 Jun 20 15:53 bin

[root@localhost opt]# id tomcat
uid=500(tomcat) gid=500(tomcat) groups=500(tomcat)
[root@localhost tomcat]# chown -hR tomcat:tomcat tomcat
[root@localhost tomcat]# ls -lart
total 9348
-rw-r--r--.  1 root   root   9552281 Apr 27 22:47 apache-tomcat-8.5.31.tar.gz
dr-xr-xr-x. 22 root   root      4096 Jun 20 15:00 ..
drwxr-xr-x.  4 root   root      4096 Jun 20 15:53 .
drwxr-xr-x.  9 tomcat tomcat      4096 Jun 20 15:53 apache-tomcat-8.5.31

Once the tomcat is unzipped with it's own owner, we can start it as follows:

[root@localhost bin]# ./startup.sh
Using CATALINA_BASE:   /opt/apache-tomcat-8.5.31
Using CATALINA_HOME:   /opt/apache-tomcat-8.5.31
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.5.31/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/apache-tomcat-8.5.31/bin/bootstrap.jar:/opt/apache-tomcat-8.5.31/bin/tomcat-juli.jar
Tomcat started.
[root@localhost bin]# netstat -plntu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1286/sshd
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1365/master
tcp        0      0 :::8009                     :::*                        LISTEN      1593/java
tcp        0      0 :::8080                     :::*                        LISTEN      1593/java    <- This port is open:
tcp        0      0 :::22                       :::*                        LISTEN      1286/sshd
tcp        0      0 ::1:25                      :::*                        LISTEN      1365/master
[root@localhost bin]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@localhost bin]# getenforce 0
Enforcing
[root@localhost bin]# setenforce 0

We can see the front page if we enter via http client:

  • tomcat_installation.txt
  • Last modified: 2019/10/18 20:04
  • by 127.0.0.1