Sunday, April 05, 2009

LAMS 2.2 install on CentOS 5.2

As part of an ongoing investigation into elearning methods we are setting up a new CentOS 5.2 server running Moodle, DSpace and LAMS.

Currently the CentOS 5.2 server has installed:

httpd-2.2.3-11.el5_2.centos.4
mysql-server-5.0.45-7.el5
mysql-5.0.45-7.el5

1) Moodle 1.9 install

Moodle 1.9 is now sucessfully up and running on the new server.

Installation was relatively straightforward. The main problem I encountered with the Moodle install was that when I visited the admin page (index.php) at the end of the installation process it just produced a blank screen. It turned out that PHP5 installed with CentOS 5 did not include MySQL support!

This was solved as follows:

yum install php-mysql
service httpd restart

The index.php script ran happily after this

Also Moodle Admin > Environment came up with a couple of recommendations so I installed php-xmlrpc and php-mbstring as follows:

yum install php-xmlrpc
yum install php-mbstring
service httpd restart


2) LAMS 2.2 install

The process followed so far has been:

Edit the file /etc/my.cnf and add the READ-COMMITTED parameter as shown:

[mysqld]
transaction-isolation = READ-COMMITTED
etc...

Restart mysql using the folowing command:

service mysqld restart


Install phpMyAdmin 2.11.9.4 using cookie authentication.


As root, and in the root users home directory, download the JDK from Sun and install it using the following commands:

chmod 755 jdk-6u13-linux-i586-rpm.bin\&File\=jdk-6u13-linux-i586-rpm.bin
./jdk-6u13-linux-i586-rpm.bin\&File\=jdk-6u13-linux-i586-rpm.bin

Edit /etc/profile and set the JAVA_HOME variable as follows:

JAVA_HOME=/usr/java/jdk1.6.0_13
export JAVA_HOME
PATH=${PATH}:${JAVA_HOME}/bin
export PATH

Change the symlink for Java to point to the new location:

rm /usr/bin/java
ln -siv /usr/java/jdk1.6.0_13/bin/java /usr/bin/java

The java -version command will now produce the following output:

java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Server VM (build 11.3-b02, mixed mode)



Download and install Wildfire 2.6.2 into the root users home directory:

Wildfire can be downloaded from http://www.igniterealtime.org/builds/wildfire/wildfire_2_6_2.rpm

rpm -ivh wildfire_2_6_2.rpm
rpm -q wildfire
wildfire-2.6.2-1

The configuration of the Wildfire server is covered later in this blog posting.


As root, and in the root users home directory, download jboss using lynx and unpack jboss:

lynx http://www.jboss.org/jbossas/downloads/
cp jboss-4.0.2.tar.gz /usr/local
cd /usr/local
tar -xzvf jboss-4.0.2.tar.gz


Edit /etc/profile and set the JBOSS_HOME variable as follows:

JBOSS_HOME=/usr/local/jboss-4.0.2
export JBOSS_HOME


Now test jboss is working:

cd jboss-4.0.2
cd bin
./run.sh &

Many screens of information appear as jboss starts and eventually the following line is displayed:

10:03:41,943 INFO [Server] JBoss (MX MicroKernel) [4.0.2 (build: CVSTag=JBoss_4_0_2 date=200505022023)] Started in 16s:278ms

Use the following commands to confirm jboss is running:

nmap 127.0.0.1

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2009-04-05 10:05 BST
Interesting ports on localhost.localdomain (127.0.0.1):
Not shown: 1672 closed ports
PORT STATE SERVICE
25/tcp open smtp
80/tcp open http
443/tcp open https
631/tcp open ipp
3306/tcp open mysql
4444/tcp open krb524
8009/tcp open ajp13
8080/tcp open http-proxy


ps aux | grep jdk
root 15109 98.3 1.3 317272 106448 pts/1 Sl 10:09 0:20 /usr/java/jdk1.6.0_13/bin/java -server -Xms128m -Xmx128m -Dprogram.name=run.sh -Djava.endorsed.dirs=/usr/local/jboss-4.0.2/lib/endorsed -classpath /usr/local/jboss-4.0.2/bin/run.jar:/usr/java/jdk1.6.0_13/lib/tools.jar org.jboss.Main

Stop jboss:

./shutdown.sh -S


As root, and in the root users home directory, download LAMS using lynx and unpack the installer:

lynx http://lamscommunity.org/2.2/stable/unix/lams-unix-installer-2.2.tar.gz
tar -xxvf lams-unix-installer-2.2.tar.gz
cd lams-unix-installer-2.2

Note: The lams.properties file contains the installation settings for LAMS. It is important you get the settings in this file right. If you subsequently change lams.properties and re-run the installer you will overwrite your existing LAMS installation. Once LAMS has been installed all subsequent configuration changes must be made from and Admin login and not by editing lams.properties

