;

How to install Moodle 3.1 on Ubuntu 16 with PHP 7

Try it in our public cloud & Get $5 Credit
CLAIM NOW

How to install Moodle 3.1 on Ubuntu 16 with PHP 7

Moodle™ is an excellent tool that instructors can use to augment online courses, creating private websites to help keep students on track and to monitor their progress. It’s also a very budget-friendly software, being free and open-source under the GNU General Public License.

Getting Started

To complete this guide, you will need the following:
• 1 Node (Cloud Server or Dedicated Server) running Ubuntu 14.
• All commands should be run as the root user
• An installed LAMP stack including Apache and PHP 7

Tutorial

Moodle requires certain software packages and PHP modules. Install these prerequisites first, in order to install Moodle 3.1.

apt-get install graphviz aspell php7.0-pspell php7.0-curl php7.0-gd php7.0-intl php7.0-mysql php7.0-xmlrpc php7.0-ldap php7.0-zip php7.0-mbstring php7.0-soap php7.0-xml libapache2-mod-php7.0

After installing the new modules, it will be necessary to restart Apache so it recognizes them.

systemctl restart apache2.service

Git, a common version control software, is essential to keeping Moodle up to date. If you don’t have it already, install git-core from the repository.

apt-get install git-core

Using git, you can download and install Moodle 3.1.

cd /opt
git clone git://git.moodle.org/moodle.git

It will prompt you for the desired version. In this guide we’ll choose 3.1.

cd moodle/
git branch -a
git branch --track MOODLE_31_STABLE origin/MOODLE_31_STABLE
git checkout MOODLE_31_STABLE

Now, locate your Document root directory and copy the content there.

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

Create a directory for Moodle. Add some permissions so Apache can access it.

mkdir /var/www/moodledata
chown -R www-data /var/www/moodledata/
chmod -R 777 /var/www/moodledata
chmod -R 0755 /var/www/html/moodle

Configure MySQL to work with Moodle

After Moodle is installed, it will need its own database in which to store data. We’ll use MySQl for this guide. First, open your mysqld.cnf in a text editor.

nano /etc/mysql/mysql.conf.d/mysqld.cnf

Add these lines to the bottom of the file.

default_storage_engine = innodb
innodb_file_per_table = 1
innodb_file_format = Barracuda

Restart the MySQL daemon so that it can recognize the changes.

systemctl restart mysql.service

Now you can create the Moodle database and accompanying user.

mysql -u root -p

CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
create user 'moodleuser'@'localhost' IDENTIFIED BY 'moodlepassword';
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO moodleuser@localhost IDENTIFIED BY 'moodlepassword';
quit;

Complete the setup

The online setup requires that you change the permissions of just one directory temporarily.

chmod -R 777 /var/www/html/moodle

Via your browser, visit the setup page and add in your database informations. For the database driver, choose Improved MySQL (native/mysqli).

http://your_ip/moodle

Once setup is completed, you can rollback the changed permissions on the Moodle folder.

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

The final step is to add some paths to the installation. Visit Moodle in your browser. Navigate to Site Administration > Server > System Paths. This is where you can add the missing paths.

Path to Du: /usr/bin/du
Path to Apsell: /usr/bin/aspell
Path to dot: /usr/bin/dot

Conclusion

Now that Moodle is setup and working on your server, you can use it as a versatile complement to your online course. Additionally, if you’re looking for a particular feature not included in the default installation, it can most likely be found among the 1000+ plugins available online. If this guide was helpful to you, kindly share it with others who may also be interested.