How To Install Moodle on Ubuntu using Nginx

Moodle is a very popular and seasoned learning platform used by many institutions. While it is easy to set up a working moodle platform, it is a lot harder to run it smoothly for many concurrent users. Therefore some of the design choices taken in this guide try to solve this issue and offer a clean and fast solution for common use cases.

welcome1

Step #1: Update System:

Use following command to update the system:

# sudo apt-get update && sudo apt-get upgrade

Step #2: Install Required Packages:

Install php, along with some modules which are required by moodle. Use following command to install the packages:

# sudo apt-get install php5-fpm php-apc php5-curl php5-gd php5-xmlrpc php5-intl python-software-properties software-properties-common git curl vim graphviz aspell	

Step #3: Install MariaDB:

This article will help you to install MariaDB 10.0 in Ubuntu 14.04 LTS and 12.04 LTS and Other Systems using apt-get package manager.

Next, we need to create a database for our Moodle installation.

mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE moodle;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost' IDENTIFIED BY 'secretpassword';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

Add the following line in the my.cnf file under [mysqld] section and restart mysql service

# sudo vim /etc/mysql/my.cnf
binlog_format = ROW

Step #4: Install PHP-FPM and Nginx:

Installing PHP and Nginx is pretty easy, just run the following command:

# sudo apt-get install nginx php5-fpm

Step #5: Nginx configuration:

Create a new Nginx server block with the following content:

server {
    listen 80;
    root /usr/share/nginx/moodle;
     server_name srv.techoism.com;
     # put your real site address here
     rewrite ^/(.*\.php)(/)(.*)$ /$1?file=/$3 last;

     location ^~ / {
         try_files $uri $uri/ /index.php?q=$request_uri;
         index index.php index.html index.htm;

         location ~ \.php$ {
             fastcgi_split_path_info ^(.+\.php)(/.+)$;                 
             fastcgi_pass 127.0.0.1:9000;
             include fastcgi_params;
         }
     }
}

Enable your moodle site and remove the default symlink:

# sudo rm /etc/nginx/sites-enabled/default
# sudo ln -s /etc/nginx/sites-available/moodle /etc/nginx/sites-enabled/moodle

Now start your nginx server and php:

# sudo service nginx start
# sudo service php5-fpm start

Step #6: Clone the Moodle git repository:

Now clone the git repository from github using the following commands:

# sudo cd /usr/share/nginx
# sudo git clone https://github.com/moodle/moodle.git
# sudo cd moodle
# sudo git checkout -t origin/MOODLE_29_STABLE
# sudo chmod 0777 /usr/share/nginx/moodle

This will clone the github moodle repository in a directory called moodle.

After you have ran the installer and you have moodle setup, you NEED to revert permissions so that it is no longer writable using the below command.

# sudo chmod -R 0755 /usr/share/nginx/moodle/admin/cli/cron

Step #7: Create data directory for Moodle:

Moodle obliges a directory to store all its files, session information and so on. The web server needs to be able to write to this directory. This directory must NOT be accessible directly via the web.

# mkdir /usr/share/nginx/moodledata

Set the following permissions for apache user to moodle directory:

# sudo chmod -R 777 /usr/share/nginx/moodledata
# sudo chown -R www-data:www-data /usr/share/nginx/moodledata

Step #8:Finally Start Moodle Web Installer:

Open your browser and type the address of your website srv.techoism.com/install.php,

Select language, and click on Next.
moodle_1

In next step we will mention Web Address, Moodle directory and Data directory path.
moodle_2

moodle_3

Choose database driver, MariaDB
moodle_4

Enter the Database settings
moodle_5

moodle_6

Now click on Continue to accept the License Agreement.
moodle_7

Now the installer will check for all require modules are installed, press continue.
moodle_8

moodle_9

Installing all Moodle modules. Click continue when complete.
moodle_10

moodle_11

Create a Administrator account and click Update.
moodle_12

Now do all require setting, press save.
moodle_13

Now your moodle site has been successfully installed.
moodle_14

Thatโ€™s it. You have successfully installed your Moodle. For more information about Moodle, please refer to the Moodle website.

Step #9: Set Crontab:

Cronjobs are very important for moodle and running them offsite is not as effective as running them locally. You can add a short command in cron tab:

# crontab -e
*/10 * * * * php -q -f /usr/share/nginx/moodle/admin/cli/cron.php

See Also:
How to install Moodle 2.9 on CentOS/RHEL 7/6/5

Enjoy it!

Comments
  1. 8 years ago
    • 8 years ago
  2. 6 years ago
  3. 6 years ago
  4. 6 years ago
  5. 5 years ago
  6. 5 years ago
    • 5 years ago
  7. 5 years ago
  8. 5 years ago
  9. 5 years ago
  10. 5 years ago
  11. 5 years ago
  12. 5 years ago
  13. 5 years ago
  14. 5 years ago
  15. 5 years ago

Leave a Reply to super glandin eyelash serum recension Cancel reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.