Sunday, February 12, 2006

LAMS 1.0.x installation procedure on CentOS 4


Written by Clive Gould. (To contact Clive please use this messages form. Our Linux training website can be reached by clicking here)

Please contact me using the above form if you find anything in this blog which is unclear or inaccurate and I'll be happy to put it right.

Menu

1) LAMS 1.0.1 installation procedure
2) LAMS 1.0.2 installation procedure
3) Installing LAMS 1.0.2 alongside DSpace
4) Sorting out 400, 403 and 404 errors
5) Moodle Lams Integration Error with config.php


1) LAMS 1.0.1 installation procedure (July 2005)

i) Introduction

I spent some time getting LAMS 1.0.1 (Learning Activity Management System) to work on a CentOS 4 Linux platform.

The actual procedure turned out to be quite straightforward, but was complicated along the way by confusing documentation and mistakes I made. The reason I chose CentOS 4 at the time was mainly because it had mysql 4 pre-installed, which Fedora Core 3 did not.

I did not realise that the LAMS installer Redhat script would take care of everything for me so went about things the "hard way" by following the custom installation procedure in the LAMS documentation. This blog is a historical document and explains the process I went through. If you are using this as an install guide, you can save yourself a lot of time and heartache by reading the entire blog BEFORE beginning your installation!


ii) Historical Installation Procedure

All the following operations were carried out as root.

Firstly I installed the sdk. I downloaded the executable rpm.bin from Sun. I had first to download the rpm.bin then chmod it and run it to extract the rpm. I then installed the sdk in /usr/java by using the command:

rpm -ivh j2sdk1.4.2_08.rpm


I then appended paths to /etc/profile as follows:.

JAVA_HOME=/usr/java/j2sdk1.4.2_08
export JAVA_HOME
PATH=${PATH}:${JAVA_HOME}/bin
export PATH


I started started mysql and checked the version number as shown below:

[root@cc ~]# service mysqld start
Initializing MySQL database: [ OK ]
Starting MySQL: [ OK ]


[root@cc ~]# mysqladmin version
mysqladmin Ver 8.41 Distrib 4.1.10a, for redhat-linux-gnu on i686
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Server version 4.1.10a
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 29 sec

Threads: 1 Questions: 2 Slow queries: 0 Opens: 11 Flush tables: 1
Open tables: 0 Queries per second avg: 0.069



I then set the root password for mysql using the command:

[root@cc ~]# mysqladmin -u root password "xxxx"

I replaced the xxxs's above with my new mysql root password. (I made the mistake of including spaces in my initial password. Do not do this as the LAMS install script will not work properly if you include spaces in this password!)


I then used the chkconfig command to automaticaly start mysql on boot as follows:

root@cc ~]# chkconfig mysqld on

[root@cc ~]# chkconfig --list grep mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off


It was now necessary to tell mysql to use READ-COMMITTED transaction isolation instead of the default setting of this parameter. This was achieved by setting the transaction-isolation as in the default configuration file /etc/my.cnf as shown below:

[root@cc ~]# nano /etc/my.cnf

[mysqld]
transaction-isolation = READ-COMMITTED
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

[mysql.server]
user=mysql
basedir=/var/lib

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid


I then restarted mysql so that the new setting would take effect:

[root@cc ~]# service mysqld stop
Stopping MySQL: [ OK ]
root@cc ~]# service mysqld start
Starting MySQL: [ OK ]


I then, unnecessarily as it turned out, downloaded and installed jboss-3.0.8_tomcat-4.1.24.zip (with integrated Tomcat 4.1.24)


I then downloaded and installed ant using the command shown below:

