Liferay On Resin Pro
From Resin 4.0 Wiki
Liferay on Resin Professional
How to run Liferay on Resin Professional
Intro
Liferay is an awesome platform on which to build your website. It comes with TONS of functionality out of the box; pages, wiki, blog, forum, calendar, polls, messaging, social integration, mobile device optimization, etc.
Liferay really likes to "take over" your Resin server. It integrates Resin like a component of Liferay, rather than Liferay being an application that runs in Resin... Unfortunately this means that it appears to duplicate or invalidate some of Resin Pro's advanced features for scalability and failover... (I'm still learning Liferay and will post more on this topic later.)
Install
We're going to use the Liferay Resin bundle as a starting point, but install Resin Professional and copy over some necessary files from the bundles Resin to Resin Pro.
Liferay like to write files to the PARENT of the Resin ROOT directory, so the default installation of Resin in /user/local/share/resin, /var/resin, /etc/resin, /var/log/resin won't work. You need a dedicated Liferay directory in which Resin is installed as a subdirectory.
1. Setup a database for Liferay. I'm using MySQL and created a dedicated schema called "liferay" and a user "liferay" with password "liferay".
2. Download Liferay bundled with Resin. I've downloaded Liferay Portal 6.1 Community Edition 6.1 CE GA2 bundled with Resin
molson:Downloads paul$ ls -l liferay-portal-resin-6.1.1-ce-ga2-20120731132656558.zip -rw-r--r--@ 1 paul staff 233381645 Jan 25 17:05 liferay-portal-resin-6.1.1-ce-ga2-20120731132656558.zip
3. Download Resin. I've downloaded Resin Professional 4.0.34.
molson:Downloads paul$ ls -l resin-pro-4.0.34.zip -rw-r--r-- 1 paul staff 28445825 Jan 31 06:47 resin-pro-4.0.34.zip
4. Extract the Liferay archive
molson:Downloads paul$ cd .. molson:~ paul$ unzip Downloads/liferay-portal-resin-6.1.1-ce-ga2-20120731132656558.zip
5. Change directory into the Liferay directory. There will be a Resin Open Source directory, probably an older version of Resin than you downloaded. We'll delete this later, but leave it there for now.
molson:~ paul$ cd liferay-portal-6.1.1-ce-ga2/ molson:liferay-portal-6.1.1-ce-ga2 paul$ ls -l total 24 drwxr-xr-x 3 paul staff 102 Jul 31 2012 data drwxr-xr-x 4 paul staff 136 Jul 31 2012 license -rw-r--r--@ 1 paul staff 12065 Jul 18 2012 readme.html drwxr-xr-x 30 paul staff 1020 Jul 31 2012 resin-4.0.29
6. Extract the Resin archive to this directory, so you'll now have 2 Resin installs in the Liferay directory
molson:liferay-portal-6.1.1-ce-ga2 paul$ unzip ~/Downloads/resin-pro-4.0.34.zip
7. Change to the Resin install directory and compile the Resin native libraries
molson:liferay-portal-6.1.1-ce-ga2 paul$ cd resin-pro-4.0.34/ molson:resin-pro-4.0.34 paul$ ./configure --prefix=`pwd` ... molson:resin-pro-4.0.34 paul$ make ... molson:resin-pro-4.0.34 paul$ make install
8. Change to the Resin licenses directory and copy your .license file to here
molson:liferay-portal-6.1.1-ce-ga2 paul$ cd licenses/ molson:licenses paul$ cp ~/Downloads/101011.license .
9. Change to the Resin conf directory and edit resin.properties
molson:licenses paul$ cd ../conf molson:conf paul$ vi resin.properties
10. Liferay needs a lot of memory, and in particular a lot of PermGen space. Find the jvm_args line, uncomment it, and it set similar to this (depending on your available memory)
jvm_args : -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Duser.timezone=GMT -Xmx2G -XX:MaxPermSize=1G
11. Change to the Resin webapp-jars directory
molson:liferay-portal-6.1.1-ce-ga2 paul$ cd ../webapp-jars/
12. Copy all files from the bundled Resin ext-lib directory to the Resin Pro webapp-jars directory (Newer versions of Resin use webapp-jar rather than ext-lib for shared webapp libraries)
molson:webapp-jars paul$ cp ../../resin-4.0.29/ext-lib/* .
13. Change to the Resin webapps directory and delete the ROOT webapp
molson:webapp-jars paul$ cd ../webapps/ molson:webapps paul$ rm -rf ROOT/
14. Copy all webapps from the bundles Resin webapps directory to the Resin Pro webapps directory
molson:webapps paul$ cp -R ../../resin-4.0.29/webapps/* .
15. Change to ROOT/WEB-INF directory, and edit the file resin-web.xml
molson:webapps paul$ cd ROOT/WEB-INF/ molson:WEB-INF paul$ vi resin-web.xml
16. resin-web.xml should already have "PortalLoginModule" defined. Modify resin-web.xml to create a database pool and a mail session resource. Add a <database> and a <mail> element as shown:
<web-app xmlns="http://caucho.com/ns/resin"> <authenticator type="com.caucho.server.security.JaasAuthenticator"> <init> <login-module>com.liferay.portal.security.jaas.PortalLoginModule</login-module> <password-digest>none</password-digest> </init> </authenticator> <database> <jndi-name>jdbc/LiferayPool</jndi-name> <driver type="com.mysql.jdbc.Driver"> <url>jdbc:mysql://localhost:3306/liferay?useUnicode=true</url> <user>liferay</user> <password>liferay</password> </driver> <prepared-statement-cache-size>8</prepared-statement-cache-size> <max-connections>20</max-connections> <max-idle-time>30s</max-idle-time> </database> <mail jndi-name="mail/MailSession"> <properties> mail.smtp.host=<your smtp server> mail.smtp.user=<your smtp user> mail.smtp.password=<your smtp password> mail.smtp.port=465 mail.transport.protocol=smtp mail.smtp.auth=true mail.smtp.starttls.enable=true mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory mail.imap.host=<your imap server> mail.imap.port=993 mail.store.protocol=imap </properties> </mail> </web-app>
17. Change to the classes directory and create a new file named portal-ext.properties
molson:WEB-INF paul$ cd classes/ molson:classes paul$ vi portal-ext.properties
18. Add the following properties to portal-ext.properties to tell Liferay about the database and mail resources you configured through Resin:
jdbc.default.jndi.name=jdbc/LiferayPool mail.session.jndi.name=mail/MailSession
19. Resin is now configured, you can delete the bundled Resin directory
molson:classes paul$ cd ~/liferay-portal-6.1.1-ce-ga2/ molson:liferay-portal-6.1.1-ce-ga2 paul$ ls -l total 24 drwxr-xr-x 3 paul staff 102 Jul 31 2012 data drwxr-xr-x 4 paul staff 136 Jul 31 2012 license -rw-r--r--@ 1 paul staff 12065 Jul 18 2012 readme.html drwxr-xr-x 30 paul staff 1020 Jul 31 2012 resin-4.0.29 drwxr-xr-x 35 paul staff 1190 Feb 3 13:46 resin-pro-4.0.34 molson:liferay-portal-6.1.1-ce-ga2 paul$ rm -rf resin-pro-4.0.34/
20. Startup Resin
molson:liferay-portal-6.1.1-ce-ga2 paul$ ./resin-pro-4.0.34/bin/resinctl start Resin/4.0.34 launching watchdog at 127.0.0.1:6600 resinResin/4.0.34 started -server 'app-0' with watchdog at 127.0.0.1:6600
21. Tail the Liferay log until you see Liferay started. This will take a while the 1st time, since Liferay has to create and populate the database.
molson:liferay-portal-6.1.1-ce-ga2 paul$ tail -f logs/liferay.2013-02-03.log
(you should see) 14:07:16,395 INFO [resin-24][ReleaseLocalServiceImpl:84] Create tables and populate with default data
22. Open a browser window to http://localhost:8080/. (Liferay has some cool way of automatically popping up a browser window, at least for me on OSX with Chrome, not sure how it does that!)
23. You can now proceed with the configuration wizard. Notice that if you did the database configuration right, the Database section should already show "JDBC Default JNDI Name jdbc/LiferayPool".