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 likes 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 now
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 to this directory
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. Copy your Resin .license file to the licenses directory
molson:resin-pro-4.0.34 paul$ cp ~/Downloads/101011.license licenses/
9. Edit conf/resin.properties
molson:resin-pro-4.0.34 paul$ vi conf/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. Create a directory named "app-inf" (in the Resin root directory, which should be your current directory if you're following along)
molson:resin-pro-4.0.34 paul$ mkdir app-inf/
12. Copy all files from the Liferay bundled Resin ext-lib/ directory to the new app-inf/ directory. This is important. Liferay needs a shared classloader to find themes and plugins. "app-inf/" is a special directory that the "app" cluster knows to use as a shared classloader.
molson:resin-pro-4.0.34 paul$ cp ../resin-4.0.29/ext-lib/* app-inf/
13. Change to the Resin webapps directory and delete the ROOT webapp
molson:resin-pro-4.0.34 paul$ cd webapps/ molson:webapps paul$ rm -rf ROOT/
14. Copy all webapps from the bundled 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 by adding <database> and a <mail> elements 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. Delete the bundled tmp and work directories if they exist
molson:WEB-INF paul$ rm -rf tmp/ work/
18. Create and edit a new file in the classes directory named portal-ext.properties
molson:WEB-INF paul$ vi classes/portal-ext.properties
19. Add the following properties to classes/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
20. Resin Pro is now configured, so you can delete the Liferay bundled Resin
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-4.0.29/
21. Startup Resin Pro
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
22. 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
23. 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!)
24. 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".