Category Archives: Moodle

Migrating Moodle to a Plesk Linux server

Following up on some work that I started earlier in the month. I am using a Plesk Version 10 server to host
a Moodle 2.x system.

Some more config work was required to migrate the Moodle system including editing the database records to change the embedded paths (file system paths) and the embedded URL’s (absolute URL’s for data files).

The addition of an SSL certificate created a problem but it was only that the Plesk process provides for modifications to http and https as two separate files. The following needed to be added as well.

[bash]

#mcedit /var/www/vhosts/your_domain_name/conf/vhost_ssl.conf

[/bash]

and create an entry like

[xml]
<Directory /var/www/vhosts/your_domain_name/httpdocs/>
php_admin_value open_basedir "/var/www/vhosts/your_domain_name/httpdocs:/var/www/vhosts/your_domain_name/moodledata"
</Directory>
[/xml]

So that both http and https have the open_basedir restriction avoided.

Moving Moodle to a Plesk environment

I am migrating a moodle install from an older system into a new hosted environment with Plesk in the background.

The setup of the Plesk account is straight forward. While the transfer was simple enough using SFTP via FileZilla out of one Linux system to my workstation and off to the new server.

The first obvious task was to modify the config.php file for moodle with its new information.

The less obvious task was the error accessing the moodledata directory which for preference sits outside the Plesk default httpdocs directory.

If you are getting an error about the $CFG->dataroot being invalid or similar it will be the open_basedir setting.

Check the logs for Apache errors

[bash]
#/var/www/vhosts/your_domain_name/statistics/logs/error_log
[/bash]

to modify the default Apache settings in a Plesk world create a file called vhost.conf in the conf directory I use mcedit as my favourite Linux command line editor (apt-get install mc) (Midnight Commander tools)

[bash]

#mcedit /var/www/vhosts/your_domain_name/conf/vhost.conf

[/bash]

and create an entry like

[xml]
<Directory /var/www/vhosts/your_domain_name/httpdocs/>
php_admin_value open_basedir "/var/www/vhosts/your_domain_name/httpdocs:/var/www/vhosts/your_domain_name/moodledata"
</Directory>
[/xml]

I referenced Aaron Gadberry’s blog for the above but stumbled when it came to restarting the Apache service

[bash]

#/usr/local/psa/admin/bin/websrvmng -a

[/bash]

is no longer valid. Given that Aaron wrote his info in 2006  and 5 years later Plesk is version 10 for my server it is not surprising there is a change. The correct command for restarting / reconfiguring a single vhost is

[bash]

#/usr/local/psa/admin/bin/httpdmng –reconfigure-domain your_domain_name

[/bash]

The final part of this conversion was to modify the Moodle MySQL database to a UTF8 format.

I have used phpmyadmin for years and most Linux servers including Plesk offer it for mySQL admin.

It’s a simple thing to change the database. Just select the database in phpmyadmin and select the Operations tab. Down the bottom is the current collation in a select list. Change the selection to utf8_unicode_ci which is at the very bottom of the list and click on Go.

Moodle upgrade from 1.9 to 2.0

The actual versions of the upgrade are v1.9.5 (live) and moving to 2.0.1+ (daily download from Jan 2011).

The server had been setup with a working copy of the live system from January and tested through an upgrade to 2.0.1+ so we were happy that all would work well. This upgrade was also a server migration from an older RedHat box to a Debian vm, but the principles are the same for any upgrade. The Moodle version to be used was already installed as a staging platform.

The following notes relate to the process that I used for the live cut-over.

Backup of live 1.9.5 database via phpmyadmin

Copy the moodledata directory (the one with the files) from live to new
(must change owner and ensure write permissions after copy or you will get an odd blank page in the middle of the upgrade)
I used rsync to transfer between the servers here.

database created live_2 : (note to self:ensure utf8 collation setting for the db in future)
import old 195 data to new db
config.php modified to use the new db
run moodle2 as admin
auto upgrade : error check references installing UTF8. This is because I forgot to set collation = utf8 corrected* and reran upgrade

Update DNS settings (transferring from one server to another)

Changed apache config on new server to accept the new virtual host.

*Correcting the collation is as simple as using your mysql admin tool and issung ‘ALTER DATABASE db_name COLLATION ‘new collation name’;
with the new collation name inside single quotes.