cd /usr/local
lynx http://ant.apache.org/bindownload.cgi
tar -xzvf apache-ant-1.6.5-bin.tar.gz
rm apache-ant-1.6.5-bin.tar.gz
rm: remove regular file `apache-ant-1.6.5-bin.tar.gz'? y
ln -s apache-ant-1.6.5 ant


I then set up the path for ant by editing /etc/profile as follows:

[root@cc local]# nano /etc/profile
Append to the end of the file:

PATH=$PATH:ANT_HOME/binANT_HOME=/usr/local/ant; export ANT_HOME
PATH=${PATH}:${ANT_HOME}/bin
export PATH

I then logged out and back in again for the path to take effect and checked that ant was accessible:

[root@cc ~]# ant -version
Apache Ant version 1.6.5 compiled on June 2 2005


I then downloaded and installed LAMS (something I should have done at the very beginning!) as follows:

From the root users home directory:

lynx http://www.lamsfoundation.org/downloads/
unzip redhat-lams-server1.0.1.zip
cd redhat*/lams-package/lib


I then downloaded and installed the mysql connector, which would allow JBoss to talk to mysql:

lynx http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-3.0.16-ga.tar.gz/from/pick
tar -xzvf mysql-connector-java-3.0.16-ga.tar.gz
rm mysql-connector-java-3.0.16-ga.tar.gz
remove regular file `mysql-connector-java-3.0.16-ga.tar.gz'? y
cd mysql*
mv mysql-connector-java-3.0.16-ga-bin.jar ../
cd ..
rm -rf mysql-connector-java-3.0.16-ga


I then logged on to mysql and tried to set up appropriate databases and privileges (Later on phpmyadmin turned out to be a MUCH better solution.) The next step was to move to the LAMS ant directory and try to edit build.xml. This turned out to be incredibly hard going and even when I was satisfied Tomcat would not start properly.



iii) An Improved Approach to Installation

This failure led me to look at the contents of the LAMS install directory carefully. I discovered that it actually contained an install script ready made for RedHat Enterprise Linux 3!

On looking at this script (redhat_install.sh) I realised that most of the installation I had undertaken so far could have been achieved by running this script and that all the necessary pacakges (e.g. jboss, ant, sdk) had already been included in LAMS download!!

The other interesting file turned out to be LAMS.SETTINGS - this was a simple text based configuration file that took all the work out of configuring build.xml!


I reinstalled the LAMS download to give me clean copies of the build.xml file etc.
I downloaded and installed phpmyadmin as follows:

lynx http://www.phpmyadmin.net/home_page/downloads.php#2.6.2-pl1
tar -xzvf phpMyAdmin-2.6.2-pl1.tar.gz
mv phpMyAdmin-2.6.2-pl1 phpmyadmin
cd phpmyadmin

I then made the changes shown in bold below to phpmyadmin/config.inc.php

nano config.inc.php

$cfg['Servers'][$i]['controluser'] = 'root';
$cfg['Servers'][$i]['controlpass'] = 'xxxx';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
cfg['Servers'][$i]['password'] = 'xxxx';

I went to the webpage for phpmyadmin and created a database called lams.

I gave to the mysql root user full privileges as shown below:

User: root
Host: %
Type: global
Privileges: ALL
Grant: Yes

I then set up a user called lams, with a password of yyyy and gave this user the following privileges on the lams database:

User: lams
Host: %
Type: database-specific
Privileges: ALL
Grant: Yes


I then edited LAMS.SETTINGS and the result for my system is shown below:

cat LAMS.SETTINGS
# Check lams-package/ant/build.xml for a detailed explanation of these fields
# or to setup advanced options

LAMS_VERSION="1.0.1-yoichi"

LAMS_HOME=/usr/local/lams/server1.0.1
LAMS_UPLOADS=$LAMS_HOME/lamsdata
LAMS_JBOSS_HOME=$LAMS_HOME/jboss

#### LAMS Community Interaction
LAMS_IS_ONLINE=false
ORGNISATION_KEY=

#### LAMS Admin User and Password

LAMS_ADMIN_USER=lamsadmin
LAMS_ADMIN_PASSWORD=zzzz

#### MySQL Database Details

# Currently not being used
#MYSQL_ALREADY_CONFIGURED=true

MYSQL_HOME=/usr/share/mysql
MYSQL_BINARIES_PATH=
MYSQL_SERVICE_NAME=mysql

LAMS_DB_NAME=lams
LAMS_DB_USER=lams

LAMS_DB_ROOT_PASSWORD=xxxx
LAMS_DB_PASSWORD=yyyy
LAMS_MYSQL_HOST=172.31.0.5

#### Configure the application server

LAMS_TOMCAT_PORT=8080
LAMS_CHAT_PORT=9800
LAMS_EMAIL_ADDRESS=root@cc.bromley.ac.uk
LAMS_SMTP_SERVER=172.31.0.5

LAMS_JBOSS_HOST=172.31.0.5

All the IP addresses used above are the internal IP addresses of the cc server inside our NAT firewall. The username and password pair for lams adminstration are used when you log into LAMS from the browser, so need careful consideration.

