Moodle 2.7: Nginx + PHP-FPM = Scorm player doesn't work

Moodle 2.7: Nginx + PHP-FPM = Scorm player doesn't work

by Владимир Зотов -
Number of replies: 3

Hi!

I've migrated my Moodle 2.7 from apache to nginx + php-fpm to improve perfomance. But after migration scorm player doesn't work - when I open any scorm package I get error "error/moodle/storedfilecannotread" (https://docs.moodle.org/27/en/error/moodle/storedfilecannotread).

My moodle root directory is installed in /var/www/mooodle-dev/www, data directory is in /var/www/moodle-dev/moodledata. Nginx config:

server{

        listen *:8080;

        server_name my.domain.name;

        access_log /var/log/nginx/my.domain.name_access.log;

        error_log /var/log/nginx/my.domain.name_error.log;


        rewrite ^(.*\.php)(/)(.*)$ $1?file=/$3 last;


        root /var/www/moodle-dev/www;

        index index.php index.html index.htm;


        location / {

                # First attempt to serve request as file

                try_files $uri $uri/index.php;

        }

        location ~ \.php$ {

                fastcgi_split_path_info ^(.+\.php)(/.+)$;

                fastcgi_pass unix:/var/run/php5-fpm.sock;

                fastcgi_index index.php;

                include fastcgi_params;

        }

}


How can I fix this issue?

Average of ratings: -
In reply to Владимир Зотов

Re: Moodle 2.7: Nginx + PHP-FPM = Scorm player doesn't work

by Matteo Scaramuccia -

Hi Vladimir,
you need to support the Moodle slash arguments i.e. to configure nginx to correctly support PATH_INFO: look at https://docs.moodle.org/29/en/Nginx#Nginx for the missing parts - at least location ~ [^/]\.php(/|$) and fastcgi_param PATH_INFO $fastcgi_path_info; - in your configuration.

HTH,
Matteo

In reply to Matteo Scaramuccia

Re: Moodle 2.7: Nginx + PHP-FPM = Scorm player doesn't work

by Владимир Зотов -

Matteo, thank for your reply!

I've edited my config with your recomendations, but SCORM player still doesn't work - some error. My config is now:


server{

        listen *:8080;

        server_name my.domain.name;

        access_log /var/log/nginx/my.domain.name_access.log;

        error_log /var/log/nginx/my.domain.name_error.log;


#       rewrite ^/moodle/(.*\.php)(/)(.*)$ /moodle/$1?file=/$3 last;

#       rewrite ^/(.*\.php)(/)(.*)$ /$1?file=/$3 last;

        rewrite ^(.*\.php)(/)(.*)$ $1?file=/$3 last;


        root /var/www/moodle-dev/www;

        index index.php index.html index.htm;


        location / {

                # First attempt to serve request as file

                try_files $uri $uri/index.php;

        }


        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

#       location ~ \.php$ {

#               fastcgi_split_path_info ^(.+\.php)(/.+)$;

                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini


                # With php5-fpm:

#               fastcgi_pass unix:/var/run/php5-fpm.sock;

#               fastcgi_index index.php;

#               include fastcgi_params;

#       }

        location ~ [^/]\.php(/|$) {

            fastcgi_split_path_info  ^(.+\.php)(/.+)$;

            fastcgi_index            index.php;

            fastcgi_pass             unix:/var/run/php5-fpm.sock;

            include                  fastcgi_params;

            fastcgi_param   PATH_INFO       $fastcgi_path_info;

            fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;

        }

        location /dataroot/ {

            internal;

            alias /var/www/moodle-dev/moodledata/; # ensure the path ends with /

        }

}


In reply to Владимир Зотов

Re: Moodle 2.7: Nginx + PHP-FPM = Scorm player doesn't work

by Matteo Scaramuccia -

Hi Vladimir,
in your first post I missed your part about the rewriting rule, rewrite ^(.*\.php)(/)(.*)$ $1?file=/$3 last;: please, get rid of it and go with the PATH_INFO plain support as described in the Moodle docs.

You can access https://moopi.mrverrall.co.uk/course/view.php?id=4: there you'll have a nice picture of the bits and pieces used to run a Moodle instance on a Raspberry Pi 2 via nginx.

HTH,
Matteo