Edit the lams.properties file and change the following settings (in bold):

# Installation Options

# The lamshome directory, will contain repository, temp and dump files
# Make sure this location has sufficient disk space as several files will be stored
# here during run time
LAMS_DIR=/var/opt/lams

# Username and password for the system admin for LAMS
LAMS_USER=yyyy
LAMS_PASS=xxxx

# Default language locale and text direction for LAMS, see section 3 of the readme
# Note that for English the ONLY choice supported by LAMS is en_AU
LOCALE=en_AU
LOCALE_DIRECTION=LTR


# Database name, username and password for your LAMS database
DB_NAME=lams2
DB_USER=lamsuser
DB_PASS=xxxx


# Wildfire configuration, used for chat tools. see the documentation under
# "Configuring the Chat Server" at:
# http://wiki.lamsfoundation.org/display/lams/Building+LAMS
# Make up a wildfire admin password
# Make a note of these settings as you will need them when configuring Wildfire later

WILDFIRE_DOMAIN=localhost
WILDFIRE_CONFERENCE=conference.localhost
WILDFIRE_USER=admin
WILDFIRE_PASS=zzzz


# Essential settings

# The port through which you want jboss to run
LAMS_PORT=8080

# The url you intend to use to run LAMS
# NOTE: Make sure the URL ends with a "/" or you will have problems running LAMS
SERVER_URL=http://vleinternal.bromley.ac.uk/lams/

# Where your home directory of JBoss is
# This will contain your LAMS installation
JBOSS_DIR=/usr/local/jboss-4.0.2

# The directory that contains your JDK. (Must be 1.5 or higher)
JDK_DIR=/usr/java/jdk1.6.0_13

# The location of your mysql executable (Must be 5.0 or higher)
SQL_DIR=/usr/bin

# The location of your MySql server, leave as localhost unless you are useing MySql on
# a separate server
SQL_HOST=localhost

# The port that your MySql server is running through
SQL_PORT=3306

# The URL that your jdbc driver will be running through
SQL_URL=jdbc:mysql://${SQL_HOST}:${SQL_PORT}/${DB_NAME}?characterEncoding=utf8&autoReconnect=true

# The root password to access the database
DB_ROOT_PASSWORD=xxxx


Run the lams unix installer script as follows:

./install-lams.sh

JDK_DIR is valid
MySql host is compatible with LAMS.
JBoss Directory Found

--------------------------------------------------------------------------------

WELCOME to the LAMS 2.2 unix Installer!

Please ensure you have read and accepted the license agreement before continuing

Make sure you have correctly configured the lams.properties file to your
preferred settings.

You should read the installation guide before continuing.

JAVA_HOME = /usr/java/jdk1.6.0_13

--------------------------------------------------------------------------------

LAMS requires about 117MB of space, continue with installation? (y)es, (n)o: y

--------------------------------------------------------------------------------

Do you wish to install LAMS as a Java Service Wrapper? (y)es, (n)o, (q)uit: y

The installer could not detect a suitable wrapper, please select one from below.
(1) wrapper-linux-x86-32-3.2.3
(2) wrapper-linux-x86-64-3.2.3
(3) wrapper-linux-ppc-64-3.2.3
(n) No wrapper, continue with install
(q) quit
> 1

Using LAMS database with the following parameters...
Database name: lams2
Database user: lamsuser
Database password: xxxx

Creating LAMS database.
Buildfile: ant-scripts/configure-database.xml
Database Created.

Filling database with LAMS tables

Buildfile: ant-scripts/filter-config.xml
Buildfile: ant-scripts/configure-database.xml

Done.

Database Created.

Copying lams.ear directory to /usr/local/jboss-4.0.2/server/default/deploy.

Done.

Configuring JBoss with your settings.
Buildfile: ant-scripts/configure-deploy.xml

Configuring the java Wrapper

Installing and configuring Java Service Wrapper: wrapper-linux-x86-32-3.2.3
Buildfile: ant-scripts/configure-deploy.xml
Done.

Copying lams.properties to /etc.

LAMS 2.2 Configuration completed!
Please view the README for instructions on how to run LAMS.



Getting Apache to talk to JBoss

I decided to use mod_jk instead of the deprecated mod_jk2 to link Apache and JBoss together.

As root, and in the root users home directory, download the source for mod_jk using lynx, compile and install the module:

lynx http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/source/jk-1.2.15/
tar -xzvf jakarta-tomcat-connectors-1.2.15-src.tar.gz
cd jakarta-tomcat-connectors-1.2.15-src
cd jk/native
./buildconf.sh
yum install httpd-devel
./configure --with-apxs=/usr/sbin/apxs
make
cp /root/jakarta-tomcat-connectors-1.2.15-src/jk/native/apache-2.0/mod_jk.so /usr/lib/httpd/modules

