Installing Apache Tomcat 9 and GeoServer on Centos 7

Installing Apache Tomcat 9 and GeoServer on Centos 7

Tomcat (in older versions – Catalina ) – servlet container open source developed by Apache Software Foundation … Implements the specification servlets , specification JavaServer Pages (JSP) and JavaServer Faces (JSF). Written in language Java Tomcat allows you to run web applications , contains a number of programs for self-configuration. Tomcat is used as a standalone web server , as a content server in combination with web server Apache HTTP Server and also as servlet container at application servers JBoss and GlassFish

Preparatory stage

We update the operating system, add the EPEL repository

                        [[email protected]]# yum update
[[email protected]]# yum install epel-release

Installing the necessary software

                        [[email protected]]# yum install htop mc nano wget zip unzip

Install Java 8. The package is available in the official repository

                        [[email protected]]# yum install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64

Once the installation is complete, you can check the installed version using the following command

                        [[email protected]]# java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

Installing Apache Tomcat 9

Download the software release from the Apache Tomcat official website and unpack it

                        [[email protected]]# cd /home
[[email protected]]# wget
[[email protected]]# unzip -d /opt

After unpacking, a directory called “apache-tomcat-9.0.13” was created. Let’s rename it

                        [[email protected]]#  mv /opt/apache-tomcat-9.0.13 /opt/tomcat

Run the following command to set the CATALINA_HOME environment variable

                        [[email protected]]# echo "export CATALINA_HOME='/opt/tomcat/'" >> ~/.bashrc
[[email protected]]# source ~/.bashrc

It is not recommended to run Apache Tomcat as root, so we will create a new user that will start the Tomcat server. We will also change the permissions on all files in the / opt / tomcat / directory

                        [[email protected]]# useradd -r tomcat --shell /bin/false
[[email protected]]# chown -R tomcat:tomcat /opt/tomcat/

Create a systemd file to start the tomcat service with the following content

                        [[email protected]]# nano /etc/systemd/system/tomcat.service
Description=Apache Tomcat 9



Save the file and run the following command to restart the daemon

                        [[email protected]]# systemctl daemon-reload

Apache Tomcat 9 setup

Let’s make the executable scripts to start the Tomcat service, otherwise it will not start

                        [[email protected]]# chmod a+x /opt/tomcat/bin/
[[email protected]]# chmod a+x /opt/tomcat/bin/

Launch Tomcat Apache and add it to startup

                        [[email protected]]# systemctl start tomcat
[[email protected]]# systemctl enable tomcat

Let’s open port 8080 in the firewall so that we can connect to the service

                        [[email protected]]# firewall-cmd --permanent --zone=public --add-port=8080/tcp
[[email protected]]# firewall-cmd --reload

Adding Users

In order to open access to Tomcat Manager, you need to edit the tomcat-users.xml file, adding the following lines to it

                        [[email protected]]# nano /opt/tomcat/conf/tomcat-users.xml
<role rolename="admin"/>
<role rolename="admin-gui"/> 
<role rolename="admin-script"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<!-- <role rolename="manager-script"/> -->
<!-- <role rolename="manager-jmx"/> -->
<!-- <role rolename="manager-status"/> -->
<user name="admin" password="password" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" />

Do not forget to change your password to a more secure one

By default, Tomcat Manager is only accessible from a browser running on the same machine as Tomcat. If you want to remove this restriction, you need to edit the context.xml file and comment out or remove the following line:

                        [[email protected]]# nano /opt/tomcat/webapps/manager/META-INF/content.xml
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127.d+.d+.d+|::1|0:0:0:0:0:0:0:1" />

Restart Tomcat

                        [[email protected]]# systemctl restart tomcat

Now, to get to our server with Tomcat, you need to type in the browser: http: // IP_address: 8080 / manager / html

Installing GeoServer

To install GeoServer, you need to download it from the official site and unpack it

                        [[email protected]]# cd /home
[[email protected]]# wget
[[email protected]]# unzip -d /opt/geoserver

Let’s transfer the necessary geoserver.war file to the webapps directory

                        [[email protected]]# mv /opt/geoserver/geoserver.war /opt/tomcat/webapps/geoserver.war

To get to our GeoServer, you need to type in the browser: http: // IP_address: 8080 / geoserver / web /

Default authorization data:

                        login: admin
pass: geoserver

If you already had GeoServer, but you forgot the login / password to access the admin panel, the password file is located here: /data/security/usergroup/default/users.xml

To change the password, you need to replace the line with the encrypted password:

                        <user enabled="true" name="admin"


<user enabled="true" name="admin" password="plain:PASSWORD"/>

Related Posts