Installing Moodle 3.4.1

I just discovered this Moodle system for online education on 8/31/2017 while visiting my daughter at her college. One of her courses was online hosted through a sub-domain called http://blackboard.<whatever>.edu/ and I got interested. Blackboard's bad reviews led me to Moodle.

Since I have plans to educate my potential clients about what I can do for them, I'm trying out the Moodle now. I think because they are educators, you don't need me to show you how to install their software, you can get it straight from them and they have a few options:

  1. Mere Mortals | non-Systems Administrators Installation Guide
  2. The computer room demi-gods | System Administrators Quick-start
  3. The cutting edge Git technicians | Git for Administrators

My video is a blend of those three incorporating as much Webmin interface as I can.

When installing on a Virtualmin managed web-server, create a Virtual Server or a Virtual Sub-Server that will host your Moodle site.

During set-up in the section for Enabled features, check the boxes for only:

  • DNS domain enabled?
  • Apache website enabled?
  • Apache SSL website enabled?
  • AWstats reporting

Now in a terminal window execute the following commands:

  • ssh <root user>@<your host or machine ip>
  • sudo apt-get install graphviz aspell php7.0-pspell php7.0-curl php7.0-gd php7.0-intl php7.0-mysql php7.0-xml php7.0-xmlrpc php7.0-ldap php7.0-zip
  • sudo apt-get install php-soap libapache2-mod-php7.0 ghostscript php-zip php7.0-xmlrpc php7.0-intl
  • sudo service apache2 restart
  • sudo apt-get install git-core
  • sudo mkdir /var/moodledata
  • sudo chmod -R 777 /var/moodledata
  • sudo chown -R www-data /var/moodledata
  • sudo mkdir /var/quarantine
  • sudo chown -R www-data /var/quarantine
  • sudo pico /etc/mysql/mysql.conf.d/mysqld.cnf (add the following in the [mysqld] section)
    • default_storage_engine = innodb
    • innodb_file_per_table = 1
    • innodb_file_format = Barracuda
  • sudo pico /etc/mysql/mysql.cnf (add the following at the end of the file)

    • [client]
    • default-character-set = utf8mb4

    • [mysqld]
    • innodb_file_format = Barracuda
    • innodb_file_per_table = 1
    • innodb_large_prefix

    • character-set-server = utf8mb4
    • collation-server = utf8mb4_unicode_ci
    • skip-character-set-client-handshake

    • [mysql]
    • default-character-set = utf8mb4

  • sudo service mysql restart
  • logout
  • ssh <virtual server owner>@<your host or machine ip>
  • cd domains/<subdomain>.<FQDN>/public_html (example of a Virtual Sub-Server / subdomain)
  • mkdir opt
  • cd opt/
  • git clone git://git.moodle.org/moodle.git
  • cd moodle/
  • git branch -a
  • git checkout MOODLE_34_STABLE (pick the right one for you, 3.4 was the best when I wrote this)
  • cd ../../
  • cp /opt/moodle ./
  • chmod -R 777 ./moodle
  • logout

Now that you have a valid moodle sub-directory in the root of your websites space, you need to change your Apache virtual servers .conf files to aim the DocumentRoot and <Directory paths for the new root which is just the old path plus /moodle appended to the end of it. Also in Virtualmin, you need to alter the Virtual Servers Server Configuration for Website Options where you'll change Website documents sub-directory from public_html to public_html/moodle. And now is an ideal time to make it a better SSL enabled site. Also in the Virtual Servers Server Configuration you click the Manage SSL Certificate module, then switch the tab to Let's Encrypt, and click the Request Certificate button (note: max renewal months is 3).

  • ssh <root user>@<your host or machine ip>
  • sudo mysql -u root -p
    • CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    • create user '<make up the user ID>'@'localhost' IDENTIFIED BY '<make up the password>';
    • GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO <user ID you just made>@localhost IDENTIFIED BY '<password you just made>';
    • quit;
  • sudo php /home/<virtual server owner>/domains/<subdomain>.<FQDN>/public_html/moodle/admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci
  • logout

