Installing Apache Tomcat 8 on a Raspberry Pi

On my Raspberry Pi I have already installed Apache 2 HTTP server and this article does a basic install and configuration of Tomcat. In this case I have chosen to simply install and run the Tomcat software as the default ‘pi’ user on my system just for demonstration purposes, however you may choose to favour a more ‘production ready’ build by creating a dedicated service account to allow finer-grained operational control.
Firstly, update all installed packages:
sudo apt-get update
Confirm that Java is already installed:
pi@pi /usr/bin $ java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode)
Log in to the home directory for the pi user and download the desired release of Tomcat:
--2015-06-19 20:59:25--
Resolving (
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9076980 (8.7M) [application/x-gzip]
Saving to: `apache-tomcat-8.0.23.tar.gz'100%[==========================================================>] 9,076,980    463K/s   in 16s2015-06-19 20:59:42 (539 KB/s) - `apache-tomcat-8.0.23.tar.gz' saved [9076980/9076980]</div>
Extract the zipped tarball:
tar xvf apache-tomcat-8.0.23.tar.gz
Add the following user XML element as the last child of the tomcat-users parent element of ~/apache-tomcat-8.0.23/conf/tomcat-users.xml (this creates an admin account called “system” who’s password is “raspberry”):
<user username="system" password="raspberry" roles="manager-gui"/>

Change the directory permissions on the following directorys, since by default, the pi Linux user cannot write to them (I believe that this step is not needed from version 8.0.24 onwards):

cd ~/apache-tomcat-8.0.23/work/Catalina
sudo chgrp -R pi localhost
sudo chmod 755 localhost
sudo chmod 775 ./localhost/docs
sudo chmod 775 ./localhost/examples
sudo chmod 775 ./localhost/manager
sudo chmod 775 ./localhost/ROOT
sudo chmod 775 ./localhost/host-manager
Add an executable startup script called tomcat to the /etc/init.d directory, which has the following contents:
# /etc/init.d/tomcat
# starts the Apache Tomcat service
# Provides:          tomcat
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# X-Interactive:     true
# Short-Description: Start/stop tomcat application server

case "$1" in
  if [ -f $CATALINA_HOME/bin/ ];
    echo $"Starting Tomcat"
    /bin/su pi $CATALINA_HOME/bin/
  if [ -f $CATALINA_HOME/bin/ ];
    echo $"Stopping Tomcat"
    /bin/su pi $CATALINA_HOME/bin/
  echo $"Usage: $0 {start|stop}"
  exit 1
Change the permissions of the tomcat startup script and use the update-rc.d command to add the appropriate links to the /etc/rc?.d directories:
sudo chmod 755 /etc/init.d/tomcat
sudo update-rc.d tomcat defaults
update-rc.d: using dependency based boot sequencing

Test that the tomcat server starts:

sudo /etc/init.d/tomcat start
$Starting Tomcat
Using CATALINA_BASE:   /home/pi/apache-tomcat-8.0.23
Using CATALINA_HOME:   /home/pi/apache-tomcat-8.0.23
Using CATALINA_TMPDIR: /home/pi/apache-tomcat-8.0.23/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /home/pi/apache-tomcat-8.0.23/bin/bootstrap.jar:/home/pi/apache-tomcat-8.0.23/bin/tomcat-juli.jar
On a web client, point you browser at:
http://"Raspberry Pi IP Address":8080
Screen Shot 2015-06-19 at 21.10.45
Test that the tomcat server stops:
sudo /etc/init.d/tomcat stop
$Stopping Tomcat
Using CATALINA_BASE:   /home/pi/apache-tomcat-8.0.23
Using CATALINA_HOME:   /home/pi/apache-tomcat-8.0.23
Using CATALINA_TMPDIR: /home/pi/apache-tomcat-8.0.23/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /home/pi/apache-tomcat-8.0.23/bin/bootstrap.jar:/home/pi/apache-tomcat-8.0.23/bin/tomcat-juli.jar
Finally, reboot the system and the Tomcat application server should now start automatically on startup, and likewise when the system shuts down.
It is noteworthy that although I already have the Apache2 HTTP server installed, Tomcat does not actually require this as a pre-requisite; it starts its own HTTP listener on TCP/IP port 8080 as configured in this example (I have proven this by stopping my Apache2 HTTP server and observing that Tomcat works as expected!).

15 thoughts on “Installing Apache Tomcat 8 on a Raspberry Pi”

  1. Thanks for this info, it worked for me.

    One correction: I got an error due to a corrupt /etc/init.d/tomcat. It turned out that you miss-copied the ending comment: I used


    export CATALINA_HOME=”/home/pi/apache-tomcat-8.0.24″

    Two questions: as I’m a complete newbie to Raspbian/Debian, do you know how to build a package I can install in the root directory? I’m using Arch Linux right now and that’s the way to go on Arch: build a package and install it using the package manager. Not a big deal, as everything works fine now, even just after boot-up I can access 192.168.x.x:8080.

    Second, how do I set up Tomcat to listen to port 80? I followed several of the steps in but they mention to change /etc/default/tomcat7 as well. Of course, as I unpacked all files in /home/pi, there is no /etc/default/tomcat8 where I can set AUTHBIND=yes.


    1. Thanks for the correction Marcel. I’ll look into your questions later but it will be next week before I can get back to you. I’m not familiar with the raspbian package manager for doing any operations other than installs and updates.


    2. Hi Marcel,
      I tried getting tomcat 8 to run on port 80 but could not get this to work, and as it isn’t a configuration I wish to run with I won’t spend too much time on it (I can’t see a simple solution). The root of the problem seems to be that IF you wish to run tomcat using a non-root user then access to privileged ports (< 1024) is not allowed by default. The use of authbind seems non-trivial with tomcat 8.

      Perhaps there's a way to use mod proxy to forward connections from a separate apache listener on port 80 on to the tomcat port 8080? Just a thought. Keep in-touch!



  2. I always get this error can you help me?
    pi@raspberrypi /etc/init.d $ sudo update-rc.d tomcat defaults
    update-rc.d: using dependency based boot sequencing
    insserv: script tomcat is not an executable regular file, skipped!


    1. Hi Aaron. Its probably because your tomcat file is not executable (I didn’t add this detail). I’d suggest running the following command:

      sudo chmod 755 /etc/init.d/tomcat

      …this will make the tomcat file executable by any system user on your Pi. Now continue and re-run the update-rc.d command.

      Hope this helps?


    1. Hello David. I looked into this and found that the repository doesn’t contain the 8.0.30 distribution (at the time of writing), but I did locate it in The command used to download was:


      Once 8.0.30 was installed I had the same observation as yourself in that the directory structures seem to have changed since 8.0.23 (I believe the change actually happened in 8.0.24). I did manage to get the 8.0.30 installation up and running however, and did not experience the same permissions issues as I did previously using 8.0.23 – hence there was no need to issue chmod/chgrp commands.

      Hope this helps…Tom


  3. I’ve managed to install Apache 8.0.30 on my Raspberry Pi 2 with success. The steps to deal with the localhost didn’t happen for me, as I was able to start the server. The one thing to mention is that editing the tomcat-users.xml file – you might see a list of users and add the new line in that same area. If so, be aware of the comments – after removing the comment lines and stopping/starting, I was able to get into the “Server Status”.


  4. Thanks for this I need to learn this for work and many other tutorials have not worked
    Now sorted and ready for the next stage 🙂


    1. Hi Rob. The Tomcat server uses a different HTTP listener by default. This is evident because Tomcat keeps on working when you shut down the Apache2 HTTP server. If you try to use the .htaccess file on Apache2 to re-direct an HTTPS connection to Tomcat (listening on port 8080) this will NOT work, and one reason for this is that HTTPS uses port 443 by default. I would expect that if you wanted to use HTTPS on Apache2 as a listener for Tomcat then it might work if you set up Apache2 as a proxy server which terminates the inbound HTTPS connection, and then re-initiates the request to Tomcat on port 8080.

      Because this post is quite old now (and Tomcat 9 is now available), I don’t intend to explore this myself.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s