I then ran the ./redhat-install.sh script and accepted all the default options apart from choosing to skip the MySQL setup.

This checked that I had all the necessary packages installed, installed the server into /usr/local/lams/server1.0.1, built and started the server automatically.

After a while a message appeared to the effect that the server had started and I was able to hit CTRL+C to exit the script. I then had to wait quite a while during which time a screen full of cryptic messages appeared until eventually after numerous refreshes of the browser the LAMS login screen appeared. (Hallelujah :-)))


Before rebuilding LAMS after making changes to the LAMS.SETTINGS file I found it necessary to:

1) Use phpmyadmin to drop all tables in the lams database.
2) Completely remove the directory /usr/local/lams/server1.0.1



iv) Getting Apache to talk to JBoss

LAMS was now fully up and running on the cc server on port 8080 but we could only access it externally because our staff and student network proxy servers only allow access via ports 80 and 443 to "external" servers! To get round this I set up Apache to talk to JBoss using mod_jk2 so that a URL in the format:

http://cc.bromley.ac.uk/lams

automatically provided access to:

http://cd.bromley.ac.uk:8080/lams

I tried a number of different ways of getting this to work and found much of the documentation available on the Internet on this subject decidedly confusing. (I managed to miss finding the Solaris instructions in the LAMS documentation zip until after writing this guide, mainly due to the Windows unzip tool I was using truncating the filenames.)

The steps I took that actually produced a working solution are outlined below:

Using ftp I copied mod_jk2.so from Fedora Core 3 /etc/httpd/modules into CentOS 4
/etc/httpd/modules and made sure its permissions were 755.


I then created jk2.conf in /etc/httpd/conf.d as shown below:

cd /etc/httpd/conf.d
nano jk2.conf

#
# 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 jk2_module modules/mod_jk2.so

#
# Mod_jk2 is configured in /etc/httpd/conf/workers2.properties
#


I then created workers2.properties in /etc/httpd/conf as shown below:

cd /etc/httpd/conf
nano workers2.properties

[logger.file:0]
level=WARN
file=${serverRoot}/logs/jk2.log

[shm]
info=Defines the shared memory
file=${serverRoot}/logs/jk2.shm
size=1000000
debug=0
disabled=0

[channel.socket:localhost:8009]
info=Defines the local Tomcat server
tomcatId=jvm1
host=localhost
port=8009

[ajp13:localhost:8009]
info=Defines the default ajp13 worker
channel=channel.socket:localhost:8009

[status:status]
info=Defines the status worker

