David Stilson

  Linux System Administration

Installing Moodle

 Follow these steps to install Moodle on a Debian-based Linux server:

 NOTE: Many Moodle installations guides suggest that you install a LAMP stack with one command. I don't like this method as there  are many items that are not installed, esp. PHP add-ons.

 NOTE:The following commands are done at the command line. You will need the root password.

- Update the Ubuntu repositories:

     sudo apt-get update

- Update the Ubuntu packages:

      sudo apt-get upgrade

- Install secure shell:

     sudo apt-get install openssh -server

- Install Apache2:

     sudo apt-get install apache2 apache2-utils apache2-mpm-prefork

- Test Apache:

     sudo /etc/init.d/apache2 status

     * apache2 is running

- Install MySQL; NOTE: during the installation you will be promted to create a root user name and password:

     sudo apt-get install mysql-server mysql-client

     sudo /etc/init.d/mysql start

- Install phpmyadmin:

     sudo apt-get install phpmyadmin

- Install PHP. Be aware that Moodle needs more PHP add-ons than are installed with standard installation:

     sudo apt-get install PHP5 libapache2-mod-php5 php5-curl php5-gd php5-common php5-cli php5-mysql php5-mcrypt        php5-xmlrpc php5-intl

      sudo php5enmod mcrypt

- To test what has been installed so far:

     dpkg --list | grep -e apache -e mysql -e php

- Restart Apache

     sudo service apache2 restart

- Use git to install/update the Moodle Core application

     sudo apt-get install git-core

- Setup your local repository and download Moodle, use /opt for this installation

     sudo git clone git://git.moodle.org/moodle.git

     cd moodle

     sudo git branch -a

     sudo git branch --track MOODLE_27_STABLE origin/MOODLE_27_STABLE

     sudo git checkout MOODLE_27_STABLE

- Copy local repository to /var/www/html/

     sudo cp -R /opt/moodle /var/www/html

     sudo mkdir /var/moodledata

     sudo chown -R www-data /var/moodledata

     sudo chmod -R 777 /var/moodledata

     sudo chmod -R 0755 /var/www/html/moodle

- create the Moodle MySQL User with the correct permissions. Use password created during MySQL install.

     mysql -u root -p

     mysql>CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

- Use your username and password of your choosing:



- If you are not comfortable using terminal to create the config.php file that needs to be created when going through the installer, you should temporarily make the webroot writable by doing the following:

     sudo chmod -R 777 /var/www/moodle

- After you have run the installer and you have moodle setup, you NEED to revert permissions so that it is no longer writable using the below command..

     sudo chmod -R 755 /var/www/moodle

- Open your browser and go to http://IP.ADDRESS.OF.SERVER/moodle
     Follow the prompts selecting:
     Database Type: Choose: mysqli
     Database: moodle
     Password: the DB password for the user you created>
     Tables Prefix: mdl_

- If you made the webroot writable, revert permissions

     sudo chmod -R 0755 /var/www/moodle

- After installing Moodle you should set the system paths.
     Navigate to Site Administration > Server > System Paths
     Path to Du: /usr/bin/du
     Path to Apsell: /usr/bin/aspell
     Path to dot: /usr/bin/dot
     Save Changes

- Setup the cron job
     sudo crontab -u www-data -e
     Add the following line to run the cron job every 15 minutes.
     */15 * * * * /usr/bin/php /path/to/moodle/admin/cli/cron.php >/dev/null

- The default Maximum upload file size is 2MB. This will need to be increased.
     Check current Maximum uploaded file size setting: site administration>security>site policies
     sudo gedit /etc/init.d/apache2/php.ini
     post_max_size 100M
     upload_max_filesize 100M
     max_execution_time 600
     sudo /etc/init.d/apache2 force-reload
     Check/change Maximum uploaded file size setting: site administration>security>site policies. It should now be set for 100MB