How to install Tomcat 8.5 on remote CentOS 7 server

In the previous post I told you how I installed Java on my production server. Now it’s time to install Tomcat. There are different ways you can do it. I must warn you that the way I did it might not be the best way, because I skipped all the security related steps. So, what you are about to read is not a definitive guide to Tomcat installation (if you are looking for that kind of guide check out this article). But I think this post can be a good starting point for a complete noob who doesn’t what to overwhelm himself with too much detail right from the start. Here we’ll just focus on installing Tomcat and making it work somehow.

My first attempt

At first I tried to just

sudo yum install tomcat

But this command installed Tomcat 7, while I wanted to install the latest stable version, which is currently Tomcat 8.5.9. So I had to remove Tomcat 7 with

sudo yum remove tomcat

(Note that I am logged to my remote server as sudo user by the name of karen)

By the way, if you install Tomcat 7 this way and then don’t see the default Tomcat page in browser, you need to install some additional stuff:

sudo yum install tomcat-admin-webapps.noarch tomcat-docs-webapp.noarch tomcat-javadoc.noarch tomcat-systemv.noarch tomcat-webapps.noarch

Also don’t forget to configure your ports. More on this later.

Before making my second attempt to install Tomcat I found a video tutorial, and went through it step by step. We will go through this tutorial later in this post, but before installing Tomcat we will need to setup FTP server. I’m sure there are other ways to transmit installation file to the remote server, but we will still need the FTP server later on for uploading our apps. So why not start with FTP server?

Setting up FTP server

I used this tutorial and I installed vsftpd like this:   

sudo yum install vsftpd

sudo yum install ftp

I’m not sure if the second line was necessary, because I didn’t quite understand the tutorial. Did I need to install ftp on my local machine or was it needed on the remote server? I just thought it wouldn’t hurt to install it also, so that’s what I did.

On my local computer I have FileZilla, which I installed a long time ago, so I used it to connect to the server.

At this point you’re not going to be able to connect to the FTP server. You need to open the port 21 in the server’s firewall:

sudo firewall-cmd –permanent –add-port=21/tcp

sudo firewall-cmd –reload

Now you can open FileZilla, specify url of your server, your name and password, and try to connect. It is going to connect, but it will throw an error soon after. The reason is that the actual data is transferred through a range of ports which are all closed in your firewall. The port 21 is just for the commands. For all the data you need to open some other several hundred ports. Also you need to tell the FTP server which ports it should use.

To understand why you need to go through all these steps you can read these articles:

Lets first configure the FTP server. Open the configuration file:

sudo vi /etc/vsftpd/vsftpd.conf

Now paste these three lines:




What we did here is we enabled the passive mode (read about it in the articles above) and set the range of ports that FTP server will use for transmitting the data. We need at least several hundred ports.

After saving and exiting the file don’t forget to restart your FTP server:

sudo /bin/systemctl restart  vsftpd.service

Now we need to open the port range in the server firewall:

sudo firewall-cmd –permanent –zone=public –add-port=10100-10900/tcp

sudo firewall-cmd –reload

Finally installing Tomcat

This is how I did it. I went to the official site of Tomcat and downloaded this file:

Then, using FileZilla, I uploaded it to my server. Now the file was in my home folder on the server.

I logged in to the server and moved the file to the new folder:

sudo mkdir /opt/tomcat

sudo mv /opt/tomcat

Then I checked the md5 sum:

cd /opt/tomcat


Then I unzipped the file:

sudo unzip

Actually I couldn’t unzip it at first, because I didn’t have the necessary program, so I installed it:

sudo yum install zip unzip -y

The reason I used specifically zip file instead of tag.gz is that that’s what was used in the video tutorial. I decided to not change anything. I think tag.gz would do just as well. 

Now I set right permissions:

cd apache-tomcat-8.5.9/bin

sudo chmod 700 *.sh

It means I can execute *.sh files.

And the last step is to create a couple of links:

sudo ln -s /opt/tomcat/apache-tomcat-8.5.9/bin/ /usr/bin/tomcatup

sudo ln -s /opt/tomcat/apache-tomcat-8.5.9/bin/ /usr/bin/tomcatdown

Now I can start Tomcat like this:

sudo tomcatup

And stop it like this:

sudo tomcatdown

If you followed all the steps and started Tomcat, now you can point your browser to your_server_ip:8080. You should see the default page of Tomcat:



Leave a Reply

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