Now create the following files:
cd /etc/httpd/conf
Create the file workers.properties containing the following:

ps=/
worker.list=worker1
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1

cd /etc/httpd/conf.d
Create the file jk.conf containing the following:

#
# Mod_jk2 allows the Apache Web server to connect to application
# servers using the AJP protocol. This allows web applications to
# be integrated seamlessly into your Apache server's URI space and
# utilize Apache features such as SSL processing.
#

LoadModule jk_module modules/mod_jk.so

#
# mod_jk is configured in /etc/httpd/conf/workers.properties
#

# Where to find workers.properties
JkWorkersFile /etc/httpd/conf/workers.properties
# Where to put jk logs
JkLogFile /var/log/httpd/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Send servlet for context /lams to worker named worker1
JkMount /lams worker1
# Send JSPs for context /lams/* to worker named worker1
JkMount /lams/* worker1
#
JkMount /upload/* worker1
#
JkMount /jmx-console/* worker1

Now to start LAMS:

service lams2 start
Starting LAMS...

ps aux | grep jdk
root 20297 87.2 6.2 961780 515220 ? Sl 07:09 2:28 /usr/java/jdk1.6.0_13/bin/java -Dprogram.name=run.sh -XX:MaxPermSize=256m -Xms246m -Xmx512m -Djava.library.path=../lib -classpath ../lib/wrapper.jar:../bin/run.jar:/usr/java/jdk1.6.0_13/lib/tools.jar -Dwrapper.key=9PVMzuBXkSSobgBc -Dwrapper.port=32000 -Dwrapper.jvm.port.min=31000 -Dwrapper.jvm.port.max=31999 -Dwrapper.pid=20295 -Dwrapper.version=3.2.3 -Dwrapper.native_library=wrapper -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=10 -Dwrapper.jvmid=1 org.tanukisoftware.wrapper.WrapperSimpleApp org.jboss.Main

nmap 127.0.0.1

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2009-04-06 07:13 BST
Interesting ports on localhost.localdomain (127.0.0.1):
Not shown: 1672 closed ports
PORT STATE SERVICE
25/tcp open smtp
80/tcp open http
443/tcp open https
631/tcp open ipp
3306/tcp open mysql
4444/tcp open krb524
8009/tcp open ajp13
8080/tcp open http-proxy


Hurray LAMS is now running. :)))

It is also accessible on port 80 of the server.

According to Luke Foxton (Macquarie University) when you choose to install with the wrapper, the installer alters the run-lams.sh script so it will work with the wrapper, with the idea being that once installed, the wrapper will automatically restart lams when the system reboots. However, this means that you can no longer use the run-lams.sh script to start lams directly.

The Wildfire chat server can be configured from a Web interface once it is running.

cd /opt/wildfire/bin
wildfire start
nano /etc/rc.d/rc.local
and append the following line

/opt/wildfire/bin/wildfire start

If you intend to use an external database for Wildfire you will at this point need to set up a wildfire database in MySQL, with a user who has appropriate privileges.

Then visit 127.0.0.1:9090 from your browser to complete the configuration. Note that you will need to use the Wildfire settings from lams.properties here.



3) Moodle - LAMS integration

Please note that it is necessary to retain the LAMS v1 module that came with Moodle and just keep it hidden. I deleted this module, not thinking I would need it and then found that with a LAMS v2 activity the buttons, Open Authoring and Add a New Lesson, were missing for Course Creators and Teachers. On re-installing the LAMS v1 module and keeping it hidden these buttons reappeared!

Download and install the lamstwo module:

cd /home/ictuser/moodle/mod
lynx http://wiki.lamsfoundation.org/display/lams/Integrations
unzip lamstwo.zip
mv lamstwo.php /home/ictuser/moodle/lang/en_utf8/
rm lamstwo.zip

Then login to LAMS as administrator and go to Sys Admin > Maintain Integrated Servers
> Add a New Server

Fill in the fields in the form paying particular attention to the ID, Key and User Information URL fields. My user information field contained the following string:

http://vleinternal.bromley.ac.uk/ict/mod/lamstwo/userinfo.php?ts=%timestamp%&un=%username%&hs=%hash%

Save your changes and then visit the Moodle admin page at which point the new tables for the lamstwo module will be added to the database. Visit the Modules > Activities > LAMSv2 page and fill in the settings.

Click on the validate button and if all is well you will get the following message "These settings are valid". This means that Moodle can talk to LAMS and LAMS can talk to Moodle.

In my case validation failed and it was only with the help of Jun-Dir and some painstaking research on my part that I found out that the cause of the failure was an extra blank line at the end of Moodle's config.php script outside the closing PHP tag!