Installing tomcat7 on freebsd

Reading Time: 2 minutes

I’ve been wondering and playing around with FreeBSD recently as well as discovering the power of free unix operating system. So long story short I have installed FreeBSD on a virtual machine so that I can well manage it. So far I would like to enhance my operating system with free stuff and I have discovered the installation of tomcat on my freebsd. So let us get started.

First of all we need to install Java. There are two options first of all to make it clear that its very easy to install OpenJDK on freebsd because of I believe licensing issues that freebsd offers openjdk from its ports and it seems very painful to install Oracle JDK on it. So I will walk along with OpenJDK depending on your preference you may install Oracle JDK as well.

To install Open JDK

pkg install openjdk

then we will install tomcat type in

pkg install tomcat7

after the installation we need to edit the users file use your favorite editor to edit the xml file located below

nano /usr/local/apache-tomcat-7.0/conf/tomcat-users.xml

find the <tomcat-users> </tomcat-users> lines and in between add the below entry

 <role rolename="manager-gui"/>
 <role rolename="manager-script"/>
 <role rolename="manager-jmx"/>
 <role rolename="manager-status"/>
 <role rolename="admin-gui"/>
 <role rolename="admin-script"/>
 <user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>

to launch the tomcat in boot we need to find the tomcat instance. Locate to the regarding path below

root@virtualbsd:~ # cd /usr/local/etc/rc.d
root@virtualbsd:/usr/local/etc/rc.d # ls

and then when you see tomcat7 instance, we are on the track. Then edit the rc.conf file

nano /etc/rc.conf

and then add the following line;


and save the file. When you restart your OS in boot tomcat7 instance will be automatically fired up!

To fastly fire up tomcat before the restart do the below command

root@virtualbsd:/usr # cd /usr/local/apache-tomcat-7.0/bin/
root@virtualbsd:/usr/local/apache-tomcat-7.0/bin # sh

then launch your favorite web browser and navigate to your server ip address you shall see the below result!



Leave a Reply

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