The applications that are being developed with Java technology are still booming. Although other languages look modern with advanced features like GoLang, it is true that even Java is talking about. Especially in quite productive and large environments where they can not afford to improvise. In this sense, in order for these applications to be focused mainly on the web, it is necessary to install a server like Tomcat. Therefore, in this tutorial post, you will learn how to install Apache Tomcat on CentOS 8. Do not miss it.
Apache Tomcat
We could easily define Apache Tomcat as a web server with exclusive support for Servlets and JSP applications. This is similar to Apache or Nginx with HTML or PHP. So, imagine a large number of server-side applications that use Java. Everyone at the end must use software like Tomcat.
Also, Tomcat has a big advantage in its license. It is open-source and very permissive. You can use it in purely professional projects or in educational and personal projects. With a well-maintained code, Tomcat is a leader in its sector.
That’s why we are going to install it on CentOS 8.
Install Apache Tomcat on CentOS 8
Apache Tomcat does not come by default in the official repositories of the distribution, so it must be downloaded and installed manually. The advantage of this method is that we can have the latest stable version at the time of installation.
The first step is to update your CentOS 8 server. To do this, connect to it using SSH. In its defect, opens a terminal session, if it is a personal computer.
:~$ su
:~# dnf update
With this, you will have the latest security patches in the system. This makes it a more secure and stable system.
Then you need to install Java 1.8. The good thing is that it comes in the repositories, then, the installation is achieved with the following command:
:~# dnf install java-1.8.0-openjdk-devel
After this, make sure wget
is installed because we will use it to download Apache Tomcat.
:~# dnf install wget
Then, download Apache Tomcat.
:~# cd /opt/
:~# wget http://mirrors.advancedhosters.com/apache/tomcat/tomcat-8/v8.5.46/bin/apache-tomcat-8.5.46.zip
Of course, you can use another mirror to download it.
Then, unzip the file and create a new symbolic link to the folder.
:~# unzip apache-tomcat-8.5.46.zip
:~# ln -s /opt/apache-tomcat-8.5.46 /opt/tomcat
To avoid problems in running Tomcat, it is better to add a user to the system and make it the owner of the Tomcat folder.
:~# useradd tomcat
:~# chown -R tomcat:tomcat /opt/apache-tomcat-8.5.46
It is recommended to use Tomcat as a system service. To do this we will have to manually create it:
:~# nano /etc/systemd/system/tomcat.service
And add the following:
[Unit]
Description=Tomcat
After=syslog.target network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
ExecStart=/opt/tomcat/bin/catalina.sh start
ExecStop=/opt/tomcat/bin/catalina.sh stop
[Install]
WantedBy=multi-user.target
For changes to take effect, services must be recharged. Then, give permission for Tomcat binaries to run. And to access the web interface that can serve other servlets and applications, it is necessary to open port 8080 in the firewall.
:~# systemctl daemon-reload
:~# chmod +x /opt/tomcat/bin/*.sh
:~# firewall-cmd --zone=public --add-port=8080/tcp --permanent
success
:~# firewall-cmd --reload
success
Finally, it starts the service and checks its status to confirm that everything is in order. If you want you can make Tomcat start with the system.
:~# systemctl start tomcat
:~# systemctl enable tomcat
:~# systemctl status tomcat
Now, open your web browser and go to http://your-server:8080
. You will see something like this.
And that is it.
Conclusion
In this post, you have learned how to install Apache Tomcat on CentOS 8. With some requirements but the program is powerful enough to serve JSP applications for the web. With pretty good performance and even better documentation. It remains to make the most of it.
Please share this post with your friends and join our Telegram channel.