Installing Moodle

From Newroco Tech Docs
Jump to navigationJump to search

Prepreq

sudo apt-get install apache2
sudo apt-get install graphviz aspell php-pspell php-xmlrpc php-ldap php-soap
sudo apt-get install php-gd php-json php-pgsql php-curl
sudo apt-get install php-intl php-mcrypt php-imagick
sudo apt-get install php-zip php-xml php-mbstring php-ldap libapache2-mod-php
sudo apt-get install postgresql postgresql-contrib

Creating Moodle Database

These instructions assume that the database server and web server are on the same machine

Log into the PostgreSQL command line client. The exact form depends on how your PostgreSQL is configured but will be something like

$ psql -U postgres
Password for user postgres:

Create the user for the Moodle database and assign a password:

postgres=# CREATE USER moodleuser WITH PASSWORD 'quickM@ss50';

Provide a suitably strong password. Please note that the actual authentication method depends on your PostgreSQL server's pg_hba.conf file. Some authentication methods (like ident) do not require the password.

Create the database:

postgres=# CREATE DATABASE moodle WITH OWNER moodleuser;


Download and copy files into place

Setup your local repository and download Moodle, We will use /opt for this installation.

Git is what is called a "version control system". By using git it will much easier down the road to update the moodle core application. Within Step 5 there is a little more detail on why we put the moodle core application code in the /opt directory.

cd /opt

Download the Moodle Code and Index

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

Change directory into the downloaded Moodle folder

cd moodle

Retrieve a list of each branch available

sudo git branch -a

Tell git which branch to track or use

sudo git branch --track MOODLE_33_STABLE origin/MOODLE_33_STABLE

Finally, Check out the Moodle version specified

sudo git checkout MOODLE_33_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

Explanation

Since we setup a local repository in the previous step, you will copy it to your webroot after any updates and making changes. Having your local repository outside of the webroot, like we have in /opt, you will be able to prepare and stage your upgrades in a more efficient manner. For example, you want to make some changes or add some plug-ins, you would download the plugin and copy it to your local moodle repository. After you have added the plug-in and any other changes you might have made you will need to edit the file located in /opt/moodle/.git/info/exclude. Within that file you want to tell git which files/folders to exclude when it pulls down the updates when you run your next "sudo git pull". An example entry would be the certificate mod located in /opt/moodle/mod/certificate so within the exclude file you want to add "/mod/certificate" below the last comments. You would add additional entries, 1 per line, for each plug-in or file you might have changed. If I were to change the favicon.ico file you would just add "favicon.ico" to the exclude file. Now when you run "sudo git pull" to update moodle to the latest version it will ignore those files and directories and just update the core moodle code. Before copying to your webroot to upgrade you want to make sure and download and copy over the latest versions of the plug-ins you might have added.


IMPORTANT

While there are now a number of places you can get the Moodle code, you are strongly advised to obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.

Start Moodle install

Note - 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/html/moodle

Installer

Change the path for moodledata : /var/moodledata 

Database type : postgresql

Database Settings

Host server: localhost

Database: moodle

User: moodledude (the user you created when setting up the database)

Password: passwordformoodledude (the password for the user you created)

Tables Prefix: mdl_

Open your browser and go to http://IP.ADDRESS.OF.SERVER/moodle

Or

sudo -u www-data /usr/bin/php7.0 admin/cli/install.php

                                 .-..-.       
   _____                         | || |       
  /____/-.---_  .---.  .---.  .-.| || | .---. 
  | |  _   _  |/  _  \/  _  \/  _  || |/  __ \
  * | | | | | || |_| || |_| || |_| || || |___/
    |_| |_| |_|\_____/\_____/\_____||_|\_____)

Moodle 3.3.1+ (Build: 20170714) command line installation program
-------------------------------------------------------------------------------
== Choose a language ==
en - English (en)
? - Available language packs
type value, press Enter to use default value (en)
: en
-------------------------------------------------------------------------------
== Data directories permission ==
type value, press Enter to use default value (2777)
: 
-------------------------------------------------------------------------------
== Web address ==
type value
: https://moodle.dbsberlin.newro.co/moodle    
-------------------------------------------------------------------------------
== Data directory ==
type value, press Enter to use default value (/var/www/moodledata)
: /var/moodledata
-------------------------------------------------------------------------------
== Choose database driver ==
 pgsql 
type value, press Enter to use default value (pgsql)
: pgsql
-------------------------------------------------------------------------------
== Database host ==
type value, press Enter to use default value (localhost)
: localhost
-------------------------------------------------------------------------------
== Database name ==
type value, press Enter to use default value (moodle)
: moodle
-------------------------------------------------------------------------------
== Tables prefix ==
type value, press Enter to use default value (mdl_)
: mdl_
-------------------------------------------------------------------------------
== Database port ==
type value, press Enter to use default value ()
: 5432
-------------------------------------------------------------------------------
== Database user ==
type value, press Enter to use default value (root)
: user_moodle
-------------------------------------------------------------------------------
== Database password ==
type value
: parola_moodle
-------------------------------------------------------------------------------
== Full site name ==
type value
: Moodle
-------------------------------------------------------------------------------
== Short name for site (eg single word) ==
type value
: Moodle
-------------------------------------------------------------------------------
== Admin account username ==
type value, press Enter to use default value (admin)
: admin_moodle
-------------------------------------------------------------------------------
== New admin user password ==
type value
: parola_moodle
-------------------------------------------------------------------------------
== New admin user email address ==
type value, press Enter to use default value ()
: name@newro.co
-------------------------------------------------------------------------------
== Upgrade key (leave empty to not set it) ==
type value
: 
-------------------------------------------------------------------------------
== Copyright notice ==
Moodle  - Modular Object-Oriented Dynamic Learning Environment
Copyright (C) 1999 onwards Martin Dougiamas (http://moodle.com)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the Moodle License information page for full details:
http://docs.moodle.org/dev/License

Have you read these conditions and understood them?
type y (means yes) or n (means no)
: y
-------------------------------------------------------------------------------
== Setting up database ==
-->System
++ Success ++


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

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


For http

append into the confing file /var/www/http/moodle/config.php

$CFG->sslproxy=true;