Edit the

Go to the https://<subdomain>.<FQDN>/moodle page and answer the questions in the installation interview. As soon as you are done:

  • ssh <virtual server owner>@<your host or machine ip>
  • chmod -R 755 domains/<subdomain>.<FQDN>/public_html/moodle
  • logout

And that brings you to about this point, System Path's After Install.

Things to copy and paste for the command line installation:

  1. Like all your other installations of web served software, you want it to be in a directory of it's own. For example you may be uncreative and put it in /var/www/moodle/, or you may be structured and put in a sub-directory of your main Virtual Host's root folder /var/www/<my_site>/get2learnin/, but I can't say what's best, just make an empty folder that you can drop the Moodle software files into.
    • Others => File Manager
    • Navigate to /var/www/ then
    • Others => File Manager => File => Create a new directory
      • Type in your desired directory name (e.g. my-edu) and click the blue Create button
  2. Unlike the other installations a separate directory is where all the user data will be stored and accessed
    • Others => File Manager
    • Navigate to /usr/share/ then
    • Others => File Manager => File => Create a new directory
      • Type in your desired directory name for Moodledata (e.g. edu-data) and click the blue Create button
  3. Get the link for your Moodle download from Moodle => Downloads; my Stable release button points to 3.3.1+, a.k.a. https://download.moodle.org/download.php/stable33/moodle-latest-33.tgz
    • If you aren't still there, navigate into /var/www/ (or anywhere really) because you just need to get that compressed moodle-latest-33.tgz file on your server to unpack it
    • Others => File Manager => Files => Download from remote URL
      • paste https://download.moodle.org/download.php/stable33/moodle-latest-33.tgz in the textbox for "URL of file to download"
      • Click the Download button
    • In the Action column, click the "Extract Archive" tool which is where the "Edit" tool usually is on the row for the moodle-latest-33.tgz bundle
    • After it's done, enter the folder named "moodle-latest-33"
    • If you can't see all the folders and files (maybe XX items), change the "Show [_____] entries" value to get them all on one page
    • Click the Others => File Manager => "Select All" checkbox tool
    • Others => File Manager => Edit => Cut
    • Go back to the root directory for Moodle Virtual Host, e.g. /var/www/my-edu
    • Others => File Manager => Edit => Paste
    • Navigate back to /var/www/moodle-latest-33 and confirm the folder is empty. If not move the rest to your V.Host, e.g. /var/www/my-edu
    • Unless you plan on doing many Moodle installs, navigate back to /var/www and select check-box for moodle-latest-33.tgz
    • Click the "Remove Selected" icon, which should be a red square with a white garbage can in it
    • UNLIKE the Drupal and WordPress installations, set the owner & group for /var/www/my-edu is "root" by recursive chown. Apparently with their system having the "www-data" owner & group is a security hole.
      • Others => File Manager
      • Navigate to your V.Host's parent folder, e.g. /var/www/
      • Check the box to the left of your V.Hosts root folder e.g. my-edu
        • Others => File Manager => Tools => Change ownership
        • Type "root" into both the User name and Group name fields.
        • Check the box for Recursive
        • Click the button for Change
      • Again, check the box to the left of your V.Hosts root folder e.g. my-edu
        • Others => File Manager => Tools => Change permissions
        • Check all boxes in the Read row, all boxes in the Execute row, and only the Owner column of the Write row
        • Change the Apply to drop-down to Selected directories and subdirectories
        • Click the blue Change button
      • Again, check the box to the left of your V.Hosts root folder e.g. my-edu
        • Others => File Manager => Tools => Change permissions
        • Check all boxes in the Read row, UNCHECK all boxes in the Execute row, and only the Owner column of the Write row
        • Change the Apply to drop-down to Selected files and files under selected directories and subdirectories
        • Click the blue Change button
    • Almost optional: To use the built-in plugin installer you need to make the directory writable by web server user "www-data"
      • So far I haven't had to deal with Access Control List's. They are an awesome thing related to a file/folder's owner and group. To have a secure way to easily install plugins for Moodle you need to use the ACL system, so here is where we side track from the Moodle install ;)
        • Get the File ACL Module link for Webmin from bbou on SourceForge (see also their install instructions)
          • Webmin => Webmin Configuration => Webmin Modules
          • In the Install from section click the radio button for From ftp or http URL
          • Paste https://sourceforge.net/projects/webmin-fsacls/files/webmin-fsacls/webmin-fsacls-0.6.5/webmin-fsacls-0.6.5.wbm.gz/download or whatever the latest link is
          • Optionally click the radio button for Grant access to all Webmin users
          • Click the green Install Module button
      • Now we're back to Moodle things ;)
        • Navigate to your new module Others =>
        • Find the my-edu in /var/www/. with the
        • add user and group "www-data" to it's ACL and check the boxes for Read, Delete, Write, Append, File_inherit, & Directory_inherit
        • Click the green Commit button
    • Ensure the owner & group for /usr/share/edu-data is "www-data" by recursive chown
      • Others => File Manager
      • Navigate to the parent folder we made in step #2, e.g. /usr/share
      • Check the box to the left of the edu-data folder.
      • Others => File Manager => Tools => Change ownership
      • Type "www-data" (or whatever the standard on your system is for web server ownership) into both the User name and Group name fields.
      • Check the box for Recursive
      • Click the button for Change
  4. Make a blank database and create a user with all privileges on that database.
    • Servers => PostgreSQL Database Server => PostgreSQL Users => Create a new user
      • Give the user an appropriate name and make a note of it, e.g. admin4my-school
      • Click the radio button for Password Set to and enter a very secure password, e.g. 8*73%rHvbDjhPDF7^@5
      • Change the radio button for Can create databases? to Yes
      • Click the green Create button
    • Servers => PostgreSQL Database Server => Create a new database
      • Give it an appropriate name and make a note of it, e.g. data4my-school
      • Change the radio button for Owned by user to the drop-down then select your newly created user
      • About the section for Character set encoding, if your Moodle School will be in the same language & character set as your operating system is, leave the radio button set to Default. Otherwise you need to pick an appropriate set for your school.
      • Click the green Create button
    • Servers => PostgreSQL Database Server => Granted Privileges
  5. Make a new Virtual Host in Apache to point at the school's main directory
    • System => Apache Webserver => Create virtual host
    • Change the radio button for Handle connections to address to Specific address then type in your intranet IP for the machine it's operating from, e.g. 192.168._?_._?_
    • Change the radio button for Port to the blank text-box and write in 80 if it's a "http" type site, or 443 if it's a "https" type site, (see Activating the SSL on your Virtual Hosts for how to make a https site)
    • In the Document Root text-box type your /var/www/my-edu, or use the tool to navigate to that directory if you fear typo's
    • Change the radio button for Server Name to the blank text-box and write in your creative idea for new sub-domain or a FQDN that you own and is pointing at your server, e.g. go2skool.example.com or my-url-is-cool.com
    • Click the green Create Now button
  6. At long last, run the Moodle web installer
    • Open a web browser and type in the appropriate website for your Moodle School in; http:// / https:// + go2skool.example.com / my-url-is-cool.com
    • k
  7. These are critical-ish finishing up procedures...
    • eMail, if you have it for your FQDN,
    • Point your Moodle site to some helper programs
      • A directory inquiry program "du" (if you followed my whole guide) is probably already on your system at /usr/bin/du
        • You can check by the Webmin Alt-K window. To ask where the du is type "which du" and remember the path for the next step
        • Return to your Moodle site and go to, Administration => Site administration => Server => System paths then set the path for du binaries
      • The "dot" binary is related to the XHprof extension to the PHP system, aka: Hierarchical Profiler
        • Enter the following command in the Webmin Alt-K window:
          • pecl install -f xhprof
        • If you don't have a /var/tmp/xhprof directory yet, make one, if it is there make it Apache's
          • Go to Others => File Manager and navigate to /var/tmp, then look for xhprof
          • If you don't see xhprof, then Others => File Manager => File => Create new directory => New directory name and type xhprof
          • Click the check-box for xhprof and then Others => File Manager => Tools => Change ownership and write www-data in the User name and Group name fields and check the Recursive box
        • Now go to Others => PHP Configuration and on the line for /etc/php/7.0/cgi/php.ini Configuration for scripts run via CGI click the blue Edit Manually button
          • Use your Ctrl-F to open the finder and search for the "Dynamic Extensions" section. As you slowly scroll to the bottom of the section, look at all the commented out information they give for editing the file.
          • At the bottom of the section enter the following lines
            • [xhprof]
            • extension=xhprof.so
            • xhprof.output_dir="/var/tmp/xhprof"
          • And while it's open add this security measure; go to the bottom of the file and add this line
            • register_globals = Off
            • Click the white Save and close button
          • In the Webmin Alt-K window:
            • service apache2 restart
        • Wan't to test to see if that went well?
          • In the Webmin Alt-K window:
            • php -m
            • If xhprof is listed, you're golden, otherwise I can't help you. Ask Google.
        • Use the Others => File Manager => Tools => Search to look for dot
        • Your results will be varied because an image file called "cleardot.gif" is a valid return of the search for dot. You're looking for a path to a dot program that has a connection to the PHP software.
        • Return to your Moodle site and go to, Administration => Site administration => Server => System paths then set the path for dot /usr/share/php ? /tools/xhprof/ ? usr/share/base-files/ ?
      • The Moodle spelling checker looks for the aspell program, and for me I also want the English dictionary; "aspell" + "aspell-en". If you followed my whole guide, you probably don't have them so install them
        • System => Software Packages, click the radio button for Package from APT in the Install a New Package section then paste the following into the text-box: aspell aspell-en
        • Click the green Install button
        • Use the Alt-K window to ask where the aspell is by typing "which aspell" and remember the path for the next step
        • Return to your Moodle site and go to, Administration => Site administration => Server => System paths then set the path for aspell binaries
    • Check the timezone
      • Return to your Moodle site and go to, Administration => Site administration => Location => Update timezones
    • Set up the Cron garbage collection
      • Check your PHP vs. the Moodle
      • Best case, your PHP and the one Moodle runs with are compatible versions, then
        • System => Scheduled Cron Jobs => Create a new scheduled cron job
          • Set Execute cron job as to www-data
          • Set Active? radio button to Yes
          • Set Command to /usr/bin/php
          • Set Input to command to /var/www/my-edu/admin/cli/cron.php >/dev/null
          • In the When to execute section click the radio button for Times and dates selected below .. and leave the radio buttons for Minutes, Hours, Days, Months, & Weekdays set to All
      • Second best case
        • System => Scheduled Cron Jobs => Create a new scheduled cron job
          • Set Execute cron job as to www-data
          • Set Active? radio button to Yes
          • Set Command to /usr/bin/curl
          • Set Input to command to http://go2skool.example.com/admin/cron.php -o /dev/null/ -silent
          • In the When to execute section click the radio button for Times and dates selected below .. and leave the radio buttons for Minutes, Hours, Days, Months, & Weekdays set to All
  8. And, well, keep on going form there; see https://docs.moodle.org/33/en/Installing_Moodle#Remaining_tasks

Log in to a shell window as the admin of the webserver that the site hosts from, then:

  • cd /path/to/your/moodle/
  • git pull
  • php ~bin/composer install
  • php ~bin/composer update
  • Go back to your Administration section of your Moodle site and follow the prompts to finish the upgrade.

Next Page: Moodle.org or Moodle.net