Installing Moodle

From Newroco tech docs
Jump to: navigation, search

Prepreq

  1.  
  2. sudo apt-get install apache2
  3. sudo apt-get install graphviz aspell php-pspell php-xmlrpc php-ldap php-soap
  4. sudo apt-get install php-gd php-json php-pgsql php-curl
  5. sudo apt-get install php-intl php-mcrypt php-imagick
  6. sudo apt-get install php-zip php-xml php-mbstring php-ldap libapache2-mod-php
  7. sudo apt-get install postgresql postgresql-contrib
  8.  

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

  1.  
  2. $ psql -U postgres
  3. Password for user postgres:
  4.  

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

  1.  
  2. postgres=# CREATE USER moodleuser WITH PASSWORD 'quickM@ss50';
  3.  

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:

  1.  
  2. postgres=# CREATE DATABASE moodle WITH OWNER moodleuser;
  3.  


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.

  1.  
  2. cd /opt
  3.  

Download the Moodle Code and Index

  1.  
  2. sudo git clone git://git.moodle.org/moodle.git
  3.  
  4. or
  5.  
  6. sudo git clone git://github.com/moodle/moodle.git
  7.  
  8.  

If the error appear

  1.  
  2. fatal: The remote end hung up unexpectedly7.96 MiB | 179.00 KiB/s
  3. fatal: early EOF
  4. fatal: index-pack failed
  5.  

try

  1.  
  2. git config --global http.postBuffer 524288000
  3.  

Or

  1.  
  2. git config --global core.compression 0
  3.  
  4. Next, let's do a partial clone to truncate the amount of info coming down:
  5.  
  6. git clone --depth 1 <repo_URI>
  7.  
  8. When that works, go into the new directory and retrieve the rest of the clone:
  9.  
  10. git fetch --unshallow
  11.  
  12. or, alternately,
  13.  
  14. git fetch --depth=2147483647
  15.  
  16. Now, do a regular pull:
  17.  
  18. git pull --all
  19. </code/
  20.  
  21. Change directory into the downloaded Moodle folder
  22. <code>
  23. cd moodle
  24.  

Retrieve a list of each branch available

  1.  
  2. sudo git branch -a
  3.  

Tell git which branch to track or use

  1.  
  2. sudo git branch --track MOODLE_33_STABLE origin/MOODLE_33_STABLE
  3.  

Finally, Check out the Moodle version specified

  1.  
  2. sudo git checkout MOODLE_33_STABLE
  3.  

Copy local repository to /var/www/html/

  1.  
  2. sudo cp -R /opt/moodle /var/www/html/
  3. sudo mkdir /var/moodledata
  4. sudo chown -R www-data /var/moodledata
  5. sudo chmod -R 777 /var/moodledata
  6. sudo chmod -R 0755 /var/www/html/moodle
  7.  

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:

  1.  
  2. sudo chmod -R 777 /var/www/html/moodle
  3.  

Installer

  1.  
  2. Change the path for moodledata : /var/moodledata
  3.  
  4. Database type : postgresql
  5.  
  6. Database Settings
  7.  
  8. Host server: localhost
  9.  
  10. Database: moodle
  11.  
  12. User: moodledude (the user you created when setting up the database)
  13.  
  14. Password: passwordformoodledude (the password for the user you created)
  15.  
  16. Tables Prefix: mdl_
  17.  
  18. Open your browser and go to http://IP.ADDRESS.OF.SERVER/moodle
  19.  

Or

  1.  
  2. sudo -u www-data /usr/bin/php7.0 admin/cli/install.php
  3.  
  4. .-..-.
  5. _____ | || |
  6. /____/-.---_ .---. .---. .-.| || | .---.
  7. | | _ _ |/ _ \/ _ \/ _ || |/ __ \
  8. * | | | | | || |_| || |_| || |_| || || |___/
  9. |_| |_| |_|\_____/\_____/\_____||_|\_____)
  10.  
  11. Moodle 3.3.1+ (Build: 20170714) command line installation program
  12. -------------------------------------------------------------------------------
  13. == Choose a language ==
  14. en - English (en)
  15. ? - Available language packs
  16. type value, press Enter to use default value (en)
  17. : en
  18. -------------------------------------------------------------------------------
  19. == Data directories permission ==
  20. type value, press Enter to use default value (2777)
  21. :
  22. -------------------------------------------------------------------------------
  23. == Web address ==
  24. type value
  25. : https://moodle.dbsberlin.newro.co/moodle
  26. -------------------------------------------------------------------------------
  27. == Data directory ==
  28. type value, press Enter to use default value (/var/www/moodledata)
  29. : /var/moodledata
  30. -------------------------------------------------------------------------------
  31. == Choose database driver ==
  32. pgsql
  33. type value, press Enter to use default value (pgsql)
  34. : pgsql
  35. -------------------------------------------------------------------------------
  36. == Database host ==
  37. type value, press Enter to use default value (localhost)
  38. : localhost
  39. -------------------------------------------------------------------------------
  40. == Database name ==
  41. type value, press Enter to use default value (moodle)
  42. : moodle
  43. -------------------------------------------------------------------------------
  44. == Tables prefix ==
  45. type value, press Enter to use default value (mdl_)
  46. : mdl_
  47. -------------------------------------------------------------------------------
  48. == Database port ==
  49. type value, press Enter to use default value ()
  50. : 5432
  51. -------------------------------------------------------------------------------
  52. == Database user ==
  53. type value, press Enter to use default value (root)
  54. : user_moodle
  55. -------------------------------------------------------------------------------
  56. == Database password ==
  57. type value
  58. : parola_moodle
  59. -------------------------------------------------------------------------------
  60. == Full site name ==
  61. type value
  62. : Moodle
  63. -------------------------------------------------------------------------------
  64. == Short name for site (eg single word) ==
  65. type value
  66. : Moodle
  67. -------------------------------------------------------------------------------
  68. == Admin account username ==
  69. type value, press Enter to use default value (admin)
  70. : admin_moodle
  71. -------------------------------------------------------------------------------
  72. == New admin user password ==
  73. type value
  74. : parola_moodle
  75. -------------------------------------------------------------------------------
  76. == New admin user email address ==
  77. type value, press Enter to use default value ()
  78. : name@newro.co
  79. -------------------------------------------------------------------------------
  80. == Upgrade key (leave empty to not set it) ==
  81. type value
  82. :
  83. -------------------------------------------------------------------------------
  84. == Copyright notice ==
  85. Moodle - Modular Object-Oriented Dynamic Learning Environment
  86. Copyright (C) 1999 onwards Martin Dougiamas (http://moodle.com)
  87.  
  88. This program is free software: you can redistribute it and/or modify
  89. it under the terms of the GNU General Public License as published by
  90. the Free Software Foundation, either version 3 of the License, or
  91. (at your option) any later version.
  92.  
  93. This program is distributed in the hope that it will be useful,
  94. but WITHOUT ANY WARRANTY; without even the implied warranty of
  95. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  96.  
  97. See the Moodle License information page for full details:
  98. http://docs.moodle.org/dev/License
  99.  
  100. Have you read these conditions and understood them?
  101. type y (means yes) or n (means no)
  102. : y
  103. -------------------------------------------------------------------------------
  104. == Setting up database ==
  105. -->System
  106. ++ Success ++
  107.  


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.

  1.  
  2. sudo chmod -R 0755 /var/www/html/moodle
  3.  


For http

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

  1.  
  2. $CFG->sslproxy=true;
  3.