Friday, November 14, 2014

Install moodle 2.8 with nginx and php5-fpm in Ubuntu14.04

The latest version of Moodle (v2.8) had been released a couple days ago with some improvement especially the gradebook (click here for more information). This blog post is about deploying a moodle instance along side with nginx and php5-fpm.


0. Create the database:

$ mysql -u root p
MariaDB [(none)]> create database moodle;
MariaDB [(none)]> grant all privileges on moodledb.* to 'moodleuser'@'localhost' identified by 'moodlepassword';

1. Clone the latest stable Moodle using git:

$ cd /var/www
$ sudo git clone --depth=1 -b MOODLE_28_STABLE --single-branch git://git.moodle.org/moodle.git 
$ sudo chown www-data:www-data -R moodle
$ sudo chmod -R 0777 moodle

2. Create the moodle data directory:

$ sudo mkdir /var/www/moodledata
$ sudo chown www-data:www-data -R /var/www/moodledata
$ sudo chmod -R 0777 /var/www/moodledata

3. Setup nginx:



$ sudo service nginx restart

4. Config php5-fpm:

make sure the /etc/php5/fpm/php.ini:
...
cgi.fix_pathinfo = 1
...

$ sudo service php5-fpm restart

5. Open the browser, go to localhost and follow instructions to install moodle.

6. Secure the moodle files:

$ sudo chmod -R 0755 /var/www/moodle
$ sudo chmod -R 0755 /var/www/moodledata
$ find /var/www/moodle -type f -exec chmod 0644 {} \;

7. Done



References:

[0] http://www.nginxtips.com/nginx-moodle/
[1] https://docs.moodle.org/dev/Moodle_2.8_release_notes
[2] https://docs.moodle.org/28/en/Installing_Moodle