Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Step-by-step Installation Guide for Ubuntu.

Step-by-step Installation Guide for Ubuntu: Difference between revisions

From MoodleDocs
No edit summary
m (Reverted edits by Sebren.ead@hotmail.com (talk) to last version by Jon Witts)
 
(30 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Review}}
= Installation Guide for Ubuntu =
= Installation Guide for Ubuntu =


== Karmic Koala 9.10 ==
*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.
*Simplified instructions are available at
 
:* [http://kubuntuguide.org/Moodle_tips Kubuntuguide -- Moodle tips]
== Installation from a package manager ==
:* [http://ubuntuguide.org/Moodle_tips Ubuntuguide -- Moodle tips]
*The Ubuntu/Debian package can be installed using a [http://ubuntuguide.org/wiki/Ubuntu:All#Ubuntu_Package_Installation_and_Updates 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 [http://ubuntuguide.org/wiki/Ubuntu:All#General_Notes command-line interface] is the default in an Ubuntu server without a desktop, and it is possible, but not recommended, to run Moodle on a standalone server without a desktop. Of course, an [http://ubuntuguide.org/wiki/Ubuntu:All#Add_a_desktop_to_an_Ubuntu_Server Ubuntu] or [http://kubuntuguide.org/All#Add_a_desktop_to_an_Ubuntu_Server 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 [http://ubuntuguide.org/wiki/Ubuntu:All#Servers 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 [http://ubuntuguide.org/wiki/Ubuntu:All#LAMP_server_installation LAMP server] (Linux, Apache2, MySQL, PHP) can easily be installed from the command-line interface:
sudo tasksel install lamp-server
 
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).
 
== Moodle installation ==
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


The complex instructions (detailed below for Hardy Heron) are no longer necessary.
*Edit Moodle apache2 configuration file (if needed):
sudo nano /etc/moodle/apache.conf


== Hardy Heron 8.04 ==
*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.


*[http://www.ubuntu.com/products/GetUbuntu/download#lts Ubuntu 8.04 LTS server CD]
<nowiki>http://localhost/moodle</nowiki>


=== Install Ubuntu ===
== Set up a virtual server ==
Start computer and boot from CD.
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.


Select '''Install to hard drive'''.
*Make sure the server on which Moodle is running has a [http://ubuntuguide.org/wiki/Ubuntu:All#Set_a_static_IP_address static IP address] on the LAN.


Select your '''language''', '''country''', and '''keyboard layout''' (i.e. English, United States, American English)
*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.


Select '''[http://help.ubuntu.com/8.04/ubuntu/serverguide/C/network-configuration.html manually configure]''' and set an IP address (or autoconfig if you don't know).  
*The [http://ubuntuguide.org/wiki/Ubuntu:All#Firewall firewall] on the Moodle server should allow all incoming traffic on ports 80 and 443.


Enter your servername (i.e. moodletest)
*A URL for your Moodle site should have been established with a DNS name server on the Internet. It is possible to [http://ubuntuguide.org/wiki/Ubuntu:All#Using_Dynamic_IP_addresses_for_a_webserver use a Dynamic DNS server], as well. An example URL is ''mymoodleserver.dyndns.org''.


Select to '''manually edit the partition table'''.  I’m doing my testing on a standard 40GB harddrive and will modify these sizes for production.
*A virtual host file in /etc/apache2/sites-available must be created for Moodle.
cd /etc/apache2/sites-available
sudo cp default ''moodlevirtualhost''


:<table>
::It should be edited (sudo nano /etc/apache2/sites-available/''moodlevirtualhost'') to look like
:<tr><td width=%10>/boot</td><td width=%10>ext3</td><td align=right width=%10>200MB</td><td align=center width=%10>bootable</td>
 
<td>([http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/ref-guide/s1-grub-whatis.html may need to be under cylinder 1024 on your harddrive to be bootable])</td></tr>
<VirtualHost *:80>
:<tr><td>/</td><td>ext3</td><td align=right>10GB</td><td></td><td>(files are relatively static)</td></tr>
ServerAdmin webmaster@''mymoodleserver.dyndns.org''
:<tr><td>swap</td><td></td><td align=right>4GB</td><td></td>
#
<td>(4xRAM if you don't have much memory, down to 1xRAM if you have gobs of memory)</td></tr>
DocumentRoot /usr/share/moodle/
:<tr><td>/var</td><td>ext3</td><td align=right>26GB</td><td></td><td>(variable content – uses rest of the drive)</td></tr>
ServerName ''mymoodleserver.dyndns.org''
:</table>
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


Select your '''timezone'''. (i.e. Central)
so that the FQDN (in this case the URL) is correctly noted.


Set clock to '''Universal Time'''.
$CFG->wwwroot = 'http://''mymoodleserver.dyndns.org''/moodle';


Enter Administrators '''full name'''. (i.e. Joe Smith)
*Login to the Moodle server:
::http://''mymoodleserver.dyndns.org''


Enter '''account name'''. (i.e. joesmith)
== Add a custom theme to Moodle ==
*Find free Moodle themes [http://moodle.org/mod/data/view.php?id=6552 here].


Enter a secure password. (‘abcde’ is not a good one!)
*Download one. Extract the zip file (by clicking on the filename in Dolphin, for example).


Let the computer restart.
*Copy the extracted folder to /usr/share/moodle/theme


Log in your account.
*From Moodle, install the new theme:
:Moodle -> Appearance -> Themes -> Theme Selector


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.
= Upgrades =
<pre>
*See [[Ubuntu_Debian_Upgrades|Ubuntu and Debian Upgrades]].
sudo nano /etc/apt/sources.list 
</pre>
Now to get all the security updates.
<pre>
sudo apt-get update


sudo apt-get dselect-upgrade
= Hardy Heron 8.04 =
</pre>
These complex instructions are no longer necessary on newer versions of Ubuntu/Kubuntu (and are maintained here for reference only).
Normally you would just use ''[http://help.ubuntu.com/6.06/ubuntu/serverguide/C/apt-get.html sudo apt-get upgrade]''.


And reboot to run on the new kernel!
== Install Ubuntu ==
<pre>
*Download and burn an [http://www.ubuntu.com/products/GetUbuntu/download#lts Ubuntu 8.04 LTS server CD] to a Live CD.
sudo reboot
*Start the computer and boot from the Live CD.
</pre>
:*Select '''Install to hard drive'''.
:*Select your '''language''', '''country''', and '''keyboard layout''' (i.e. English, United States, American English)
:*Select '''[http://help.ubuntu.com/8.04/ubuntu/serverguide/C/network-configuration.html 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.


=== Install MySQL (skip Postgresql) ===
::<table>
At this point we'll need to log in again to the server and type:
::<tr><td width=%10>/boot</td><td width=%10>ext3</td><td align=right width=%10>200MB</td><td align=center width=%10>bootable</td>
<td>([http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/ref-guide/s1-grub-whatis.html may need to be under cylinder 1024 on your harddrive to be bootable])</td></tr>
::<tr><td>/</td><td>ext3</td><td align=right>10GB</td><td></td><td>(files are relatively static)</td></tr>
::<tr><td>swap</td><td></td><td align=right>4GB</td><td></td>
<td>(4xRAM if you don't have much memory, down to 1xRAM if you have gobs of memory)</td></tr>
::<tr><td>/var</td><td>ext3</td><td align=right>26GB</td><td></td><td>(variable content – uses rest of the drive)</td></tr>
::</table>


<pre>
:*Select your '''timezone'''. (i.e. Central)
sudo apt-get install mysql-server php5-mysql
:*Set clock to '''Universal Time'''.
</pre>
:*Enter Administrators '''full name'''. (i.e. Joe Smith)
Press ''Y'' to continue the install.
:*Enter '''account name'''. (i.e. joesmith)
:*Enter a secure password.  (‘abcde’ is not a good one!)
:*Reboot.


*Log in using your account name/password.


Replace the following string ''NewRootDatabasePassword'' with a secure password of your own choosing.
*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


There is no space between the ''-p'' and the password on the second command.
*Get the security updates.
<pre>
sudo apt-get update
mysqladmin -u root password NewRootDatabasePassword
sudo apt-get dselect-upgrade


mysqladmin -u root -h localhost password NewRootDatabasePassword -pNewRootDatabasePassword
:Normally you would just use ''[http://help.ubuntu.com/6.06/ubuntu/serverguide/C/apt-get.html sudo apt-get upgrade]''.
</pre>


We now need to create the Moodle database and Moodle user in MySQL.
*Reboot:
sudo reboot


The mysql command will prompt for your ''NewRootDatabasePassword'' (from above).
=== Install MySQL (skip Postgresql) ===
Replace ''NewMoodleDatabasePassword'' with a secure password of your own choosing.
sudo apt-get install mysql-server php5-mysql
<pre>
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
</pre>
The above also creates a backup user moodlebackup so that you can use ''mysqldump'' to make database backups without accident.


=== Install Postgresql (skip MySQL) ===
*Replace the following string ''NewRootDatabasePassword'' with a secure password of your own choosing.


At this point we'll need to log in again to the server and type:
There is no space between the ''-p'' and the password on the second command.
<pre>
mysqladmin -u root password NewRootDatabasePassword
sudo apt-get install postgresql-8.1 php5-pgsql
mysqladmin -u root -h localhost password NewRootDatabasePassword -pNewRootDatabasePassword
</pre>
Press Y to continue the install.


We now need to create the database user 'moodleuser'.
*Create the Moodle database and Moodle user in MySQL.
<pre>
sudo -u postgres createuser -D -A -P moodleuser
</pre>
Enter in a ''NewMoodleDatabasePassword here'', then answer 'N' to the question.


We now need to create the database 'moodle' for the user 'moodleuser'. You'll need to enter the password that you just created.
The mysql command will prompt for your ''NewRootDatabasePassword'' (from above).
<pre>
Replace ''NewMoodleDatabasePassword'' with a secure password of your own choosing.
sudo -u postgres createdb -E utf8 -O moodleuser moodle
</pre>
Let's now secure the postgresql database with an admin password.  
<pre>
sudo -u postgres psql template1
# ALTER USER postgres WITH PASSWORD 'NewAdminDatabasePassword';
# \q
</pre>
Edit the file '/etc/postgresql/8.1/main/pg_hba.conf' and on line 79 change the words ''ident sameuser'' to ''md5''.
<pre>
sudo nano /etc/postgresql/8.1/main/pg_hba.conf
</pre>
Restart the database so everything is fine.
<pre>
sudo /etc/init.d/postgresql-8.1 restart
</pre>


=== Install Apache ===
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 following mod-security, ldap, and odbc libraries are optional.
:The above also creates a backup user moodlebackup so that you can use ''mysqldump'' to make database backups without incident.
<pre>
sudo apt-get install apache2 libapache2-mod-php5 php5-gd


sudo apt-get install libapache2-mod-security php5-ldap php5-odbc
=== Install Postgresql (skip MySQL) ===
</pre>
sudo apt-get install postgresql-8.1 php5-pgsql


Restart Apache
*Create the database user 'moodleuser'.
<pre>
sudo -u postgres createuser -D -A -P moodleuser
sudo /etc/init.d/apache2 restart
</pre>


'''Note:''' To install Moodle 2.0 for the current ubuntu, you need to [http://moodle.org/mod/forum/discuss.php?d=116604 install PHP from an external repository] --[[User:Olli Savolainen|Olli Savolainen]] 19:28, 10 April 2009 (UTC)
:Enter in a ''NewMoodleDatabasePassword here'', then answer 'N' to the question.


=== Install other software ===
*Create the database 'moodle' for the user 'moodleuser'. Enter the password that you just created.
On the command line, type:
sudo -u postgres createdb -E utf8 -O moodleuser moodle
<pre>
sudo apt-get install openssh-server unattended-upgrades


sudo apt-get install unzip zip aspell-en aspell-fr aspell-de aspell-es
*Secure the postgresql database with an admin password.
sudo -u postgres psql template1
# ALTER USER postgres WITH PASSWORD 'NewAdminDatabasePassword';
# \q


sudo apt-get install curl php5-curl php5-xmlrpc
*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


sudo apt-get install clamav-base clamav-freshclam clamav
*Restart the database:
</pre>
sudo /etc/init.d/postgresql-8.1 restart
Press ''Y'' to continue the install after each of these apt-get commands.


The clamav package will support virus checking on file uploads into Moodle. May have to run it again to configure properly.
=== Install Apache ===


Additional languages are available for aspell.
*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


=== Install Moodle ===
*Restart Apache
On the command line, type:
sudo /etc/init.d/apache2 restart
<pre>
cd /var/www


sudo wget http://download.moodle.org/stable19/moodle-latest-19.tgz
=== 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
sudo apt-get install clamav-base clamav-freshclam clamav


sudo tar -zxf moodle-latest-19.tgz
=== Install Moodle ===


----
cd /var/www
in ubuntu 8.04 it should be:
sudo wget <nowiki>http://download.moodle.org/stable19/moodle-latest-19.tgz</nowiki>
sudo tar zxf moodle-latest-19.tgz
sudo tar -zxf moodle-latest-19.tgz
----


sudo mkdir /var/moodledata
:Note: in ubuntu 8.04 it should be: sudo tar zxf moodle-latest-19.tgz


sudo chown -R www-data:www-data /var/moodledata
sudo mkdir /var/moodledata
where www-data is whatever user/group was created automatically when apache was installed.
sudo chown -R www-data:www-data /var/moodledata
</pre>


We now need to 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.)
:where www-data is whatever user/group was created automatically when apache was installed.
<pre>
sudo nano /etc/apache2/sites-available/default 


sudo /etc/init.d/apache2 restart
*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.)
</pre>
sudo nano /etc/apache2/sites-available/default 
sudo /etc/init.d/apache2 restart


=== Configure Moodle website ===
=== Configure Moodle website ===
ifconfig (look for your server’s ip address on the 2nd line).
ifconfig
 
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.
:Note: look for your server’s ip address on the 2nd line


Go to a bar for a few hours.
*On another computer open a web browser and put in your server address. Make sure your web browser is set to accept cookies.


Come back and tell your boss that you FINALLY got the test server running.
*Complete the Moodle install using a secure username and password.


== Other Resources ==
= Other Resources =


* [http://kubuntuguide.org/Moodle_tips Kubuntuguide -- Moodle tips]
* [http://kubuntuguide.org/Moodle_tips Kubuntuguide -- Moodle tips]
* [http://ubuntuguide.org/Moodle_tips Ubuntuguide -- Moodle tips]
* [http://ubuntuguide.org/wiki/Moodle_tips Ubuntuguide -- Moodle tips]
* Setting up the [http://www.howtoforge.com/perfect_setup_ubuntu_6.06 Perfect Ubuntu 6.06 server]
* Setting up the [http://www.howtoforge.com/perfect_setup_ubuntu_6.06 Perfect Ubuntu 6.06 server]
* Ubuntu 6.06 Server Guide - [http://help.ubuntu.com/6.06/ubuntu/serverguide/C/index.html HTML] [http://help.ubuntu.com/6.06/pdf/ubuntu/C/serverguide.pdf PDF]
* Ubuntu 6.06 Server Guide - [http://help.ubuntu.com/6.06/ubuntu/serverguide/C/index.html HTML] [http://help.ubuntu.com/6.06/pdf/ubuntu/C/serverguide.pdf PDF]

Latest revision as of 16:01, 17 March 2011

This page requires a review. Please do so and remove this template when finished.


Installation Guide for Ubuntu

  • 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 without a desktop, and it is possible, but not recommended, to run Moodle on a standalone server without a desktop. 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

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).

Moodle installation

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.
http://localhost/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.

  • 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 webmaster@mymoodleserver.dyndns.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:
http://mymoodleserver.dyndns.org

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

Upgrades

Hardy Heron 8.04

These complex instructions are no longer necessary on newer versions of Ubuntu/Kubuntu (and are maintained here for reference only).

Install Ubuntu

  • 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.
/bootext3200MBbootable (may need to be under cylinder 1024 on your harddrive to be bootable)
/ext310GB(files are relatively static)
swap4GB (4xRAM if you don't have much memory, down to 1xRAM if you have gobs of memory)
/varext326GB(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!)
  • Reboot.
  • 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.
  • Reboot:
sudo reboot

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

Install Apache

  • 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
sudo apt-get install clamav-base clamav-freshclam clamav

Install Moodle

cd /var/www
sudo wget http://download.moodle.org/stable19/moodle-latest-19.tgz
sudo tar -zxf moodle-latest-19.tgz
Note: in ubuntu 8.04 it should be: 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

ifconfig
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.

Other Resources