HOWTO: Moodle on Gentoo
14 April 2006
Introduction
Moodle is an e-learning platform that can be used for schools, universities, colleges and so on. I personally am primarily interested in higher education.
According to Zacker.org, Moodle has now become the most used e-learning platform in higher education, with more installs than Blackboard and WebCT put together (for a quick idea see this market penetration chart).
Not only does it (arguably) have the most features and the best stability record, it is also free/open-source, meaning that it is free as in beer as well as free as in speech.
After talking to a colleague who was helping out someone who is providing a moodle server for a school, I thought I had better check it out.
Moodle was a doodle to install, it took me about half an hour to install onto my little LAMP server (including typing out what I was doing). Of course if you were doing this seriously, you would need to spend a little extra time on the theme to match your existing website.
Here is some notes that I made while installing it, I hope it they will be helpful. As always, comments and corrections are always welcome.
Browse through the whole guide before you begin. It would be worth consulting Gentoo Wiki HOWTO Moodle and the Installing Moodle guide at Moodle.org. You should refer to those alongside this guide, especially if you are reading this guide a long time after 2006.
Step 0. You need a working LAMP setup
Here is how to do it the Gentoo may:
- You need a working Gentoo install - See the Gentoo Handbook for how to do that. It will take between an evening and a week, depending on how used to Linux you are.
- Install Apache with PHP - emerge apache mod_php should get you started.
- Install MySQL, this is more difficult, best to follow the Gentoo MySQL howto (emerge phpmyadmin be prove very helpful too)
Step 1. Setup the portage overlay
If you are reading this some months later and the Gentoo ebuild has been through the internal Gentoo quality assurance already, you will be able to skip steps 1 and 2.
At time of writing, the Moodle ebuild is not 100% official, so you need to add it yourself. A nice way of doing this to separate the official builds that you automatically download using emerge --sync from those that you have added yourself, a directory of your own ebuilds is called "a portage overlay".
Add this to /etc/make.conf
PORTDIR_OVERLAY="/usr/local/portage"
Not done yet, lets continue.
Step 2. Setup The ebuild for Moodle
a. Make the directories:
mkdir -p /usr/local/portage/www-apps/moodle/files
b. You need to grab all the files, well at least you need the main three files, run all the following commands:
cd /usr/local/portage/www-apps/moodle/
wget http://svn.gnqs.org/projects/gentoo-webapps-overlay/browser/experimental/www-apps/moodle/moodle-1.5.3.ebuild?format=raw -O moodle-1.5.3.ebuild
cd files
wget http://svn.gnqs.org/projects/gentoo-webapps-overlay/browser/experimental/www-apps/moodle/files/reconfig?format=raw -O reconfig
wget http://svn.gnqs.org/projects/gentoo-webapps-overlay/browser/experimental/www-apps/moodle/files/README.gentoo?format=raw -O README.gentoo
cd ..
ebuild /usr/local/portage/www-apps/moodle/moodle-1.5.3.ebuild digest
Step 3. Emerge moodle
Moodle currently has three use flags. Firstly there are flags to define what database you want, i.e. mysql or postgres. The other flag is the vhosts flag; this is to define whether you want moodle to be automatically installed in the default location within the Apache directory (htdocs/moodle) or you want to choose your own location.
I chose to use MySQL and the default location, so my use flags for moodle look like this:
USE="mysql -postgres -vhosts" emerge moodle
If you want to use a postgres database and you want to choose the location then choose:
USE="-mysql postgres vhosts" emerge moodle
Step 4. Run a few more random commands.
These are from the `Gentoo Wiki Guide`_, these basically finish the install by sorting out the permissions and getting rid of the stock config.php (we will make our own later).
> ``cd /var/www/localhost/htdocs/moodle/ > > rm config.php -f > > chmod a+w . > > cp lib/htaccess .htaccess > > ``
Obviously if you changed the default location for moodle then you need to adapt the first line accordingly.
Step 5. Create some data directories.
If you have your own server then you can make the whole thing much more secure by moving the data directories out of your Apache directory.
``mkdir /var/moodledata
chmod 777 /var/moodledata
mkdir /var/moodlequarantine
chmod 777 /var/moodlequarantine
Step 6. Create the moodle database and user
You can do this using the MySQL shell or through phpmyadmin. I will quote from the `Gentoo Wiki Guide`_ and from the Moodle Install guide. Change to something else.
Using the MySQL shell:
> ``# mysql -u root -p > > > use mysql; > > > INSERT INTO user (host, user, password, select_priv, insert_priv, update_priv) VALUES ('localhost', 'moodleuser', PASSWORD(''), 'Y', 'Y', 'Y'); > > > FLUSH PRIVILEGES; > > > SELECT host, user, password FROM user WHERE user = 'moodle'; # check your new user > > > CREATE DATABASE moodle; > > > GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER ON moodle.* > > TO moodleuser@localhost IDENTIFIED BY ''; > > > quit > > # mysqladmin -p reload > > ``
Using phpmyadmin:
> If you didn't define the database manully, point your browser to http://127.0.0.1/phpmyadmin/ and login as root, giving your root password for mysql. Create a user moodle, database moodle and grant all rights for the user for that database.
Using Postres:
> # su - postgres > > > psql -c "create user moodleuser createdb;" template1 > > > psql -c "create database moodle with encoding 'unicode';" -U moodleuser template1 > > > psql -c "alter user moodleuser nocreatedb;" template1 > > > psql -c "alter user moodleuser with password 'yourpassword';" template1 > > > su - root > > # /etc/init.d/postgresql reload
Step 7. Run the install script
Now open a web broswer and go to wherever you have installed moodle, for example:
http://www.domainname.com/moodle/install.php
http://www.domainname.com/install.php
http://127.0.0.1/moodle/install.php
This will open the install wizard. It will create a moodle config file for you. You bascially click next a lot. Below I have provided a small note on each section where I have thought of something useful to say.
a. Choose your language.
I chose en for English.
b. It then checks your PHP settings.
c. Choose the directory settings:
I put the data in /var/moodledata see step 5 above.
d. Fill in the database settings,
You need to enter the username and password that you made earlier, e.g. moodleuser and .
e. config.php has been successfully created.
This is not the end, this is not the beginning of the end, this is the end of the beginning.
f. You are then shown the GPL.
Make a cup of tea, lie back and get reading...
g. It then sets up the tables in database, outputting all the queries to the screen.
Don't panic! These are not error messages, these are SQL queries, look down to the bottom, mine said "Database was successfully upgraded".
h. It then tells you the version number.
Okay...
i. It then gives you all the release notes.
More exciting reading for you...
j. You are then shown a Variables configuration screen.
- You can change these later, so don't get too worried about getting everything right the first time.
- A rather nice feature is that you can set moodle to use ClamAV to scan the files that your students/users upload.
- Your path to clam AV is probably /usr/bin/clamscan
- I set my quarantine directory to /var/moodlequarantine see step 5 above
- For my zip programs I added /bin/gzip and /bin/gunzip .
- Path to du was /usr/bin/du or /bin/du (/usr/bin/du is a symlink to /bin/du)
**k. Then it sets up the module tables, **
More pretty SQL here, keep clicking next if everything is green.
l. Eventually you get to the site settings.
Here you provide the text that will show on the front page and so on. You can change this later, so probably best to keep it simple for now.
m. Account profile
Lastly you setup a profile for the admin user, make sure that you remember the password. Then your are done!




1 Zeth says...
Moodle has gone to 1.6 and the overlay above has not been upgraded yet. So your choices at this point:
Posted at 6:03 p.m. on July 4, 2006