Installing Moodle on an Ubuntu Workstation

From Wiki

Jump to:navigation, search

This is a simple guide to setting up Moodle on Ubuntu Linux (Breezy Badger) on a home system, for learning/experimentation purposes. It goes as far as getting Moodle up and running for the first time, but doesn't include any actual configuration of Moodle – this is best left for the official Moodle documentation. I felt the need to pull this information together after spending over a week trying to get Moodle installed and working on my system at home.

Information for Absolute Newcomers

Root and Ubuntu Linux

In a Linux installation, the administrator is known as root and usually has it's own password. Most operations that need root privileges will ask you for the root password or if you are working on the command line, you would swap to root for a time by typing su (for Super User) and then the password. This gives an element of protection and security to the system. You are advised not to work as root under normal operating circumstances. This is one of the ways that Linux helps protect you from virus infections and other problems.

Ubuntu is a little different and you need to understand the differences if you are to get the best from your system. When Ubuntu Linux is first installed, a normal user account is set up along with a password. When certain operations are attempted – for example going to synaptic package manager – you will be asked for your password. This is your normal user password. If you are working on the command line some operations will require su type privileges. In these instances you need to type sudo before the command and you will again be asked for the password. If you need to have a dedicated root account there is a way of setting one up, but for normal use you wouldn't need that.


Moodle is a stand alone package that can run on a single machine, a home network or from a Dedicated Web based Server. However it needs certain additional components for it to work.

These are:

  • it's own web server – we will use Apache2
  • a database – we will use Mysql
  • a scripting language – we will use PHP5

These need to be installed before Moodle. All the software is readily available using the extremely simple Ubuntu package system – Synaptic Package Manager or the manual command line “apt-get install *******”. However, when Ubuntu is first installed it only gives access to a percentage of the available packages and so has to be tweaked a little to make more packages available. This tweak is worth doing as it also gives access to such packages as MP3 codecs, video/DVD codecs and much more, which can't be included in the free Ubuntu CD due to licensing issues.

Initially I will use the “command line” installation, but any instance where I use “apt-get install” can be found using the synaptic package manager which is available from “System”, “Administration”.

Go to “Applications”, “Accessories”, “Terminal”. We need to edit a particular file. In Microsoft Windows, you could have gone to the file and opened it directly in an editor, however in Linux many operation like this are quickly performed from the command line.

sudo gedit /etc/apt/sources.list

You will be asked for your password and then a window will open with the contents of the sources.list file. You will notice that some lines have two ## symbols some one # and some none. The # symbol has the effect of telling the system to ignore these lines and so are just text lines for help purposes. gedit incidentally is the command to Get a file and Edit it, the file being sources.list and the location being in the etc folder and in a sub folder called apt.

If you go to “places”, “computer”, “filesystem” you will see all the folders in a similar way that you would by going to the C: drive in Windows. You could go to /etc/apt and you will see the sources.list file, but you wouldn't be able to edit it from here due to the security restrictions mentioned earlier.

Delete all the single # symbols so that each of these lines become active. there will be about six lines covering repositories such as universe and multiverse. Save and close the editor. At the command line type:

sudo apt-get update

This will update all your repository and package information and may take a minute or two.

Installing Apache2

 sudo apt-get install apache2

Installing PHP5

sudo apt-get install php5

We now need to restart apache

sudo /etc/init.d/apache2 restart

To test things so far, we are going to create a file using gedit (if you use gedit with a file name that doesn't exist, it will create the file)

sudo gedit /var/www/test.php 
- a window will open with a blank sheet.

type <? phpinfo(); ?> - then save and close

Open a browser by clicking on the blue globe on the task bar at the top (next to system) and in the address line type http://localhost/test.php if all has gone according to plan, you should now have a window with lots of information about PHP.

Installing MySQL

sudo apt-get install mysql-server 

If asked, choose the no configuration option

sudo apt-get install libapache2-mod-auth-mysql
sudo apt-get install php5-mysql
sudo /etc/init.d/apache2 restart
to restart the server.

There is a GUI interface for configuring the mysql server. You don't strictly speaking need it for this installation but I'm going to install it in case it's required in the future.

sudo apt-get install mysql-admin

You will find a new icon in Applications, System Tools, MYSQLadmin. You need server host name “localhost”, user “root” and no password.

Installing Moodle

sudo apt-get install moodle

Web server is apache2

Database is mysql-server

Server host name is localhost

admin username root leave password blank twice

owner moodle

finally go back to browser and go to http://localhost/moodle/admin and follow the screens to set up the moodle database and get into moodle. Initial user and password is admin/admin. You can change these and add additional users within Moodle.

See Moodle documentation at for further help.

Hope this helps and happy Moodling.