Install Tomcat 8 In FreeBSD 10/10.1

About Apache Tomcat

From Wikipedia,

Apache Tomcat is an open source web server and servlet container developed by the Apache Software Foundation (ASF). Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems, and provides a pure Java HTTP web server environment for Java code to run in. In the simplest config Tomcat runs in a single operating system process. The process runs a Java virtual machine (JVM). Every single HTTP request from a browser to Tomcat is processed in the Tomcat process in a separate thread.

My testbox details:

root@Freebsd-unixmen:~ # uname -a
FreeBSD Freebsd-unixmen 10.1-RELEASE-p6 FreeBSD 10.1-RELEASE-p6 #0: Tue Feb 24 19:00:21 UTC 2015 

root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
root@Freebsd-unixmen:~

This article has been edited from old article about install apache 7 on freebsd 9.3

Install Tomcat 8 In FreeBSD 10

I was trying to install from the ports (/usr/ports/www/tomcat7 ) then i got many issues, finally i stopped the installation and started with the pkg tool.

Now, lets start:

root@Freebsd-unixmen:~ # pkg   install tomcat8
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100%    944 B   0.9kB/s    00:01    
Fetching packagesite.txz: 100%    5 MiB 486.0kB/s    00:11    
Processing entries: 100%
FreeBSD repository update completed. 24086 packages processed
The following 5 packages will be affected (of 0 checked):

New packages to be INSTALLED:
        tomcat8: 8.0.18
        openjdk: 7.76.13_1,1
        java-zoneinfo: 2015.a
        javavmwrapper: 2.5
        jakarta-commons-daemon: 1.0.15

The process will require 165 MiB more space.
57 MiB to be downloaded.

Proceed with this action? [y/N]:

Configuration

This OpenJDK implementation requires fdescfs(5) mounted on /dev/fd and procfs(5) mounted on /proc for some functionality.

If you have not done it yet, please do the following:

mount -t fdescfs fdesc /dev/fd
mount -t procfs proc /proc

To make it permanent, you need the following lines in /etc/fstab:

fdesc   /dev/fd         fdescfs         rw      0       0
proc    /proc           procfs          rw      0       0

Now, Tomcat is ready to start. Before that lets edit the user files to add users/admins and managers.

Edit the users file (my example file):

vim  /usr/local/apache-tomcat-8.0/conf/tomcat-users.xml
<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">


<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"/>


</tomcat-users>

Lets start Tomcat

root@FreeBSd9:/usr/ports/www/tomcat7 # cd /usr/local/apache-tomcat-8.0/bin/

root@Freebsd-unixmen:/usr/local/apache-tomcat-8.0/bin # ./startup.sh 
Using CATALINA_BASE:   /usr/local/apache-tomcat-8.0
Using CATALINA_HOME:   /usr/local/apache-tomcat-8.0
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.0/temp
Using JRE_HOME:        /usr/local
Using CLASSPATH:       /usr/local/apache-tomcat-8.0/bin/bootstrap.jar:/usr/local/apache-tomcat-8.0/bin/tomcat-juli.jar
Tomcat started.
root@Freebsd-unixmen:/usr/local/apache-tomcat-8.0/bin # 

Check if the port 8080 listening

root@Freebsd-unixmen # netstat -an | grep 8080
tcp46      0      0 *.8080                 *.*                    LISTEN

Now, navigate to http://ip:8080 or http://hostname:8080.

 apache-freebsd

tomcat-managerDone!