[uri:/jkstatus/*]
group=status:status

[uri:/scheduler/*]
context=/scheduler

[uri:/lams/*]
context=/lams


I then edited the JBoss server.xml file to modify the default engine container to include the jmvRoute attribute. The engine container I used (with opening and closing tags removed in order to display properly in this blog) is shown below:

nano /usr/local/lams/server1.0.1/jboss/tomcat-4.1.x/conf/server.xml

Engine name="Standalone" defaultHost="localhost" debug="0" jmvRoute="jvm1"


I then stopped LAMS and edited the jk2.properties file, which was otherwise just comments:

/etc/init.d/lams stop

nano /usr/local/lams/server1.0.1/jboss/tomcat-4.1.x/conf/jk2.properties

and appended the line shown below to the end of this file:

channelSocket.port=8009


I then restarted Apache and started LAMS:

service httpd restart
/etc/init.d/lams start

I was delighted to find that when I visited http://cc.bromley.ac.uk/lams it worked :-) What's more it also worked from our staff and student network behind the proxy servers :-))

I subsequently installed a copy of Moodle 1.5 on the same server and it is running happily alongside LAMS.

Return to Menu


2) LAMS 1.0.2 installation procedure (February 2006)

Today I undertook a fresh installation of LAMS 1.0.2 from the root account on a CentOS 4 Linux server.

The first step was to download and install the jdk.

lynx http://java.sun.com/j2se/1.4.2/download.html

Note that you need the 1.4 JDK NOT the 1.5 jdk for LAMS 1.0.2.

chmod 755 j2sdk*

./j2sdk-1_4_2_10-linux-i586-rpm.bin

rpm -ivh j2sdk-1_4_2_10-linux-i586.rpm


Once the jdk was installed I added the appropriate paths to /etc/profile:

Append to /etc/profile:

JAVA_HOME=/usr/java/j2sdk1.4.2_10
export JAVA_HOME
PATH=${PATH}:${JAVA_HOME}/bin
export PATH


The next step was to configure MySQL. To be on the safe side I completely removed the existing MySQL installation and re-installed a clean copy using yum. (Don't re-install MySQL if you already have a copy of Moodle running on the same server!)

I set MySQL to start automatically at boot as follows:

chkconfig mysqld on
chkconfig --list grep mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off


I also set the READ COMMITTED option in the MySQL configuration file:

pico /etc/my.cnf

[mysqld]
transaction-isolation = READ-COMMITTED
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

[mysql.server]
user=mysql
basedir=/var/lib

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

I then started MySQL:

service mysqld start

I logged on to mysql as root using the following command:

mysql -u root -p

The root password was set as follows:

mysql> set password = password("XXXX");

quit

Where XXXX represents the new password

I initially downloaded and installed phpMyAdmin 2.7.0 but could not get it to work
properly with MYSQL 4.1 so downloaded and installed phpMyAdmin-2.6.4-pl4 instead.

I downloaded and installed phpmyadmin as follows:

cd /var/www/html
lynx http://www.phpmyadmin.net/home_page/downloads.php#2.6.2-pl4
tar -xzvf phpMyAdmin-2.6.2-pl4.tar.gz
mv phpMyAdmin-2.6.2-pl4 phpmyadmin
cd phpmyadmin

I then made the changes shown in bold below to phpmyadmin/config.inc.php

nano config.inc.php

$cfg['Servers'][$i]['controluser'] = 'root';
$cfg['Servers'][$i]['controlpass'] = 'XXXX';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
cfg['Servers'][$i]['password'] = 'XXXX';

Where XXXX represents the root password for MySQL.

I used the browser to go to the web page for phpmyadmin (http://cc.bromley.ac.uk/phpmyamdin) and gave to the mysql root user full privileges as shown below:

User: root
Host: %
Type: global
Privileges: ALL
Grant: Yes

(Note that with LAMS 1.0.2 it was not necessary to create the LAMS database using phpMyAdmin as the LAMS installer now takes care of this. It is a good idea to password protect access to phpMyAdmin using a .htaccess file.)

I then went on to download and install LAMS as follows:

cd /home

lynx http://lamscommunity.org/lams-server1.0.2.zip

unzip lams*

cd lams-server1.0.2/config

I edited the lams.conf file to include the correct path for JAVA_HOME as follows:

pico lams.conf

## LAMS Server 1.0.2 - Used by the init script
export LAMS_HOME=/usr/local/lams/
export LAMS_VERSION=1.0
export JBOSS_HOME=/usr/local/lams/jboss
export JAVA_HOME="/usr/java/j2sdk1.4.2_10/"
export PATH="$JAVA_HOME/bin:$PATH"

I created the lams directory and copied over the JBOSS files:

mkdir /usr/local/lams

cp -r /home/lams-server1.0.2/jboss /usr/local/lams

Now I created the jboss user and made that user the owner and group owner of the jboss directory:

useradd jboss

chown jboss:jboss /usr/local/lams/jboss

chmod 755 /usr/local/lams/jboss/bin/*

I then edited the file build.properties as shown below:

cd /home/lams-server1.0.2/lams-package/ant

pico build.properties

# Properties file for ant install for LAMS
#
# NOTE: Installation platform is auto-detected
#
# ===============================================
# JBoss location for UNIX
LAMS_JBOSS_HOME_UNIX=/usr/local/lams/jboss

# ===============================================
# LAMS temp data directory for UNIX
LAMS_HOME_UNIX=/usr/local/lams

# ===============================================
# JBoss location for Windows
LAMS_JBOSS_HOME_WINDOWS=D:/jboss-3.0.8_tomcat-4.1.24

# ===============================================
# LAMS temp data directory for Windows
LAMS_HOME_WINDOWS=D:/home/lams

# ===============================================
# Tell Ant the MySQL db root password. That is what
# you have set when you installed MySQL.
# This is required only if you run "ant db-prep-only
LAMS_DB_ROOT_PASSWORD=XXXX

# ===============================================
# Tell Ant the hostname of the MySQL server that
# should be put in the MySQL grant able.
# MySQL seems unhappy with just 'localhost' or '%'
# in the grant table, in order to be able to connect
# from a client on the server itself.
# You can use either the hostname or the IP address,
# that is in the server's /etc/host file.
LAMS_MYSQL_HOST=172.31.0.5

# ===============================================
# Tell Ant the hostname of the LAMS server that
# should be put in the MySQL grant table.
#
# If the same server is used for both LAMS and MySQL,
# set this to "localhost".
#
# If LAMS server connects from another server and
# if it can only connect behind a firewall and with
# DNS settings as below:
#
# External IP-Address: 137.111.132.34
# Internal Hostname: b1600-s0.lib.mq.edu.au
# internal IP-Address: 192.168.1.30
#
# then this value must be set with the internal address.
# You can use either 192.168.1.30, b1600-s0 or
# b1600-s0.lib.mq.edu.au.
LAMS_JBOSS_HOST=localhost

# ===============================================
# The name of the LAMS database name
# The default is "lams". Ant will create the database
# if it did not exist. If it existed, it will be emptied.
# You may change this if you have more than one instance
# of LAMS running on the same instance of MySQL.
LAMS_DB_NAME=lams

# ===============================================
# The userid for the LAMS database.
# The default is "lams".
# "ant prepare-db" will set the userid to this value.
# You may change this value
LAMS_DB_USER=lams

# ===============================================
# The password for the userid for the LAMS database.
# "ant prepare-db" will set the password to this value.
# You must change this value for security reasons
LAMS_DB_PASSWORD=XXXX

# ===============================================
# The MySQL connector jar file name.
# This is to establish the connection for
# Ant tasks to run some SQL scripts
# This file must be placed inside the /lib
MYSQL_CONNECTOR_JAR_FILE=mysql-connector-java-3.1.11-bin.jar

# ===============================================
# JBoss Web server port number.
# JBoss normally uses 8080
# You may change this value
LAMS_TOMCAT_PORT=8080

# ===============================================
# JBoss Web server (Tomcat) request processor parameters.
# You may change these values. (Refer to Tomcat manual)
# These values affect LAMS performance greatly
MIN_PROCESSOR=5
MIN_PROCESSOR=75
ACCESS_COUNT=100
ENABLE_LOOKUP=false

# ===============================================
# JBoss mod_jk connector (Tomcat) request processor parameters.
# You may change these values. (Refer to Tomcat manual)
JK_MIN_PROCESSOR=5
JK_MIN_PROCESSOR=75
JK_ACCESS_COUNT=100
JK_ENABLE_LOOKUP=false

# ===============================================
# Certain Tools in LAMS send emails.
# You must set these parameters for your site,
# although LAMS still functions even if this is not set.
LAMS_ADMIN_EMAIL_ADDRESS=root@cc.bromley.ac.uk
LAMS_SMTP_SERVER=172.31.0.5

# ===============================================
# The port number where the lams chat server
# would be listening. In case you are behind a firewall you have to
# open this port for commucnication
LAMS_CHAT_PORT=9800

# ===============================================
# LAMS superuser userid. "admin" is reserved and cannot be used
LAMS_ADMIN_USER=root

# ===============================================
# Password for the LAMS superuser "root".
# "ant install" or "ant conf-only" will register it
# with LAMS database.
LAMS_ADMIN_PASSWORD=xxxxxxxxxxxxx

# ===============================================
# MySQL connection pool size.
# You may change these values if you need more connections.
# NOTE: You have to also increase MySQL max_connections if
# MYSQL_MAX_POOL_SIZE exceeds the config paramter.
# @see http://dev.mysql.com/doc/mysql/en/cj-general-j2ee-concepts.html
MYSQL_MIN_POOL_SIZE=10
MYSQL_MAX_POOL_SIZE=100

# ===============================================
# JBoss JVM memory sizes in MB.
# Eg. if you can give LAMS 1GB, set max to 512MB.
# because the actual memory size can grow twice as much.
# Setting min=max will reduce overhead in heap management.
JVM_MIN_HEAP=256
JVM_MAX_HEAP=256

# ===============================================
# LAMS log level
# Values are: ERROR,DEBUG,INFO,WARN
# You may change this value.
LOG_LEVEL=ERROR


I then edited /etc/profile to add the path for ANT:

pico /etc/profile

and appended the following text:

ANT_HOME=/home/lams-server1.0.2/apache-ant
export PATH=$PATH:$ANT_HOME/bin

It was now time to get ANT to prepare the database:

chmod 755 /home/lams-server1.0.2/apache-ant/bin/ant

cd /home/lams-server1.0.2/lams-package/ant

ant prepare-db
Buildfile: build.xml
[echo] it is unix
[echo] jboss home is: /usr/local/lams/jboss
[echo] LAMS home is: /usr/local/lams

prepare-db:
[echo] it is unix
[echo] jboss home is: /usr/local/lams/jboss
[echo] LAMS home is: /usr/local/lams

_prep_db:
[echo] This creates the database and sets username/password
[echo] mysql.classpath=/home/lams-server1.0.2/lams-package/lib/mysql-connector-java-3.1.11-bin.jar
[echo] url=jdbc:mysql://172.31.0.5/mysql
[echo] userid=root
[echo] password=XXXX
[sql] Executing commands
[sql] 18 of 18 SQL statements executed successfully

BUILD SUCCESSFUL
Total time: 2 seconds


ant install

ant install also ran successfully:
BUILD SUCCESSFUL
Total time: 13 seconds


I then set up LAMS so that it started automatically on boot:

cd /home/lams*/config

chmod 755 lams

cp lams /etc/init.d

cp lams.conf /etc

chkconfig lams on

service lams start

LAMS took a little while to start up

On visting http://cc.bromley.ac.uk:8080/lams/ the login page was available.

LAMS was now fully up and running on the cc server on port 8080 but we could only access it externally because our staff and student network proxy servers only allow access via ports 80 and 443 to "external" servers! To get round this I set up Apache to talk to JBoss using mod_jk2 so that a URL in the format:

http://cc.bromley.ac.uk/lams

automatically provided access to:

http://cd.bromley.ac.uk:8080/lams

The steps I took are outlined below:

Using ftp I copied mod_jk2.so from Fedora Core 3 /etc/httpd/modules into CentOS 4
/etc/httpd/modules and made sure its permissions were 755.


I then created jk2.conf in /etc/httpd/conf.d as shown below:

cd /etc/httpd/conf.d
nano jk2.conf

#
# 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 jk2_module modules/mod_jk2.so

#
# Mod_jk2 is configured in /etc/httpd/conf/workers2.properties
#


I then created workers2.properties in /etc/httpd/conf as shown below:

cd /etc/httpd/conf
nano workers2.properties

[logger.file:0]
level=WARN
file=${serverRoot}/logs/jk2.log

[shm]
info=Defines the shared memory
file=${serverRoot}/logs/jk2.shm
size=1000000
debug=0
disabled=0

[channel.socket:localhost:8009]
info=Defines the local Tomcat server
tomcatId=jvm1
host=localhost
port=8009

[ajp13:localhost:8009]
info=Defines the default ajp13 worker
channel=channel.socket:localhost:8009

[status:status]
info=Defines the status worker

[uri:/jkstatus/*]
group=status:status

[uri:/scheduler/*]
context=/scheduler

[uri:/lams/*]
context=/lams


I then edited the JBoss server.xml file to modify the default engine container to include the jmvRoute attribute. The engine container I used (with opening and closing tags removed in order to display properly in this blog) is shown below:

nano /usr/local/lams/jboss/tomcat-4.1.x/conf/server.xml

Engine name="Standalone" defaultHost="localhost" debug="0" jmvRoute="jvm1"


I then stopped LAMS and edited the jk2.properties file, which was otherwise just comments:

service lams stop

nano /usr/local/lams/jboss/tomcat-4.1.x/conf/jk2.properties

and appended the line shown below to the end of this file:

channelSocket.port=8009


I then restarted Apache and started LAMS:

service httpd restart
service lams start

I was delighted to find that when I visited http://cc.bromley.ac.uk/lams it worked :-) What's more it also worked from our staff and student network behind the proxy servers :-))

The next step was to configure Moodle on vle.bromley.ac.uk to include LAMS as an activity.

The following website proved invaluable in this and the instructions were clear, easy to follow and worked first time :-)))

http://lamsfoundation.org/integration/moodle/

Return to Menu


3) Using LAMS with DSpace and Apache along with mod_jk2 (February 2006)

I have just done an install of LAMS on our VLE server, which already has a copy of Moodle and DSpace running on it. If you are interested in DSpace installation please select this link. DSpace uses its own copy of Tomcat so I needed to get multiple instances of Tomcat, accessible via a single Apache server.

Below are the instructions for how I got LAMS JBOSS Tomcat running on the same server (CentOS 4) as DSpace Tomcat . Both Tomcat servers are now accessible on port 80 via Apache and mod_jk2.

Note that you need the 1.4 JDK NOT the 1.5 jdk for LAMS 1.0.2. I ran into trouble of installing LAMS on our VLE server, which already had the the 1.5 JDK pre-installed and I found I could not build the LAMS application. I had to download and install the 1.4.2 JDK as well and subsequently had to add appropriate pathing information for the 1.4 JDK to run.sh, ant and lams.conf. To help anyone else who makes the same mistake the error messages that appeared were:

[1] Done ./run.sh
[root@vle bin]#
================================================================================

JBoss Bootstrap Environment

JBOSS_HOME: /usr/local/lams/jboss

JAVA: /usr/java/jdk/bin/java

JAVA_OPTS: -server -Xms256m -Xmx256m -Dprogram.name=run.sh

CLASSPATH: /usr/local/lams/jboss/bin/run.jar:/usr/java/jdk/lib/tools.jar

================================================================================

06:30:53,332 INFO [Server] JBoss Release: JBoss-3.0.8 CVSTag=JBoss_3_0_8
06:30:53,339 INFO [Server] Home Dir: /usr/local/lams/jboss
06:30:53,339 INFO [Server] Home URL: file:/usr/local/lams/jboss/
06:30:53,339 INFO [Server] Library URL: file:/usr/local/lams/jboss/lib/
06:30:53,340 INFO [Server] Patch URL: null
06:30:53,340 INFO [Server] Server Name: default
06:30:53,340 INFO [Server] Server Home Dir:
/usr/local/lams/jboss/server/default
06:30:53,341 INFO [Server] Server Home URL:
file:/usr/local/lams/jboss/server/default/
06:30:53,341 INFO [Server] Server Data Dir:
/usr/local/lams/jboss/server/default/db
06:30:53,341 INFO [Server] Server Temp Dir:
/usr/local/lams/jboss/server/default/tmp
06:30:53,341 INFO [Server] Server Config URL:
file:/usr/local/lams/jboss/server/default/conf/
06:30:53,342 INFO [Server] Server Library URL:
file:/usr/local/lams/jboss/server/default/lib/
06:30:53,342 INFO [Server] Root Deployemnt Filename: jboss-service.xml
06:30:53,344 INFO [Server] Starting General Purpose Architecture (GPA)...
06:30:53,363 ERROR [Server] start failed
javax.management.InstanceNotFoundException:
JMImplementation:service=LoaderRepository,name=Default
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1010)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:804)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
at
org.jboss.system.server.ServerImpl.initBootLibraries(ServerImpl.java:440)
at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:261)
at org.jboss.system.server.ServerImpl.start(ServerImpl.java:221)
at org.jboss.Main.boot(Main.java:148)
at org.jboss.Main$1.run(Main.java:381)
at java.lang.Thread.run(Thread.java:595)
javax.management.InstanceNotFoundException:
JMImplementation:service=LoaderRepository,name=Default
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1010)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:804)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
at
org.jboss.system.server.ServerImpl.initBootLibraries(ServerImpl.java:440)
at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:261)
at org.jboss.system.server.ServerImpl.start(ServerImpl.java:221)
at org.jboss.Main.boot(Main.java:148)
at org.jboss.Main$1.run(Main.java:381)
at java.lang.Thread.run(Thread.java:595)


The DSpace installation of Tomcat was already running on the VLE server using the default ports.

Before building LAMS I edited the file build.properties as configured in sectiion of this blog to change the Tomcat port from 8080 to 8081.

Shown below are the workers2.properties and the JBOSS Tomcat server.xml file that I successfully used:

cd /etc/httpd/conf

less workers2.properties

[logger.file:0]
level=WARN
file=${serverRoot}/logs/jk2.log

[shm]
info=Defines the shared memory
file=${serverRoot}/logs/jk2.shm
size=1000000
debug=0
disabled=0

[channel.socket:localhost:8009]
info=Defines the DSpace Tomcat server
host=localhost
tomcatId=jvm1
host=localhost
port=8009

[channel.socket:localhost:8010]
info=Defines the LAMS Tomcat server
host=localhost
tomcatId=jvm2
port=8010

[ajp13:localhost:8009]
info=Defines the DSpace ajp13 worker
channel=channel.socket:localhost:8009

[ajp13:localhost:8010]
info=Defines the LAMS ajp13 worker
channel=channel.socket:localhost:8010

[status:status]
info=Defines the status worker

[uri:/jkstatus/*]
group=status:status

[uri:/scheduler/*]
context=/scheduler

[uri:/dspace/*]
group=ajp13:localhost:8009

[uri:/dspace-oai/*]
group=ajp13:localhost:8009

[uri:/lams/*]
group=ajp13:localhost:8010


In the /usr/local/lams/jboss/tomcat-4.1.x/conf/server.xml file I changed the port allocations to make sure that JBOSS Tomcat was not listening on the same ports as LAMS Tomcat.

The lines I changed are shown in bold below. I've missed out the xml tags as they will interfere with your viewing this blog.

Server port="8006" shutdown="SHUTDOWN" debug="0"

Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8081" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="100" debug="0" connectionTimeout="20000"
useURIValidationHack="false" disableUploadTimeout="true"

Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8010" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="0"
useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"

Engine name="Standalone" defaultHost="localhost" debug="0" jvmRoute="jvm2"

On restarting Apache:
Moodle was available on http://vle.bromley.ac.uk/vle
DSpace was available on http://vle.bromley.ac.uk/dspace
LAMS was available on http://vle.bromley.ac.uk/lams
:-)))

Return to Menu


4) Sorting out 400, 403 and 404 errors (February 2006)

We've just been using LAMS from within Moodle and have encountered seemingly arbitary 403 error messages in one or more frames. After a number of refreshes/revists to the site these disappear.

I found a fix for this on the LAMS Community Technical Forum on 22nd February and duplicate the solution that worked for me below:

nano /usr/local/lams/jboss/server/default/conf/jboss-service.xml

Locate the lines lines containing the named attributes DefaultCacheTimeout and DefaultCacheResolution and comment each line out separately using <-- -->

Restart LAMS:

service lams stop
service lams start

Hurray the 403 messages appear to have gone away :-)


I also had the following 400 and 404 errors, which went away once I closed the offending browser window and reselected the LAMS Learner link within Moodle.

Initially when I clicked on the Open LAMS Learner link I got the following message:

HTTP Status 400 - Invalid direct reference to form login page

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

type Status report

message Invalid direct reference to form login page

description The request sent by the client was syntactically incorrect (Invalid direct reference to form login page).

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

Apache Tomcat/4.1.24-LE-jdk14



On refreshing the browser window I then got the following message:

HTTP Status 404 - /lams/j_security_check

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

type Status report

message /lams/j_security_check

description The requested resource (/lams/j_security_check) is not available.


The solution was to download lams-valve.jar from here on the lamscommunity forum.

(Note: I initially used Internet Explorer to download the above jar file and found it had downloaded lams-valve.jar.zip - just a matter of uploading this file to the Linux box and renaming it lams-valve.jar)

I copied the downloaded lams-valve.jar to

/usr/local/lams/jboss/server/default/lib

On restarting LAMS and visting it from Moodle was well and the 400 and 404 error messages no longer appeared.


Return to Menu




5) Moodle Lams Integration Error with config.php (May 2006)

Despite Moodle and LAMS integration appearing to work well, I noticed some error messages appearing in the Apache error_log file relating to LAMS:

[client 10.200.0.1] PHP Warning: main(../../config.php): failed to open stream: No such file or directory in /home/bcvleuser/moodle/mod/lams/lib.php on line 4

The solution was to modify /home/bcvleuser/moodle/mod/lams/lib.php to correctly define the path to Moodle's config.php script as follows:

/// Library of functions and constants for module lams
include_once("/home/bcvleuser/moodle/config.php");


Once I had modified lib.php the error went away :-)

I have also noticed the following error messages in the Apache error_log file relating to mod_jk2 and LAMS:

[error] channelSocket.receive(): Error receiving message body -1 11
[error] workerEnv.processCallbacks() Error reading reply
[error] ajp13.service() ajpGetReply recoverable error 120000


These seem to appear in the error_log whenever LAMS is called from Moodle.
I have yet to find out the significance of these messsages!


Return to Menu