Install Apache Tomcat 8.5 on CentOS 7

Scenario: Install Apache Tomcat 8.5 on CentOS/RHEL 7

STEPS:
1) This scenario using Oracle Java. Login as root user then install Oracle Java.

2) Create tomcat service account

3) Download Apache Tomcat 8.5.33

4) Extract and set chown to /opt/tomcat8.5

5) Controlling Apache Tomcat
– Manual
Apache Tomcat can be started and stopped by the script which comes with the package.

Start the Apache Tomcat. You will get the following output.

Stop the Apache Tomcat.

– Setup Tomcat service Systemd
We can also configure systemd to start the Tomcat service. Skip the below step in case you do not want to use systemd for managing Tomcat service.

Tomcat’s systemd service file requires java location. So, run the following command to list the java versions available on your system.

Create a tomcat systemd service file like below,
# vi /etc/systemd/system/tomcat.service

Reload systemd daemon.
# systemctl daemon-reload

To start the Tomcat service; run:
# systemctl start tomcat

Check the status of Tomcat, run:
# systemctl status tomcat

Enable the auto start of Tomcat service on system start, run:
# systemctl enable tomcat

To stop the Tomcat service; run:
# systemctl stop tomcat

To disable the auto start of Tomcat service on system start, run:
# systemctl disable tomcat

Setup Firewall to allow port 8080
# firewall-cmd --permanent --add-port=8080/tcp
# firewall-cmd --reload

Configure admin password to login Tomcat manager.
# vi /opt/tomcat/conf/tomcat-users.xml

Configure to allowed login to Tomcat manager from remote hosts.
For security reason, Web and Host Manager is accessible only from localhost, i.e., from the server itself.
If you want to access Web and Host manager from remote systems, then you need to add your source network in allow list. To do that, edit the below two files.

# vi /opt/tomcat8.5/webapps/manager/META-INF/context.xml
# vi /opt/tomcat8.5/webapps/host-manager/META-INF/context.xml

Update the below line on both files with source IP from which you’re accessing the Web and Host Manager. .* will allow everyone to have access to Web and Host manager.

OR

You can also allow part of your network only. For example: To allow 10.20.0.0/24 network only, you can use the below values.

Restart the Tomcat service.
# systemctl restart tomcat

Access Tomcat

Reference:
https://www.itzgeek.com/how-tos/linux/centos-how-tos/install-apache-tomcat-8-on-centos-7-rhel-7.html


Related posts:

Leave a Reply

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