In this post, I will be documenting the process of running Apache Tomcat on Raspberry Pi 2.
Before we start installing Tomcat, it would be good to do a update.
sudo apt-get update
After the update, verify that you have java 8 installed. At this stage if everything is going correctly, you should already have java 8 installed.
Now we will start downloading Apache Tomcat via wget
cd /opt wget http://www.us.apache.org/dist/tomcat/tomcat-9/v9.0.0.M8/bin/apache-tomcat-9.0.0.M8.tar.gz tar xzf apache-tomcat-9.0.0.M8.tar.gz mv apache-tomcat-9.0.0.M8 tomcat9
Now that tomcat is downloaded and extracted from the zip to the respective location. Before we process to the next step, we need to get bash on evaluated permission by typing the below
With that, we could proceed to set the environment variable.
echo 'export CATALINA_HOME='/opt/tomcat9'' >> /etc/environment echo 'export JAVA_HOME='/usr/lib/jvm/java-8-oracle'' >> /etc/environment echo 'export JRE_HOME='/usr/lib/jvm/java-8-oracle/jre'' >> /etc/environment source ~/.bashrc
Next we will need to perform a set up of the various user accounts for using the gui management.
You would have to go to conf/tomcat-users.xml and added in the below. Replace _SECRET_PASSWORD_ with your secured password.
<pre><!-- user manager can access only manager section --> <role rolename="manager-gui" /> <user username="manager" password="_SECRET_PASSWORD_" roles="manager-gui" /> <!-- user admin can access manager and admin section both --> <role rolename="admin-gui" /> <user username="admin" password="_SECRET_PASSWORD_" roles="manager-gui,admin-gui" /></pre>
Once that is done, you could launch tomcat by doing the below
cd /opt/tomcat9 ./bin/startup.sh
You should now see something like
Using CATALINE_BASE: /opt/tomcat9 Using CATALINE_HOME: /opt/tomcat9 ...
Verify that tomcat is running by going to the browser and point to http://localhost:8080
It is also important to go into /conf/server.xml to change the port that tomcat listen to from 8080 to 80 if that is what you requires on your client side.