Presented byDiana Clarke and Brian Dichter
Behind the Scenes–Serving Moodle
Introduction
- Moodle is Open Source and relies on several key Open Source applications to do its magic.
- MySQL database.- PHP is server-side scripting language that works especially well with MySQL.
- Apache is the webserver software on Mac OS X.
Assumptions
- You know that Moodle is a “software package for producing internet-based courses and web sites, supporting a social constructionist framework of education”.
- Brand new “vanilla” Mac OS X Server- Or, server without PHP/MySQL configured- Administrator access to Mac OS X Server- Use both GUI and Terminal
Downloads
- Moodle-latest build (1.5.3+)- http://download.moodle.org/
- PHP (4.3.11 for Apache 1.3)- http://www.entropy.ch/software/macosx/php/
- MySQL (Standard 4.0.26)- http://dev.mysql.com/downloads/mysql/4.0.html
- Apache (1.33)Already installed on Mac OS X Server
Downloads–Optional
- phpMyAdmin- http://www.phpmyadmin.net/home_page/index.php
- MyS QL Administrator- http://www.mysql.com/products/tools/administrator/
- MySQL Query Browser- http://dev.mysql.com/downloads/query-browser/1.1.html
Configure Webserver
- Use Server Admin- Select the “Web” service to configure Settings
- Double-click the default site- Edit the Domain Name (use FQDN if possible)- Take note of the Web folder location- Make sure to edit the Default index files- Edit the Administrator email address- Select Options and uncheck everything (unless you have other sites running that need any of these)
- Start the Web service!
Configure Webserver
- Visit your site in a browser to test that it’s working (you should see the Apache manual)
- Clean up your Web folder (I usually delete all of the Apache files…actually, I usually delete everything except the error page)
Install and Test PHP
- Install the PHP package
- Create a text file in your Web folder named “info.php” containing the following code:<?php>phpinfo();?>- Open this page in your browser to test PHPhttp://yoursite.org/info.php
- After successfully testing, delete the “info.php” file.
Install and Test MySQL
- Install the MySQL package and the startup item package.
- User Terminal to start the MySQL server.$ sudo /Library/StartupItems/MySQL/MySQL start
- Use Terminal and the MySQL Monitor program to check that it’s running (most common error is forgetting to start the server).$ mysql -u root
- Set and secure the root password.mysql> set password for > root@localhost=password(‘------’);
Install and Test MySQL
- Delete anonymous accounts.
mysql> use mysql;
mysql> delete from user where User=‘’;
mysql> delete from db where User=‘’;
mysql> flush privileges;
Install and Test MySQL- Create Moodle database and account.
mysql> CREATE DATABASE moodle;mysql> GRANT SELECT,INSERT,DELETE,CREATE,DROP,INDEX,> ALTER ON moodle.* TO moodleuser@localhost > IDENTIFIED BY ‘somesecretpassword’;> quit
$ mysqladmin -u root -p reload
Install and Test MySQL- Test your new account.
$ mysql -u moodleuser -p
Prepare to Install Moodle
- Create a data directory.
$ sudo mkdir /Library/WebServer/moodle-data
- Change the owner and permissions on the data directory.
$ sudo chown www:www /Library/WebServer/moodle-data$ sudo chmod 700 /Library/WebServer/moodle-data
Prepare to Install Moodle
- Move your Moodle download into your Web folder.- Use the Terminal to extract the files (there are
a lot of files!).
$ tar xvf moodle-latest-15.tar
- Change the owner of the Moodle directory (or you may get an error).
$ sudo chown www:www /Library/WebServer/Documents/moodle
Install Moodle- Open the install.php file in your web browser.
- Follow the instructions on each page until you’re done!
Moodle Database Backup- Create a simple backup script to backup your database.
- Create a folder where you will store your database backups (for example: /Library/WebServer/db)
- Create a text file (plain text, not rtf!) named “dbBot” containing the following code:
#!/bin/bashcd /Library/WebServer/dbmysqldump -u root -psecretpassword
moodle > moodle-backup.sql.`date +%m%d%Y`
Moodle Database Backup
- Change the permissions of this file so root owns, noone can read.
$ sudo chown root dbBot$ sudo chmod 700 dbBot
- Test the script.$ sudo sh dbBot
- A test should produce something like this in /Library/WebServer/db:
moodle-backup.sql.02282006
moodle-backup.sql.03012006
Moodle Database Backup
- Restoring a database is fairly easy.
mysqldump -u root -psecretpassword moodle < moodle-backup.sql.03012006
Automate Backup and Tasks
- We use Cron to automate backups and Moodle tasks. Use Terminal!$ sudo pico /etc/crontab
- You will see this:# /etc/crontabSHELL=/bin/shPATH=/etc:/bin:/sbin:/usr/bin:/usr/sbinHOME=/var/log##minute hour mday month wday who command##*/5 * * * * root /usr/libexec/atrun## Run daily/weekly/monthly jobs.15 3 * * * root periodic daily30 4 * * 6 root periodic weekly30 5 1 * * root periodic monthly
Automate Backup and Tasks
- Add the following sections with comments at the end and exit pico (control-x) and save the file (y to save, hit enter):# run Moodle cron script*/5 * * * * wget -q -O /dev/null http://yoursite.org/moodle/admin/cron.php
# run dbBot to backup Moodle database in MySQL every day at 6:15am15 6 * * * root /System/bin/dbBot
Summary
- Download the Open Source applications.- Configure the webserver.- Install and test PHP.- Install and test MySQL.- Create a Moodle database and user.- Create a data folder.- Install and test Moodle.- Create a custom MySQL database backup script.- Automate backup and Moodle tasks with Cron.
Configure Themes/Courses
- Configure Themes
- Add Courses
Resources- Moodle Documentation
http://docs.moodle.org/
- Moodle Support (Free Community Support)http://moodle.org/course/view.php?id=5
- Moodle Philosophyhttp://docs.moodle.org/en/Philosophy
- Presentation files and other docshttp://helpdesk.d214.org/projects/ice06/
Diana Clarke [email protected] Dichter [email protected]
Q & A
Recommended