We used Liferay on Apache Tomcat, so it has to be installed first. Tomcat requires Java, but we did not want to use sun-jdk, mostly because of the fact that there are so many archives needed to download manually in order to install it on FreeBSD.
We used java/diablo-jdk16 port, which required only to download two packages manually.

Install Java

# cd /usr/ports/java/diablo-jdk16
# make install clean
Please access
 with a web browser and "Accept" the End User License Agreement for
 "Caffe Diablo 1.6.0".
 Please open
 in a web browser and follow the "Download" link for
 "JDK DST Timezone Update Tool - 1_3_45" to obtain the
 time zone update file,
 Please place the downloaded file(s) in /usr/ports/distfiles.

Accept, download, build and install.
Unfortunately all Java ports install bunch of X11 related packages. And that is even when WITHOUT_X11=yes is set in /etc/make.conf. There has been many mailing threads in the net about this, but every port has something like USE_XORG+= xi xp xt xtst in their Makefile, because AWT uses those libs, so there is nothing reasonable to do about it.

Install Tomcat

# cd /usr/ports/www/tomcat7# make install clean

If you do not install Java first, it defaults to java/sun-jdk.

Configure Tomcat Startup

The FreeBSD port installs all the files into the /usr/local/apache-tomcat-7.0. Since I don’t like the idea of having all the temporary files (Tomcat’s temp and log directories) in my /usr partition, I decided to move them to /var instead.

# mkdir /var/log/tomcat
# chown www:www /var/log/tomcat

Now set up the proper variables in /etc/rc.conf:

tomcat7_catalina_log=">> /var/log/tomcat/catalina.out 2>&1"

Liferay needs the -XX:MaxPermSize=256M otherwise Tomcat will run out of memory when initializing the Liferay’s database.

Enable Access to Admin Console

By default there are no users which are allowed access to Tomcat’s web console located under http://domain.tld:8080/manager/html and http://domain.tld:8080/host-manager/html.
Edit /usr/local/apache-tomcat-7.0/conf/tomcat-users.xml:

<role rolename="manager-gui" />
<role rolename="admin-gui" />
<user username="tomcat" password="my_password" roles="manager-gui,admin-gui" />

Now start the Tomcat from /usr/local/etc/rc.d/tomcat7. The default website should be displayed on port 8080.

Install Liferay

Download the war-file from Liferay Download section. Install the package into Tomcat. We decided to copy the file into the Tomcat’s /usr/local/apache-tomcat-7.0/webapps directory. The server instance found it and extracted it automatically. The admin console should display the Liferay webapp in stopped state. Starting it will fail.
Liferay needs some external libraries to function properly. Although there is a link in their website where the support libraries can be downloaded, some of them still seem to be missing from that archive. So it will fail again even with the Tomcat Bundle installed. The solution for us was to download the entire Liferay Tomcat package from the main download page.
Extract it, and copy the whole tomcat7/lib/ext directory to /usr/local/apache-tomcat-7.0/lib.
Now edit the /usr/local/apache-tomcat-7.0/conf/ file to instruct Tomcat to load all the JAR-files from that directory as well:


Note that on FreeBSD the base directory is stored in ${catalina.base}. The Liferay archive has the same common.loader line with the variable ${catalina.home} which will not reference to proper location.

Set Up Liferay Environment

Since Liferay is running on Tomcat as one of the webapps with the root context of /liferay, the URL suffix must be specified in Liferay’s configuration file. Otherwise the links generated by it will not point to proper location.
We also configured Liferay’s working directory where it can put all the files it generates.
So create the working directory:

# mkdir /srv/liferay
# chown www:www /srv/liferay

Then create Liferay’s preferences file /usr/local/apache-tomcat-7.0/webapps/liferay/WEB-INF/classes/


Now start the Liferay webapp from the admin console. The catalina.log should show what’s going on. It will take some time to create the initial database but eventually the http://domain.tld:8080/liferay/ should display the basic configuration dialog for initial setup.