Installing Liferay-Tomcat bundle as a Windows Service

Hi

Here I will explain you how to install Liferay6.1(Tomcat bundle) as a Windows Service.

Assumptions:

  1. You already have the liferay 6.1 bundle downloaded (If not, download it from here).
  2. You already have a Tomcat7 server (windows zip) downloaded  (If not, download it from here).

Procedure:

  • Extract your liferay bundle and tomcat to any chosen location.

  • Copy tomcat7.exe  and tomcat7w.exe from tomcat to your liferay-portal and rename them to liferay61 and liferay61w respectively (If you wish them not to rename then leave them as is).

  • Create liferay-windows-service.bat in liferay-portal/tomcat/bin directory and copy the below content to that file
@ECHO OFF
CLS
@ECHO Liferay windows service - Instalation Script
@ECHO *

@SET "SERVICE_NAME=Liferay61"
@SET "SERVICE_DISPLAY_NAME=Liferay Portal 6.1 CE"
@SET "SERVICE_DESCRIPTION=Starts Liferay Portal 6.1 CE"

@SET "TOMCAT_DIR=D:\liferay\liferay-portal-6.1.0-ce-ga1\tomcat-7.0.23"

@SET "JRE_PATH=D:\liferay\liferay-portal-6.1.0-ce-ga1\tomcat-7.0.23\jre1.6.0_20\win"
@SET "INITIAL_MEMORY=512"
@SET "MAXIMUM_MEMORY=1024"

@ECHO *
@ECHO Setting variables ...
@ECHO JRE_PATH=%JRE_PATH%
@ECHO TOMCAT_DIR=%TOMCAT_DIR%
@ECHO INITIAL_MEMORY=%INITIAL_MEMORY%
@ECHO MAXIMUM_MEMORY=%MAXIMUM_MEMORY%
@ECHO *

@ECHO ON
@ECHO Executting command ...

liferay61.exe //IS//%SERVICE_NAME% --DisplayName="%SERVICE_DISPLAY_NAME%" --Description="%SERVICE_DESCRIPTION%" --Install="%TOMCAT_DIR%\bin\liferay61.exe" --Jvm="%JRE_PATH%\bin\server\jvm.dll" --JvmMs="%INITIAL_MEMORY%" --JvmMx="%MAXIMUM_MEMORY%" --Classpath="%TOMCAT_DIR%\bin\bootstrap.jar;%TOMCAT_DIR%\bin\tomcat-juli.jar" --StartMode=jvm --StartClass=org.apache.catalina.startup.Bootstrap --StartParams=start --StartPath=%TOMCAT_DIR% --StopMode=jvm --StopClass=org.apache.catalina.startup.Bootstrap --StopParams=stop --StopPath=%TOMCAT_DIR% --LogPath="%TOMCAT_DIR%\logs" --StdOutput="%TOMCAT_DIR%\logs\stdout.log" --StdError="%TOMCAT_DIR%\logs\stderr.log" --JvmOptions="-XX:MaxPermSize=256m;-Dfile.encoding=UTF8;-Djava.net.preferIPv4Stack=true;-Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false;-Duser.timezone=GMT;-Djava.io.tmpdir=%TOMCAT_DIR%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%TOMCAT_DIR%\conf\logging.properties;-Dcatalina.home=%TOMCAT_DIR%;-Dcatalina.base=%TOMCAT_DIR%;-Djava.endorsed.dirs=%TOMCAT_DIR%\endorsed"

  • Edit the file according to your requirements and run it.

  • Congratulations you have successfully installed Liferay 6.1 as a windows service

  • Run liferay61w to configure any settings.

Advertisements

15 thoughts on “Installing Liferay-Tomcat bundle as a Windows Service

  1. Anonymous says:

    I am facing the problem starting this service. The below is the error i am facing:
    Windows cannot start the ____________ service on local computer.
    Error 2: The system cannot find the file specified.
    Can you please help me its urgent.

    • I couldn’t infer anything from the info you provided about the error. But I can suggest you something here.
      1. Check the user you logged in as has the admin rights.
      2. Recheck the configuration and see if the tomcat and liferay-tomcat versions are in sync..

  2. Anonymous says:

    Hello i am facing a problem in running the liferay-window-service.bat file.
    I am getting the below error:
    Liferay61.exe is not recognized as an internal or external command, operable program or batch file.
    The service doesnt gets created. Please help

    • That error clearly suggests that there is no file liferay61.exe or it may not be in the classpath, check the case of file names. Also make sure the bat and exe file are in same folder i.e bin folder..

  3. Anonymous says:

    I solved the problem by removing the .exe from liferay61.exe. Also the bootstrap.jar and tomcat-juli.jar are to be added in the bin folder. And this allowed me to build the service successfully.

  4. Dhahi says:

    Dear
    Thank you very much for this information, i tried twice on Window 2012 and in both times it is working from the first time.
    Your assistance is very much appreciated

  5. Mahesh Narwade says:

    I followed the steps mentioned in this article. just need to edit service.bat file as emntioned with JRE_HOME and path variables.
    It works!

    Thanks!
    Mahesh

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s