1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

XSendfile Acceleration for Moodle/NGINX

This commit is contained in:
root 2021-07-05 17:15:12 +00:00
parent b5844e17b8
commit 134997676e
3 changed files with 34 additions and 16 deletions

View file

@ -146,22 +146,37 @@
# name: "{{ apache_service }}"
# state: restarted
- name: Does {{ moodle_base }}/config.php exist?
stat:
path: "{{ moodle_base }}/config.php"
register: config
# - name: Does {{ moodle_base }}/config.php exist?
# stat:
# path: "{{ moodle_base }}/config.php"
# register: config
- name: Execute {{ moodle_base }}/moodle_installer -- REQUIRES 'max_input_vars = 5000' (or higher) in /etc/php/{{ php_version }}/cli/php.ini with PHP 8+ (as set up by www_options/tasks/main.yml) -- WHEREAS Moodle uses /etc/php/{{ php_version }}/{{ apache_service }}/php.ini or /etc/php/{{ php_version }}/fpm/php.ini during regular operation
- name: Execute {{ moodle_base }}/moodle_installer IF {{ moodle_base }}/config.php doesn't yet exist -- REQUIRES 'max_input_vars = 5000' (or higher) in /etc/php/{{ php_version }}/cli/php.ini with PHP 8+ (as set up by www_options/tasks/main.yml) -- WHEREAS Moodle uses /etc/php/{{ php_version }}/fpm/php.ini during regular operation
shell: "{{ moodle_base }}/moodle_installer"
when: config.stat.exists is defined and not config.stat.exists
args:
creates: "{{ moodle_base }}/config.php"
#when: config.stat.exists is defined and not config.stat.exists
# 2021-02-01: Let's stick with Moodle's default (640)
# 2021-07-05: Let's stick with Moodle's default (755 dirs & 644 files), as we do in moodle/tasks/mathjax.yml
#- name: Make {{ moodle_base }}/config.php readable, with permission '0644'
# #command: chown -R {{ apache_user }} {{ moodle_base }}
# file:
# path: "{{ moodle_base }}/config.php" # /opt/iiab/moodle
# mode: '0644'
# https://docs.moodle.org/311/en/Nginx#XSendfile_aka_X-Accel-Redirect
- name: Write extra parameters to {{ moodle_base }}/config.php -- "Setting Moodle and Nginx to use XSendfile functionality is a big win as it frees PHP from delivering files allowing Nginx to do what it does best, i.e. deliver files"
lineinfile:
path: "{{ moodle_base }}/config.php"
line: '$CFG->{{ item.name }} = {{ item.value }};'
insertbefore: '^\$CFG->directorypermissions'
with_items:
#- { name: 'backuptempdir', value: "'{{ moodlebox_moodle_data_dir }}/backup'" }
- { name: 'xsendfile', value: "'X-Accel-Redirect'" }
- { name: 'xsendfilealiases', value: "array('/dataroot/' => $CFG->dataroot)" }
#- { name: 'customfiletypes', value: "array(\n (object)array(\n 'extension' => 'crt',\n 'icon' => 'sourcecode',\n 'type' => 'application/x-x509-ca-cert',\n 'customdescription' => 'X.509 CA certificate'\n )\n)"}
#- { name: 'showcampaigncontent', value: 'false' }
- include_tasks: mathjax.yml

View file

@ -11,13 +11,12 @@
#version: "{{ moodle_mathjax_version }}" # 2021-07-05: https://github.com/moodlebox/moodlebox/blob/master/default.config.yml uses 2.7.9 from 2020-08-25 -- whereas https://github.com/mathjax/MathJax/releases offers 3.2.0 from 2021-07-17
depth: 1
- name: chmod -R ug+w,o-w {{ moodle_base }}/lib/MathJax (dirs 755 -> 775, files 644 -> 664, {{ apache_user }}:{{ apache_user }})
- name: chown -R {{ apache_user }}:{{ apache_user }} {{ moodle_base }}/lib/MathJax
file:
path: "{{ moodle_base }}/lib/MathJax"
state: directory
owner: "{{ apache_user }}" # www-data
group: "{{ apache_user }}" # MoodleBox uses {{ moodlebox_username }} set to 'moodlebox' in https://github.com/moodlebox/moodlebox/blob/master/default.config.yml
mode: ug+w,o-w
#mode: ug+w,o-w # 2021-07-05: Let's stick with Moodle's default (755 dirs & 644 files), as we do in moodle/tasks/install.yml
recurse: yes
# SEE https://github.com/moodle/moodle/blob/master/filter/mathjaxloader/lang/en/filter_mathjaxloader.php

View file

@ -1,12 +1,16 @@
# 2021-07-02: Let's monitor & learn from these 2 pages year-by-year:
# 2021-07-02: Let's monitor & learn from these 3 pages year-by-year:
# https://docs.moodle.org/311/en/Nginx
# https://github.com/moodlebox/moodlebox/blob/master/roles/moodleinstall/tasks/coreinstall.yml
# https://github.com/moodlebox/moodlebox/blob/master/roles/webserver/templates/etc/nginx/sites-available/default.j2
# Odd that MoodleBox.net is using only the 2nd half of https://docs.moodle.org/311/en/Nginx#XSendfile_aka_X-Accel-Redirect ?
#location ~ ^/moodle/dataroot/ {
# internal;
# alias {{ moodle_data }};
#}
# This passes 404 pages to Moodle so they can be themed
#error_page 404 /error/index.php; error_page 403 =404 /error/index.php;
# https://docs.moodle.org/311/en/Nginx#XSendfile_aka_X-Accel-Redirect
location ~ ^/moodle/dataroot/ {
internal;
alias {{ moodle_data }}/;
}
location ~ ^/moodle(.*)\.php(.*)$ {
alias {{ moodle_base }}$1.php$2;