Thursday, April 23, 2009

Mahara installation and upgrade on Centos 5.x

(Last updated with a guide to upgrading Mahara from 1.4.0 to 1.4.1)

Please scroll to the bottom of this blog for the latest posting.

Installing Mahara

This blog was written after installing Mahara 1.1.2 on a CentOS 5.3 box already running Moodle, LAMS and DSpace.

Please note that in some places these instructions are specific to our installation.

The process I followed is explained below:

Login as root
su - postgres

Create the Mahara user and database in postgresql:
Note that postgresql was already installed and configured during the DSpace installation. For more information please select this link.

-bash-3.2$ createuser -U postgres -d -A -P mahara
Enter password for new role:
Enter it again:
Shall the new role be allowed to create more new roles? (y/n) n

-bash-3.2$ createdb -U mahara -EUTF8 mahara
-bash-3.2$ exit

nano /var/lib/pgsql/data/pg_hba.conf and add the line
host mahara mahara md5
service postgresql restart

Download and install Mahara:

tar -xzvf mahara-1.1.2.tar.gz
cd mahara-1.1.2
cp -pr htdocs /var/www/html/mahara
cd /var/www/html/mahara
cp config-dist.php config.php
nano config.php

* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2008 Catalyst IT Ltd (
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license GNU GPL
* @copyright (C) 2006-2008 Catalyst IT Ltd
// Copy this file from config-dist.php to config.php, and change the values in
// it to suit your environment.
// Information about this file is available on the Mahara wiki:
$cfg = new StdClass;

// database connection details
// valid values for dbtype are 'postgres8' and 'mysql5'
$cfg->dbtype = 'postgres8';
$cfg->dbhost = 'localhost';
$cfg->dbport = null;
$cfg->dbname = 'mahara';
$cfg->dbuser = 'mahara';
$cfg->dbpass = 'XXXX';
// Note: database prefix is NOT required, you don't need to set one except if
// you're installing Mahara into a database being shared with other
// applications (this happens most often on shared hosting)
$cfg->dbprefix = '';
// wwwroot - the web-visible path to your Mahara installation
// Normally, this is automatically detected - if it doesn't work for you
// then try specifying it here
//$cfg->wwwroot = '';
// dataroot - uploaded files are stored here
// For example, valid paths are:
// * /home/user/maharadata
// * /var/lib/mahara
// * c:\maharadata
// INVALID paths:
// * http://yoursite/files
// * ~/files
// * ../data
// This path must be writable by the webserver and outside document root (the
// place where the Mahara files like index.php have been installed).
// Mahara will NOT RUN if this is inside your document root, because
// this is a big security hole.
$cfg->dataroot = '/home/mahara';

mkdir /home/mahara
chown apache:apache /home/mahara

[root@vleinternal mahara]# crontab -e
Append the last line to the root crontab:

* * * * * wget -q -O /dev/null

It is necessary to now install the following php modules before Mahara's Web based installer will run:

yum install php-devel
yum install php-pear
pear install pecl/json
yum install php-pgsql
yum install php-gd

nano /etc/php.d/json.ini and add

nano /etc/php.d/ and add

nano /etc/php.d/

Edit httpd.conf and set AllowOverride = All
restart apache
visit to complete install

Once Mahara is installed you can login as follows:

Username: admin
Password: mahara

You will be prompted to change the password on first login.

Moodle-Mahara integration is straightforward and I successfully followed the instructions contained in the file mahoodle.pdf available from eduforge.

Mahara Upgrade Process

Below is the process I followed to upgrade Mahara from version 1.1.2 to version 1.1.3

Please note that in some places these instructions are specific to our installation.

A very similar process worked successfully to upgrade Mahara to later versions. Please see below for information on any problems I encountered with specific version upgrades.

mv /var/www/html/mahara /root/mahara_old_1.1.2

Download mahara-1.1.3.tar.gz as root, extract the contents of the tar archive and install the new version.

tar -xzvf mahara-1.1.3.tar.gz
cd mahara-1.1.3
cp -pr htdocs /var/www/html
mv /var/www/html/htdocs /var/www/html/mahara
cp /root/mahara_old_1.1.2/config.php /var/www/html/mahara

Then visit the upgrade script in Mahara from the browser to complete the upgrade:

When I upgraded from 1.1.7 to 1.2.0 I had the following error message when I went to the admin page:

Mahara: Site unavailable
Your server configuration does not include the dom extension. Mahara requires this in order to parse XML data from a variety of sources.

This was solved by installing php-xml and restarting Apache as shown below:

yum install php-xml
service httpd stop
service httpd start

When I upgraded from 1.2.0 to 1.2.2 the above process worked fine, although the download site URL has changed:


When I upgraded from 1.2.2 to 1.2.3 and from from 1.2.3 to 1.2.4 the above process worked fine.

When I upgraded from 1.2.4 to 1.3.3 I ran into a problem with the default version of PHP installed with CentOS 5. When I went to complete the upgrade I received the message:

Mahara will not run on PHP < 5.2.0. Please upgrade your PHP version,
or move Mahara to a different host.

On checking as shown below I found the installed version of PHP was 5.1.6

rpm -q php

This meant that before the upgrade could be completed I was going to have to upgrade PHP. The process I followed is shown below.

Install yum priorities:

yum install yum-priorities

Then enable priorities in the appropriate configuration file:

nano /etc/yum/pluginconf.d/priorities.conf

enabled = 1

Install access to the additional repositories:

rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm

Now change the repository priorities. i.e.

cd /etc/yum.repos.d
cat remi.repo
name=Les RPM de remi pour Enterprise Linux 5 - $basearch

cat epel.repo
name=Extra Packages for Enterprise Linux 5 - $basearch

Set the the priorities of everything in the CentOS-Base.repo to priority=2

Now update php and mysql:

service httpd stop
service mysqld stop
yum --enablerepo=remi update mysql
yum --enablerepo=remi update php
service mysqld start
service httpd start

This successfully updates PHP and MySQL to the latest versions.

Now change the priorites of everything in the CentOS-Base.repo back to priority=1. Also change the priorities of the remi and epel repos to priority=10.

It occurred to me that the above process was going to be a bit messy each time I needed to update MySQL and PHP. My solution was to create two separate copies of the /etc/yum.repos.d directories. One contained files with the default repository priorities (yum.repos.d.orig) and the other contained the files with the priorities required to update PHP and MySQL(yum.repos.d.remi). I created the script below in /root/bin to run whenever I need to upgrade PHP and MySQL:

cat update.mysql.php
cd /etc
rm -rf yum.repos.d
cp -pr yum.repos.d.remi yum.repos.d
service httpd stop
service mysqld stop
yum --enablerepo=remi update mysql
yum --enablerepo=remi update php
service mysqld start
service httpd start
rm -rf yum.repos.d
cp -pr yum.repos.d.orig yum.repos.d
yum update
cd /root/bin

The upgrade to Mahara 1.3.3 then went smoothly and for convenience the commands I used are provided below:

cd /root
mv /var/www/html/mahara /root/mahara_old_1.2.4
tar -xzvf mahara-1.3.3.tar.gz
cd mahara-1.3.3
cp -pr htdocs /var/www/html
mv /var/www/html/htdocs /var/www/html/mahara
cp /root/mahara_old_1.2.4/config.php /var/www/html/mahara

Visit the upgrade script in Mahara from the browser to complete the upgrade e.g.:

Setting up Moodle and Mahara so that Mahara views can be submitted to Moodle for assessment.

This was tested with Moodle 1.9.10 and Mahara 1.3.3

Please note that in some places these instructions are specific to our installation and assume SSO between Moodle and Mahara is already working.

Log in as the root user and download the following files to the root users home directory:

lynx ""

lynx ""

lynx ""

Untar the downloaded archives:

tar -xzvf mahara-contrib-mdl19-mod-mahara-master.tar.gz
tar -xzvf mahara-contrib-mdl19-mod-assignment-type-mahara-master.tar.gz
tar -xzvf mahara-contrib-plugin-artefact-outcome-master.tar.gz

Rename and copy the downloaded Moodle module folders:

cp -pr mahara-contrib-mdl19-mod-mahara /home/vle1011user/moodle/mod/mahara
cp -pr mahara-contrib-mdl19-mod-assignment-type-mahara /home/vle1011user/moodle/mod/assignment/type/mahara

Create an empty lib.php file so Moodle doesn't say the module isn't present on disc:

touch /home/vle1011user/moodle/mod/mahara/lib.php

Login to Moodle using the /admin URL and the new modules will be installed.

Go to the admin menu in Moodle.

Under Modules > Activities > Manage activities it is necessary to have the eye CLOSED on the Mahara assignment mnet module.

Under Networking > Peers select your Mahara host, and then select the Services tab. Under the Mahara new assignment mnet module section at the top of the page, check Subscribe, and save the change.

Now when you go to Add an activity to a course, under Assignments you should see Mahara Portfolio as the bottom option.

If you have enabled outcomes within Moodle assessment you can make the outcomes of a graded asessment available to a student from within Mahara. This is optional an involves installing the outcome module into Mahara. To install this module follow the steps below:

cp -pr mahara-contrib-plugin-artefact-outcome /var/www/html/mahara/artefact/outcome

To install the plugin into Mahara, log in as the Mahara administrator, go to Site Administration > Administer Extensions > Plugin Administration and click the Install link beside the outcome artefact plugin. I understand that this is supposed to add the My Outcomes tab under the My Portfolio menu when an outcome enabled assignment is graded in Moodle. However students can just as easily view their results directly in Moodle.

Once a Mahara view is submitted to a Moodle assignment for assessment it is locked within Mahara so a user cannot change it. By default the view is only unlocked when the assignment is graded using outcomes. This can prove a problem as if outcomes are not set, or the assignment is deleted, then the view in Mahara remains permanently locked :(

A work around this, which releases a view once an assignment has been graded (regardless of whether outcomes are set in Moodle) is to comment out one line in the following file:

nano /home/vle1011user/moodle/mod/assignment/type/mahara/assignment.class.php

The relevant excerpt from the file is shown below:

function process_outcomes($userid) {
global $CFG, $MNET, $USER;

// Export outcomes to the mahara site
$grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, $userid);

if (empty($grading_info->outcomes)) {
// return;

if (!$submission = $this->get_submission($userid)) {

Commenting out the return statement above means that once an assignment is graded in Moodle (whether or not it has outcomes set) the view is released in Mahara.

Whether there are any unwanted side effects of the above code amendment remains to be seen ;)

With thanks to Dominique-Alain JAN and Richard Mansfield for advice, which helped me to sort out issues with the view submission installation process.

Upgrade from 1.3.3 to 1.3.5

I followed the standard upgrade process detailed above. For convenience the commands I used are provided below:

cd /root
mv /var/www/html/mahara /root/mahara_old_1.3.3
tar -xzvf mahara-1.3.5.tar.gz
cd mahara-1.3.5
cp -pr htdocs /var/www/html
mv /var/www/html/htdocs /var/www/html/mahara
cp /root/mahara_old_1.3.3/config.php /var/www/html/mahara

Visit the upgrade script in Mahara from the browser to complete the upgrade e.g.:

This worked fine on the test server but failed on the production server with the message:

Mahara: Site unavailable
A nonrecoverable error occured. This probably means you have encountered a bug in the system

On checking the Apache error_log file I found the following message:

[WAR] 6a (lib/mahara.php:1086) File /var/www/html/mahara/artefact/outcome/lib.php did not exist, referer:

This immediately alerted me to the fact that the outcome module was missing. I copied over the outcome folder from the 1.3.3 backup:

cp -pr /root/mahara_old_1.3.3/artefact/outcome /var/www/html/mahara/artefact

And low and behold Mahara 1.3.5 worked fine :)

Upgrade from 1.3.5 to 1.3.6

I followed the standard upgrade process detailed above. For convenience I created a shell script to make life easier. The content of the script is shown below:

[root@vle bin]# cat upgrademahara
cd /root
mv /var/www/html/mahara /root/mahara_old_1.3.5
tar -xzvf mahara-1.3.6.tar.gz
cd mahara-1.3.6
cp -pr htdocs /var/www/html
mv /var/www/html/htdocs /var/www/html/mahara
cp /root/mahara_old_1.3.5/config.php /var/www/html/mahara
cp -pr /root/mahara_old_1.3.5/artefact/outcome /var/www/html/mahara/artefact

This worked like lightning and the upgrade went like a dream :)

Upgrade from 1.3.6 to 1.4.0

I followed the standard upgrade process detailed above. The content of the modified script is shown below:

[root@standbyvle bin]# cat upgrademahara
cd /root
mv /var/www/html/mahara /root/mahara_old_1.3.6
tar -xzvf mahara-1.4.0.tar.gz
cd mahara-1.4.0
cp -pr htdocs /var/www/html
mv /var/www/html/htdocs /var/www/html/mahara
cp /root/mahara_old_1.3.6/config.php /var/www/html/mahara
cp -pr /root/mahara_old_1.3.6/artefact/outcome /var/www/html/mahara/artefact

Visit the upgrade script in Mahara from the browser to complete the upgrade e.g.:

Upgrade from 1.4.0 to 1.4.1

I used the following modified script for the upgrade:

[root@vle bin]# cat upgrademahara
cd /root
echo "Please put Mahara into maintenance mode before performing the upgrade"
echo "Press any key when ready"
read dummy
echo "Enter new version number of Mahara (must be 1.4 series) to upgrade to e.g. 1.4.1"
read newver
echo "Enter existing version number of Mahara to backup e.g. 1.4.0"
read oldver
mv /var/www/html/mahara /root/mahara_old_$oldver
tar -xzvf mahara-$newver.tar.gz
cd mahara-$newver
cp -pr htdocs /var/www/html
mv /var/www/html/htdocs /var/www/html/mahara
cp /root/mahara_old_$oldver/config.php /var/www/html/mahara
cp -pr /root/mahara_old_$oldver/artefact/outcome /var/www/html/mahara/artefact
echo "Please visit to complete the upgrade"