Installing Liferay 6.2 CE GA4 on CentOS 7.1 with Wildfly 8.2.0 as a service

This guide will show how to install Liferay 6.2 CE GA4 onto CentOS 7.1. Assumption is, that the mimimum version of CentOS 7.1 is installed and updated.

You manually need to adapt the standalone.xml according to the liferay documentation.

Pending for this documentation is still the java security manager setup as well as using a different user of the wildfly service (not root).

cd /tmp
wget -nv --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm
yum install -ya cifs-utils jdk*

wget -nv --content-disposition http://download.jboss.org/wildfly/8.2.0.Final/wildfly-8.2.0.Final.zip
unzip -q wildfly*.zip
mkdir wildfly
mv wildfly*/* wildfly
rm wildfly-* -Rf
export JBOSS_HOME=$(pwd)/wildfly

mkdir $JBOSS_HOME/modules/com
mkdir $JBOSS_HOME/modules/com/liferay
mkdir $JBOSS_HOME/modules/com/liferay/portal
mkdir $JBOSS_HOME/modules/com/liferay/portal/main

wget -nv --content-disposition http://sourceforge.net/projects/lportal/files/Liferay%20Portal/6.2.3%20GA4/liferay-portal-dependencies-6.2-ce-ga4-20150416163831865.zip
unzip -q liferay-portal-dependencies-*.zip
mv liferay-portal-dependencies*/*.jar $JBOSS_HOME/modules/com/liferay/portal/main

wget -nv --content-disposition http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.35.tar.gz
tar -xf mysql-connector-java*
mv mysql-connector*/mysql-connector*.jar $JBOSS_HOME/modules/com/liferay/portal/main/mysql-connector-java-bin.jar

cat > $JBOSS_HOME/modules/com/liferay/portal/main/module.xml << EOF
<?xml version="1.0"?>

<module xmlns="urn:jboss:module:1.0" name="com.liferay.portal">
    <resources>
        <resource-root path="mysql-connector-java-bin.jar" />
        <resource-root path="portal-service.jar" />
        <resource-root path="portlet.jar" />
    </resources>
    <dependencies>
        <module name="javax.api" />
        <module name="javax.mail.api" />
        <module name="javax.servlet.api" />
        <module name="javax.servlet.jsp.api" />
        <module name="javax.transaction.api" />
    </dependencies>
</module>
EOF

cat > $JBOSS_HOME/bin/server.policy << EOF
grant {
    permission java.security.AllPermission;
};
EOF

cat >> $JBOSS_HOME/bin/standalone.conf << EOF
JAVA_OPTS="\$JAVA_OPTS -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Djava.security.manager -Djava.security.policy=\$JBOSS_HOME/bin/server.policy -Djboss.home.dir=\$JBOSS_HOME -Duser.timezone=GMT -Xmx1024m -XX:MaxPermSize=256m"
EOF

wget -nv --content-disposition http://sourceforge.net/projects/lportal/files/Liferay%20Portal/6.2.3%20GA4/liferay-portal-6.2-ce-ga4-20150416163831865.war

unzip -q liferay-portal-6.2*.war -d $JBOSS_HOME/standalone/deployments/ROOT.war/

cat >> $JBOSS_HOME/standalone/deployments/ROOT.war/WEB-INF/classes/portal-ext.properties << EOF
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://db/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
#jdbc.default.username=lportal
#jdbc.default.password=lportal
liferay.home=/var/liferay
EOF

> $JBOSS_HOME/standalone/deployments/ROOT.war.dodeploy
rm -f $JBOSS_HOME/standalone/deployments/ROOT.war/WEB-INF/lib/eclipselink.jar

mkdir /var/liferay
mkdir /var/liferay/data
cat >> /etc/fstab << EOF
//fileserver/apps/liferay  /var/liferay/data  cifs  credentials=/root/.smbcredentials,uid=root,gid=root  0  0
EOF
mount /var/liferay/data
[ -f /etc/liferay/classes/portal-ext.properties ] || echo "liferay.home=/var/liferay" >> /etc/liferay/classes/portal-ext.properties

mkdir /opt
mv $JBOSS_HOME /opt
export JBOSS_HOME=/opt/wildfly

ln -s $JBOSS_HOME/bin/init.d/wildfly-init-redhat.sh /etc/init.d/wildfly
sed -i 's#/default/#/#g' /etc/init.d/wildfly
cp $JBOSS_HOME/bin/init.d/wildfly.conf /etc/
cat >> /etc/wildfly.conf << EOF
## Autoadded right parameters
#JBOSS_HOME="/usr/share/wildfly"
JBOSS_USER=root
JBOSS_MODE=standalone
STARTUP_WAIT=60
SHUTDOWN_WAIT=60
EOF

rm -f /opt/wildfly/standalone/configuration/standalone.xml
ln -s /etc/liferay/wildfly/standalone.xml /opt/wildfly/standalone/configuration/standalone.xml
rm -f /opt/wildfly/modules/system/layers/base/sun/jdk/main/module.xml
ln -s /etc/liferay/wildfly/module.xml /opt/wildfly/modules/system/layers/base/sun/jdk/main/module.xml
rm -f /opt/wildfly/standalone/deployments/ROOT.war/WEB-INF/classes/portal-ext.properties
ln -s /etc/liferay/classes/portal-ext.properties /opt/wildfly/standalone/deployments/ROOT.war/WEB-INF/classes/portal-ext.properties
firewall-cmd --permanent --add-port=8009/tcp
firewall-cmd --reload
chkconfig --add wildfly
chkconfig --level 2345 wildfly on
service wildfly start