Bitnami Moodle

    Moodle is a Course Management System that is designed using sound pedagogical principles to help educators create effective online learning communities. It can scale from one computer to a 50,000-student university and is used in 175 countries around the world.

    Please, take a look to the Quick Start Guide to know the basic use of this Stack.

    How to start/stop the servers?

    Cloud Images

    Each Bitnami stack includes a control script that lets you easily stop, start and restart servers.

    The script is located at /opt/bitnami/ctlscript.sh. Call it without any arguments to restart all services:

    $ sudo /opt/bitnami/ctlscript.sh start
    

    Or use it to restart a specific service only by passing the service name as argument - for example 'mysql':

    $ sudo /opt/bitnami/ctlscript.sh restart mysql
    

    Virtual Machine

    Each Bitnami stack includes a control script that lets you easily stop, start and restart servers.

    The script is located at /opt/bitnami/ctlscript.sh. Call it without any arguments to restart all services:

    $ sudo /opt/bitnami/ctlscript.sh start
    

    Or use it to restart a specific service only by passing the service name as argument - for example 'mysql':

    $ sudo /opt/bitnami/ctlscript.sh restart mysql
    

    Native Installer

    You can use either the graphical manager tool or the command-line tool to start and stop the servers.

    Graphical Tool

    Bitnami stacks include a graphical tool to manage the servers easily (native installers only). Using this tool, you can start, stop and restart the servers and check the log files.

    manager-servers.png

     

     

     

     

     

     

     

     

     

     

    On Windows:

    • Double-click the "manager-windows.exe" file in your installation directory.  
    • You can also start the Manager tool using the Start Menu path Start -> Program Files -> Bitnami Stack -> Manager.

    On Linux and Mac OS X:

    • Double-click the "manager-osx" or "manager-linux-*" tool in your installation directory. 
    Command-line Tool

    Each Bitnami stack includes a control script that lets you easily stop, start and restart servers.

    The control script is only available for Linux and Mac OS X native installers. The script is located in your installation directory and named ctlscript.sh. Call it without any arguments to restart all services.

    On Linux:
    If your installation directory is /home/USER/wordpress-4.0.1-0, call the control script with the ‘start’ argument to start all servers. For example:

    $ cd /home/USER/wordpress-4.0.1-0
    $ ./ctlscript.sh start
    

    Or use it to restart a specific service only by passing the service name as argument - for example 'mysql':

    $ cd /home/USER/wordpress-4.0.1-0
    $ ./ctlscript.sh restart mysql
    

    On Mac OS X:
    If your installation directory is /Applications/wordpress-4.0.1-0, call the control script with the ‘start’ argument to start all servers. For example:

    $ cd /Applications/wordpress-4.0.1-0
    $ ./ctlscript.sh start
    

    Or use it to restart a specific service only by passing the service name as argument - for example 'mysql':

    $ cd /Applications/wordpress-4.0.1-0
    $ ./ctlscript.sh restart mysql
    

    Tabs end

    How to change the default URL?

    This approach describes how to configure your application to run in the root URL directly. Also, you will be able to modify the URL to a NEW_DOMAIN using the bnconfig tool. The details are described below.

    Automatic Approach

    This approach is based on the Bitnami Configuration Tool (bnconfig).

    Bitnami Cloud Hosting

    The best way to change your URL in BCH is to go to your application tab and modify it there. In the Bitnami Cloud Hosting console, select Servers, choose your server, Manage and go to the Applications tab. Press there the pencil next to the application which URL you want to modify and choose .

    Refer to this guide for more information.

    Cloud Images and Virtual Machines

    Moving the application to /

     If your application is running in "/moodle" you can remove the prefix from the URL executing the following command:

    $ sudo /opt/bitnami/apps/moodle/bnconfig --appurl /
    

    (use --help to check if that option is available for your application)

    Now you will be able to access to the application at http://YOUR_DOMAIN instead of http://YOUR_DOMAIN/moodle.

    Updating the IP or hostname

    Some applications require to update the IP/domain if the machine IP/domain changes. The bnconfig tool also has an option which updates the IP automatically during boot, called machine_hostname (use --help to check if that option is available for your application). Note that this tool changes the URL to http://NEW_DOMAIN/moodle

    sudo /opt/bitnami/apps/moodle/bnconfig --machine_hostname NEW_DOMAIN
    

    If you already moved your application to the root URL you should include both options at the same time.

    sudo /opt/bitnami/apps/moodle/bnconfig --appurl / --machine_hostname NEW_DOMAIN
    

    If you have configured your machine to use an static domain name or IP, you should rename or remove the "/opt/bitnami/apps/moodle/bnconfig" file.

    sudo mv /opt/bitnami/apps/moodle/bnconfig /opt/bitnami/apps/moodle/bnconfig.disabled
    

    Native Installer

    Remember to use your actual installation directory instead of installdir.

    Moving the application to /

    If your application is running in "/moodle" you can remove the prefix from the URL executing the following command:

    On Linux,

    installdir/apps/moodle/bnconfig --appurl /
    

    On Mac OS X, 

    installdir/apps/moodle/bnconfig.app/Contents/MacOS/installbuilder.sh --appurl /
    

    On Windows,

    installdir/apps/moodle/bnconfig.exe --appurl /
    

    (use --help to check if that option is available for your application)

    Now you will be able to access to the application at http://YOUR_DOMAIN instead of http://YOUR_DOMAIN/moodle.

    Updating the IP or hostname

    Some applications require to update the IP/domain if the machine IP/domain changes. The bnconfig tool also has an option which updates the IP , called machine_hostname (use --help to check if that option is available for your application). Note that this tool changes the URL to http://NEW_DOMAIN/moodle.

    installdir/apps/moodle/bnconfig --machine_hostname NEW_DOMAIN
    

    If you already moved your application to the root URL you should include both options at the same time.

    installdir/apps/moodle/bnconfig --appurl / --machine_hostname NEW_DOMAIN
    

    Tabs end

    Manual Approach

    If you want to change the default URL from http://your_domain/moodle to http://your_domain, edit the installdir/apps/moodle/conf/httpd-prefix.conf file so that it looks like the file below:

    DocumentRoot "/installdir/apps/moodle/htdocs"
    # Alias /moodle/ "/installdir/apps/moodle/htdocs/"
    # Alias /moodle "/installdir/apps/moodle/htdocs"
    
    (...)
    
     
    Remember that you must substitute installdir with your actual installation directory (for native installers) or /opt/bitnami (for cloud images and virtual machines).

    Some applications also require additional changes in their configuration files or in their database.

    In the Moodle case, it is also necessary to specify the new URL in the /installdir/apps/moodle/htdocs/config.php file:

    $CFG->wwwroot   = 'http://NEW_DOMAIN';
    

    How to create a full backup of Moodle?

    Backup

    Bitnami stacks are self-contained and the simplest option for performing a backup is to copy or compress the Bitnami stack installation directory. To do so in a safe manner, you will need to stop all servers, so this method may not be appropriate if you have people accessing the application continuously.

    Cloud Server

    Follow these steps:

    • Change to the directory in which you wish to save your backup.
      cd /your/directory
      
    • Stop all servers.
      $ sudo /opt/bitnami/ctlscript.sh stop
      
    • Create a compressed file with the stack contents.
      $ sudo tar -pczvf application-backup.tar.gz /opt/bitnami
    • Restart all servers.
      $ sudo /opt/bitnami/ctlscript.sh start

    You should now download or transfer the application-backup.tar.gz file to a safe location.

    Virtual Machine

    Follow these steps:

    • Change to the directory in which you wish to save your backup.
      cd /your/directory
      
    • Stop all servers.
      $ sudo /opt/bitnami/ctlscript.sh stop
    • Create a compressed file with the stack contents.
      $ sudo tar -pczvf application-backup.tar.gz /opt/bitnami
    • Restart all servers.
      $ sudo /opt/bitnami/ctlscript.sh start
      

    You should now download or transfer the application-backup.tar.gz file to a safe location.

    Native Installer (Windows)

    Follow these steps:

    • Stop all servers using the shortcuts in the Start Menu or the graphical manager tool.
    • Create a compressed file with the stack contents. You can use a graphical tool like 7-Zip or WinZip.
    • Stop all servers using the shortcuts in the Start Menu or the graphical manager tool.

    You should now download or transfer the application-backup.zip file to a safe location.

    Native Installer (Linux and Mac OS X)

    Follow these steps:

    • Change to the directory in which you wish to save your backup.
      cd /your/directory
      
    • Stop all servers.
      $ sudo installdir/ctlscript.sh stop
      
    • Create a compressed file with the stack contents.
      $ sudo tar -pczvf application-backup.tar.gz installdir
      
    • Restart all servers.
      $ sudo installdir/ctlscript.sh start
      

    You should now download or transfer the application-backup.tar.gz file to a safe location.

    Tabs end

    Restore

    Bitnami stacks are self-contained, so to restore a stack, you only need to uncompress the backup file in the same location. It is important to use the same path that was used when the stack was originally installed.

    Cloud Server

    Follow these steps:

    • Change to the directory containing your backup.
      cd /your/directory
      
    • Stop all servers.
      $ sudo /opt/bitnami/ctlscript.sh stop
    • Rename the current directory to save it.
      $ sudo mv /opt/bitnami /opt/bitnamiBackup
    • Uncompress the backup file to the original directory.
      $ sudo tar -pxzvf application-backup.tar.gz -C /
    • Start all servers.
      $ sudo /opt/bitnami/ctlscript.sh start
      

    Virtual Machine

    Follow these steps:

    • Change to the directory containing your backup.
      cd /your/directory
      
    • Stop all servers.
      $ sudo /opt/bitnami/ctlscript.sh stop
    • Rename the current directory to save it.
      $ sudo mv /opt/bitnami /opt/bitnamiBackup
    • Uncompress the backup file to the original directory.
      $ sudo tar -pxzvf application-backup.tar.gz -C /
    • Start all servers.
      $ sudo /opt/bitnami/ctlscript.sh start
      

    Native Installer (Windows)

    Follow these steps:

    • Uncompress the backup file to the original directory.
    • Install services by launching a new command prompt and executing the following commands. Administrator privileges are required.
      $ cd installdir
      $ serviceinstall.bat INSTALL
      

    You can now start or stop servers using the graphical manager tool.

    Native Installer (Linux and Mac OS X)

    Follow these steps:

    • Change to the directory containing your backup.
      cd /your/directory
      
    • Stop all servers.
      $ sudo /opt/bitnami/ctlscript.sh stop
      
    • Rename the current directory to save it.
      $ sudo mv installdir installdirBackup
    • Uncompress the backup file to the original directory.
      $ sudo tar -pxzvf application-backup.tar.gz -C /
      
    • Start all servers.
      $ sudo installdir/ctlscript.sh start
      

    Tabs end

    IMPORTANT: When restoring, remember to maintain the original permissions for the files and folders. For example, if you originally installed the stack as 'root', make sure that the restored files are owned by 'root'.


    If you want to create only a database backup, refer to these instructions for MySQL and PostgreSQL.

    How to upgrade Moodle?

    It is strongly recommended that you create a backup before starting the update process. If you have important data, it is advisable that you create and try to restore a backup to ensure that everything works properly.

    There are two different ways to upgrade your application.

    1. If you want to upgrade the application and all Moodle Stack components PHP, MySQL, Apache… You can follow the steps described at How to migrate the Moodle Stack?
    2. In case you only want to upgrade the application code without modifying any other Stack components,  you should follow the guide which is in the application page itself.

    For upgrading the Moodle application you can follow this quick guide. Before upgrading your current installation it is important to create a backup of the server. This guide shows how to upgrade Moodle in a Bitnami cloud server

    - Move your current Moodle files:

    $ sudo mv /opt/bitnami/apps/moodle/htdocs /opt/bitnami/apps/moodle/htdocs.backup
    

    - Download the new Moodle version. In this case we use the link to the latest 2.6.1 version.

    $ wget http://download.moodle.org/download.php/direct/stable26/moodle-latest-26.tgz

    - Create a new folder and uncompress the files:

    $ sudo mkdir /opt/bitnami/apps/moodle/htdocs
    $ sudo tar -xzvf moodle-latest-26.tgz -C /opt/bitnami/apps/moodle/htdocs --strip 1

    - Copy your previous configuration file and your modules or themes:

    $ sudo cp /opt/bitnami/apps/moodle/htdocs.backup/config.php /opt/bitnami/apps/moodle/htdocs
    $ sudo cp -rp /opt/bitnami/apps/moodle/htdocs.backup/theme/mytheme /opt/bitnami/apps/moodle/htdocs/theme/
    $ sudo cp -rp /opt/bitnami/apps/moodle/htdocs.backup/mod/mymod /opt/bitnami/apps/moodle/htdocs/mod/

    - Then go to your application from a browser and follow the steps to upgrade the database to the latest version.

    Note: If you want to install modules or plugins from the Moodle administration panel, check the section below.

    How to migrate your Moodle installation?

    There are two importants steps when migrating a Moodle Stack: migrate the database and migrate the Moodledata folder (you may want to migrate the Themes and Modules folders if you have them installed and you want to keep them). To make the process easier, we are going to divide them in four substeps.

    1. Export the database

    You can do it manually or using phpMyAdmin. If you use the phpMyAdmin option, export it as .sql file.

    2. Copy the moodledata folder

    In this step, you just need to copy the moodledata folder, located in YOUR_INSTALLATION_DIRECTORY/apps/moodle/moodledata, to the machine where you have installed the new Moodle. When doing this step, copy the exported database file too. If you have themes or modules installed and you want to keep them, you also have to copy them.

    3. Import the database

    First of all, you have to delete the tables in the bitnami_moodle database. To do so, the easiest way could be accessing phpMyAdmin, choosing the bitnami_moodle database, selecting all the tables and dropping them.

    Other option could be to do it manually. When we use BITNAMI_USER_PASSWORD here, you have to substitute it for the password that is in the config.php file (YOUR_INSTALLATION_DIRECTORY/apps/moodle/htdocs/config.php), $CFG->dbpass    = 'BITNAMI_USER_PASSWORD';

    mysql -u root -p
    mysql> drop database bitnami_moodle;
    mysql> create database bitnami_moodle;
    mysql> grant all privileges on bitnami_moodle.* to 'bitnami'@'localhost'
    identified by 'BITNAMI_USER_PASSWORD';
    mysql> flush privileges;
    mysql> exit;
    

    After that, import the database. You can do it manually or using phpMyAdmin.

    4. Substitute moodledata (and others) folder

    Finally, you just need to substitute the moodledata folder, as well as the Themes and Modules folders if you want.

    Once this steps are done, restart the Apache server and access Moodle through the browser. If you login as administrator, you will be asked to update your database. Click to do it and the migration of your Moodle stack will be completed.

    Thanks to @aguayomanel and @pivot_1990_69 for their guides.

    How to configure the email settings for Moodle?

    This is required so your application can send notifications via email. If you are using the Native installers, you can configure it during the installation. If you are using the Virtual Machines or AMI's you can configure the email settings manually. You can find below an example of configuring the email using a GMail account from the Moodle Administration Panel.

    Log in as the admin user and go to Site administration -> Plugins -> Message outputs -> Email.

    SMTP hosts = smtp.gmail.com:465
    
    SMTP security = SSL
    
    SMTP username: your gmail account (including @gmail.com)
    
    SMTP password: your gmail password
    

    moodle_email.png

    How to secure your installation?

    One of our main goals is to configure Bitnami applications in the most secure way. However sometimes we need to find a compromise between security and easy to use.

    This is the case with Moodle since its version 2.5. In Moodle 2.5 a new feature for installing add-ons from the admin web interface has been implemented. However to allow this feature on Unix, it is required to grant write permissions to the web server group. You can make more secure your configuration by disabling this feature and installing Moodle plugins copying the files to the right directory. However this will require to upload the files to your server using other tools like SFTP client tools or scp.

    How to install a plugin in Moodle?

    You can follow the official Moodle documentation.  Below you can find relevant information about the Bitnami configuration.

    From the web interface

    Since Moodle 2.5 you can install any plugin from the Moodle administration panel. This is the default configuration for virtual machines, cloud images. With the native stack this method is available if you select "development" mode during the installation.

    Manually uploading the files

    With this method you need to copy and uncompress the plugin to the server file system in the correct folder. You can check that the module has been correctly installed in Settings > Site administration > Notifications (as Moodle admin user). With the native stack this method is available if you select "production" mode during the installation. In virtual machines and cloud images you can disable the web installer tool method and sse a SFTP client or use scp for manually copying the files.

    How to disable the admin web interface option for installing add-ons?

    For hidding this option from the admin web interface edit the configuration file /installdir/apps/moodle/htdocs/config.php and set:

    $CFG->disableonclickaddoninstall = true;
    

    On Unix systems you also should remove the write permissions from the web server group in the Moodle folders:

    find /installdir/apps/moodle/htdocs -type d 755
    

    Where /installdir/ is the installation directory. In virtual machines and cloud images the installation directory is /opt/bitnami.

    How to enable SSL?

    You can see how to configure Apache to enable SSL connections at How to enable SSL to access through https?

    How to debug Moodle errors?

    Once Apache starts, it will create two log files, the access_log and the error_log /installdir/apache2/logs directory or in /var/log/httpd if you are using Amazon Linux or Red Hat Enterprise cloud images.

    In Virtual Machines, Cloud Images and Ubuntu based Bitnami Cloud Hosting images installdir is /opt/bitnami.

    The access_log file is used to track client requests. When a client requests a document from the server, Apache records several parameters associated with the request in this file, such as: the IP address of the client, the document requested, the HTTP status code, and the current time.

    The error_log file is used to record important events. This file includes error messages, startup messages, and any other significant events in the life cycle of the server. This is the first place to look when you run into a problem when using Apache.

    If no error is found, you will see a message similar to:

    Syntax OK
    /installdir/ctlscript.sh : httpd started
    

    The main MySQL log file is created at /installdir/mysql/data/mysqld.log file.

    How to increase the allowed size of the uploaded files?

    You can modify the following option in the php.ini file to increase the allowed size for uploads:

    ; Maximum size of POST data that PHP will accept.
    post_max_size = 16M
    
    ...
    
    ; Maximum allowed size for uploaded files.
    upload_max_filesize = 16M
    

    If you have enabled PHP-FPM (enabled by default in Cloud Images and VMs) you need to restart PHP-FPM running the following command:

    sudo /opt/bitnami/ctlscript.sh restart php-fpm
    

    Note: For native installers replace /opt/bitnami with your current installation directory.

    Otherwise, you need to restart the Apache server:

    sudo YOUR_INSTALLATION_DIRECTORY/ctlscript.sh restart apache

    How to install cron task for Moodle?

    Moodle requires to run a cron task that must be run regularly. The Administrator user can do that from the Admin panel -> Site Adminitration -> Notifications. In case you want to run this task in the background, you can create a cron task.

    To edit the crontab you can run the following command and add the following line.

    $ sudo crontab -u daemon -e
    
    */15 * * * *  /opt/bitnami/php/bin/php /opt/bitnami/apps/moodle/htdocs/admin/cli/cron.php >/dev/null
    

    This cron entry will run the script every 15 minutes.

    If you see the following error: "PHP Notice: Undefined index: HTTP_HOST in /opt/bitnami/apps/moodle/htdocs/config.php" It is necessary to specify your domain name in the config.php file.

    $CFG->wwwroot   = 'http://YOUR_DOMAIN/moodle';
    
    Tag page (Edit tags)
    • No tags
    Page statistics
    83061 view(s), 28 edit(s) and 13674 character(s)

    Comments

    You must login to post a comment.

    Attach file

    Attachments

    FileSizeDateAttached by 
     moodle_email.png
    SMTP settings
    238.25 kB09:20, 2 Sep 2014victoriaActions