Step-by-step Installation Guide for Ubuntu
This page requires a review. Please do so and remove this template when finished.
Installation Guide for Ubuntu
- A very useful link to install Moodle on Ubuntu 10.10 and 11.10 is available on this website: https://help.ubuntu.com/community/MySQLMoodle. The information via this link (last tried and tested in 02/2012) is easy to follow and straight forward. It is highly recommended to follow the information on the above link.
- Ubuntu provides an integrated Moodle package consistent with other Ubuntu/Debian packages. While the Ubuntu/Debian package may not install the latest cutting-edge development version of Moodle, it is more likely to work well in an Ubuntu system.
Installation from a package manager
- The Ubuntu/Debian package can be installed using a Package Manager (such as Synaptic Package Manager, Adept Package Manager, or KPackageKit), but installation usually is more transparent and successful when the package is installed (using the apt-get tool) from a command-line interface. You may notice that many installation options are not displayed when installing from a package manager. Please note that Moodle 1.9.4 is not compatible with PHP 5.3, so currently (May 2010) installing moodle using apt-get or synaptic won't work. You need to install a more recent version of Moodle or wait until there is a more recent version in the ubuntu 10.4 repository (see https://bugs.launchpad.net/ubuntu/+source/moodle/+bug/578797).
Installation from the command-line interface
- The command-line interface is the default in an Ubuntu server as no GUI is included in a default install. An experienced 'nix system admin would expect to use a CLI i/f on a server. Of course, an Ubuntu or Kubuntu desktop is easily added to a server (using one of the commands: sudo apt-get install ubuntu-desktop or sudo apt-get install kubuntu-desktop). From the Ubuntu desktop the command-line interface is reached using Terminal; from a Kubuntu desktop it is reached using Konsole.
Prepare your server
- Moodle is meant to be run on a server. It requires Apache2, the PHP scripting language, and a database (either MySQL or postgreSQL). While many users feel postgreSQL is a better database, MySQL is more widely used and is easier for first time users (since there are many integrated packages that use it). A LAMP server (Linux, Apache2, MySQL, PHP) can easily be installed from the command-line interface:
sudo tasksel install lamp-server
If you are using ubuntu 11.04 it does not have tasksel installed you will need to install it
sudo apt-get install tasksel
When installing the LAMP server, note the MySQL root password carefully. This will be required during Moodle installation.
- Moodle must know where the server is located. (You must also have a way for other users to reach it.) The FQDN (Fully Qualified Domain Name) refers to the location of the server on which the Moodle database is located. In general, there are two options: localhost (meaning the database will be located on the same computer on which Moodle will be installed) or a URL. (Of course, the URL could still refer to the same computer).
Don't worry, whichever option you choose can be changed later. For initial installation, it is easiest to use localhost as the FQDN (and also wherever it is available as an installation option).
Install the Moodle package from the command-line interface and follow the prompts:
sudo apt-get install moodle
- Database server software for Moodle: mysql-server -> follow remainder of instructions. Assuming the database is hosted on the same computer as the one Moodle is being installed upon, accept localhost for the options when prompted.
- Edit Moodle configuration options (if needed):
sudo nano /etc/moodle/config.php
- Edit Moodle apache2 configuration file (if needed):
sudo nano /etc/moodle/apache.conf
- Finish installation through a web browser. (A server without a desktop will not have a web browser. Now you see why it is better to have an Ubuntu or Kubuntu desktop installed on top of the server). I recommend the unattended installation.
If 404 page is displayed
- A few ubuntu users may try this on the terminal.
cd /var/www;sudo ln -s /usr/share/moodle
Set up a virtual server
The whole point of Moodle is that users can access it over a network. The easiest way is to set up a URL for your server so that users can reach Moodle using the URL. Several steps are necessary.
- Make sure the server on which Moodle is running has a static IP address on the LAN.
- If you have a router on your network, forward incoming traffic on ports 80 and 443 (http and https) from the router to the (static) LAN IP address of the server hosting Moodle.
- The firewall on the Moodle server should allow all incoming traffic on ports 80 and 443.
- A URL for your Moodle site should have been established with a DNS name server on the Internet. It is possible to use a Dynamic DNS server, as well. An example URL is mymoodleserver.dyndns.org.
- A virtual host file in /etc/apache2/sites-available must be created for Moodle.
cd /etc/apache2/sites-available sudo cp default moodlevirtualhost
- It should be edited (sudo nano /etc/apache2/sites-available/moodlevirtualhost) to look like
<VirtualHost *:80> ServerAdmin firstname.lastname@example.org # DocumentRoot /usr/share/moodle/ ServerName mymoodleserver.dyndns.org ServerAlias www.mymoodleserver.dyndns.org mymoodleserver.dyndns.org #RewriteEngine On #RewriteOptions inherit </VirtualHost>
Notes: The Rewrite options are listed here only for forward compatibility with Apache rewrite rules. They are only used for multi-site installations and can, in general, remain commented out (with the #).
- The virtual host file should be linked to /etc/apache2/sites-enabled and apache2 restarted.
sudo ln -s /etc/apache2/sites-available/moodlevirtualhost /etc/apache2/sites-enabled sudo /etc/init.d/apache2 restart
- Edit the /etc/moodle/config.php file
sudo nano /etc/moodle/config.php
so that the FQDN (in this case the URL) is correctly noted.
$CFG->wwwroot = 'http://mymoodleserver.dyndns.org/moodle';
- Login to the Moodle server:
Add a custom theme to Moodle
- Find free Moodle themes here.
- Download one. Extract the zip file (by clicking on the filename in Dolphin, for example).
- Copy the extracted folder to /usr/share/moodle/theme
- From Moodle, install the new theme:
- Moodle -> Appearance -> Themes -> Theme Selector
Hardy Heron 8.04
These complex instructions are no longer necessary on newer versions of Ubuntu/Kubuntu (and are maintained here for reference only).
- Download and burn an Ubuntu 8.04 LTS server CD to a Live CD.
- Start the computer and boot from the Live CD.
- Select Install to hard drive.
- Select your language, country, and keyboard layout (i.e. English, United States, American English)
- Select manually configure and set an IP address (or autoconfig if you don't know).
- Enter your servername (i.e. moodletest)
- Select to manually edit the partition table. I’m doing my testing on a standard 40GB harddrive and will modify these sizes for production.
/boot ext3 200MB bootable (may need to be under cylinder 1024 on your harddrive to be bootable) / ext3 10GB (files are relatively static) swap 4GB (4xRAM if you don't have much memory, down to 1xRAM if you have gobs of memory) /var ext3 26GB (variable content – uses rest of the drive)
- Select your timezone. (i.e. Central)
- Set clock to Universal Time.
- Enter Administrators full name. (i.e. Joe Smith)
- Enter account name. (i.e. joesmith)
- Enter a secure password. (‘abcde’ is not a good one!)
- Log in using your account name/password.
- Edit the /etc/apt/sources.list file. Remove the # mark on lines 22 and 38 to enable access to the universe package source and universe security updates. You will need to re-enter your account password when sudo asks for it.
sudo nano /etc/apt/sources.list
- Get the security updates.
sudo apt-get update sudo apt-get dselect-upgrade
- Normally you would just use sudo apt-get upgrade.
Install MySQL (skip Postgresql)
sudo apt-get install mysql-server php5-mysql
- Replace the following string NewRootDatabasePassword with a secure password of your own choosing.
There is no space between the -p and the password on the second command.
mysqladmin -u root password NewRootDatabasePassword mysqladmin -u root -h localhost password NewRootDatabasePassword -pNewRootDatabasePassword
- Create the Moodle database and Moodle user in MySQL.
The mysql command will prompt for your NewRootDatabasePassword (from above). Replace NewMoodleDatabasePassword with a secure password of your own choosing.
mysql -u root -p > CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; > GRANT ALL PRIVILEGES ON moodle.* TO moodleuser@localhost IDENTIFIED BY 'NewMoodleDatabasePassword'; > GRANT SELECT,LOCK TABLES on moodle.* TO moodlebackup@localhost IDENTIFIED BY 'MoodleBackupPassword'; > FLUSH PRIVILEGES; > QUIT
- The above also creates a backup user moodlebackup so that you can use mysqldump to make database backups without incident.
Install Postgresql (skip MySQL)
sudo apt-get install postgresql-8.1 php5-pgsql
- Create the database user 'moodleuser'.
sudo -u postgres createuser -D -A -P moodleuser
- Enter in a NewMoodleDatabasePassword here, then answer 'N' to the question.
- Create the database 'moodle' for the user 'moodleuser'. Enter the password that you just created.
sudo -u postgres createdb -E utf8 -O moodleuser moodle
- Secure the postgresql database with an admin password.
sudo -u postgres psql template1 # ALTER USER postgres WITH PASSWORD 'NewAdminDatabasePassword'; # \q
- Edit the file '/etc/postgresql/8.1/main/pg_hba.conf' and on line 79 change the words ident sameuser to md5.
sudo nano /etc/postgresql/8.1/main/pg_hba.conf
- Restart the database:
sudo /etc/init.d/postgresql-8.1 restart
- The following mod-security, ldap, and odbc libraries are optional:
sudo apt-get install apache2 libapache2-mod-php5 php5-gd sudo apt-get install libapache2-mod-security php5-ldap php5-odbc
- Restart Apache
sudo /etc/init.d/apache2 restart
Install other software
sudo apt-get install openssh-server unattended-upgrades sudo apt-get install unzip zip aspell-en aspell-fr aspell-de aspell-es sudo apt-get install curl php5-curl php5-xmlrpc php5-intl sudo apt-get install clamav-base clamav-freshclam clamav
cd /var/www sudo wget http://download.moodle.org/stable19/moodle-latest-19.tgz sudo tar -zxf moodle-latest-19.tgz
sudo mkdir /var/moodledata sudo chown -R www-data:www-data /var/moodledata
- where www-data is whatever user/group was created automatically when apache was installed.
- Edit the location of the default web site. On lines five and ten, replace /var/www/ with /var/www/moodle/. Restart Apache. (See page comments for more details on this instruction.)
sudo nano /etc/apache2/sites-available/default sudo /etc/init.d/apache2 restart
Configure Moodle website
- Note: look for your server’s ip address on the 2nd line
- On another computer open a web browser and put in your server address. Make sure your web browser is set to accept cookies.
- Complete the Moodle install using a secure username and password.
- Installing Moodle on Ubuntu
- Kubuntuguide -- Moodle tips
- Ubuntuguide -- Moodle tips
- Setting up the Perfect Ubuntu 6.06 server
- Ubuntu 6.06 Server Guide - HTML PDF
- Ubuntu - 1 2 security
- Debian - 1 2 security
- Setting up a secure LAMP Webserver on Debian Etch (May 22nd, 2008) 
- Linux - 1 2 3 security
- MySQL - 1 2 security
- Apache - 1 2 security
- Modsecurity apache2 module
- Another Ubuntu and Moodle install document
- Moodle Security
- Using Moodle HowTo: Installing aspell in Ubuntu (with dictionary) forum discussion