Liferay hosting with private Java and cPanel or VPS

Liferay 6 with private Java on shared server install is simple as you will see below. Yet Liferay comes with many features and thus needs quite much RAM. Your other option is a VPS but there you need to care for memory for all running components. We show 2 Liferay hosting scenarios below.

If you want to have all typical shared server services like cPanel, FTP, mail, SQL and private JVM with Tomcat and Liferay use our Java hosting Tomcat Pro package (1GB heap). As per its developers this amount of RAM ‘is perfectly reasonable for a moderately sized machine or a developer machine‘. Here comes idle Liferay JVM memory usage graph:

liferay memory usage

If you want to manage your own server then get a VPS package where we will optionally prepare Java, application server, SQL database,  Liferay and other software for you. You can also perform the installs by yourself. Liferay on a VPS will be described later in this article. Liferay can also run on Jetty, JBoss and Glassfish if you prefer any of these application servers.

This is copy and paste style tutorial. We are using liferay-portal-tomcat bundle here as it allows for fastest installation. We will use currently newest Liferay 6.2 GA3.

Private Liferay in cPanel environment (private Java on shared server)

As is based on Tomcat 7.0.42, please first make sure your Tomcat version is set to 7.0.42 in Java Control panel (change it if necessary and relogin to SSH if you are currently logged in).

1. Get the Tomcat Lifreray bundle, unzip it and move to a temporary directory with a short name

mv liferay-portal-6.2.0-ce-ga1/tomcat-7.0.42 tomcat

mysql-connector-java-5.1.23-bin.jar (mysql.jar) is already included in bundeled Tomcat’s lib/ext directory so there’s no need to add it.

2. Reset to not include parameters provided by our environment and controlled by Java Control Panel

echo 'CATALINA_OPTS="$CATALINA_OPTS -Dfile.encoding=UTF8 -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false"' > tomcat/bin/

3. Copy server.xml and tomcat-users.xml from your existing Tomcat (created by Java Control Panel). This will ensure your Liferay Tomcat will use correct ports and Tomcat Manager/Admin access will work as expected. Also set connectors to use UTF-8 encoding.

cp ~/appservers/apache-tomcat-7.0.42/conf/server.xml ~/tomcat/conf
cp ~/appservers/apache-tomcat-7.0.42/conf/tomcat-users.xml ~/tomcat/conf
sed -i.bak 's/<Connector /<Connector URIEncoding="UTF-8" /g' ~/tomcat/conf/server.xml

4. Stop and replace our Tomcat with Liferay’s Tomcat. Also cleanup the temporary directory.

rm -rf ~/appservers/apache-tomcat-7.0.42
mv ~/tomcat ~/appservers/apache-tomcat-7.0.42
rm -rf ~/tomcat

5. Start new Tomcat and access Liferay Wizard at your domain or alias root URL. We will need to configure MySQL database there. Optionally (later) you can set local or remote email account that will be used for sending email. If you do not configure outgoing email Liferay will send email using its internal mechanism. [~]# js
Using CATALINA_BASE:   /home/user/appservers/apache-tomcat-7.0.42
Using CATALINA_HOME:   /home/user/appservers/apache-tomcat-7.0.42
Using CATALINA_TMPDIR: /home/user/appservers/apache-tomcat-7.0.42/temp
Using JRE_HOME:        /opt/jdk1.7.0_45
Using CLASSPATH:       /home/user/appservers/apache-tomcat-7.0.42/bin/bootstrap.jar:/home/liferayj/appservers/apache-tomcat-7.0.42/bin/tomcat-juli.jar
Using CATALINA_PID:    /home/user/

Liferay_hosting_config1On the Wizard screen click ‘Change’ besides ‘Default Database (Hypersonic)’ as we will use MySQL. Login to your cPanel and create new MySQL database user_lportal, new database user user_lportal and assign one to the other with all privileges. In real scenario
user_ prefix will contain your hosting username.

Use the database credentials in the form. JDBC URL will look similar to (again replace user with your hosting username):



Click ‘Finish Confguration’. You will see ‘Liferay is being installed. This may take a few minutes’. And next message will be: ‘Your configuration was saved successfully. The configuration was saved in /home/user/appservers/’

liferay_hosting_config3Go to the Portal, read and accept Usage Terms, change password, set password hint and you are set. Now you may finetune and configure the portal by following the guides ‘Review our Quick Start Guide for an overview of Liferay’s features.’ and ‘Read the official Liferay User Guide for detailed information about setting up and configuring Liferay.’ referenced on main portal page.

Liferay Performance Tuning

Liferay was never a master of speed. It’s user friendliness requires processing power an resources. You carefully should read and apply any tweaks possible.

Common tweaks that can improve performance are:

  • increase JVM memory limit especially if you see memory usage nears it or you see high activity of JVM Garbage Collector. You can view memory usage directly in portal or use our Java Control Panel graphs or connect with a monitoring tool like jconsole or jvisualvm. Contact us for advice and quote for the upgrade.
  • add Garbage Collector flags in your (we are overwriting our initial settings):
echo 'CATALINA_OPTS="$CATALINA_OPTS -Dfile.encoding=UTF8 -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=20 -XX:ParallelGCThreads=8"' > $CATALINA_HOME/bin/
  • when in production mode, create/update webapps/ROOT/WEB-INF/classes/ with the following content:
cat >> $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/<<EOF
  • disable unused servlet filters. For the beginning try disabling the following ones:
cat >> $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/<<EOF

You can extract filter list from with:

unzip -c $CATALINA_HOME//webapps/ROOT/WEB-INF/lib/portal-impl.jar | grep com.liferay.portal.servlet.filters
  • remove uneeded portlets from webapps
  • enable Tomcat APR native library – it is enabled by default but recheck in Java Control Panel to be sure. In Tomcat log you should see a line similar to ‘INFO: Loaded APR based Apache Tomcat Native library 1.1.27 using APR version 1.4.6‘.

Liferay in VPS environment

In this kind of hosting you get Java, application server, database and any requested software preinstalled but you need to ensure the VPS RAM size ordered is enough to hold all running components. This is different from shared Java hosting where you only care for JVM heap and PermGen limits.

Install instructions to come…

Leave a Reply

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

× three = twenty seven

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>