Moodle 2.0 with Nginx backend

2019-05-10 20:31发布

问题:

Hello I am looking for a tutorial on how to configure a server for Moodle 2.0 with nginx as the server and PHP-FPM or FastCGI with mySQL as the backend. Sorry if I am confusing these terms bit of a server architecture noob. Probably would run it on Ubuntu/Debian machine

found a tutorial for older versions of Moodle with older PHP and PostgreSQL compiled from source. This would slow down my deployment plans and seems deprecated. Also would prefer MySQL over Postgres based on my experience level with MySQL.

Can anyone out there make some updated suggestions?

回答1:

I wrote a documentation for Nginx and Moodle 2: http://docs.moodle.org/dev/Install_Moodle_On_Ubuntu_with_Nginx/PHP-fpm

Don't forget to set slash arguments to off in Moodle, otherwise you'll have problem with image links in the html editor.



回答2:

First of all, you need to run php-fpm on nginx... http://www.bytetouch.com/blog/linux/how-to-nginx-with-php-fpm-fastcgi-implementation-on-debian-lenny/

to better performance i use unix sockets to connect instead tcp sockets, here appears configuration for unix sockets. http://andreas-lehr.com/blog/archives/491-nginx-wordpress-php-fpm-on-debian-squeeze.html

i use the following conf for php in nginx

            location ~ \.php($|/) {
                    if ($uri ~ "^(.+\.php)(/.*)") {
                            set $script $1;
                            set $path_info $2;
                    }

                    fastcgi_pass    unix:/var/run/php-fpm.sock;
                    fastcgi_param   SCRIPT_FILENAME  $document_root$script;
                    fastcgi_param   SCRIPT_NAME      $script;

                    include        /etc/nginx/fastcgi_params;
            }

you need to replace the unix socket, and i don't know if debian distribution have fastcgi_params include file, but have anyway by hand in tutorials

After that, you run php in a nginx server then you could use moodle and all your favorite php scripts or applications.

if you have some doubt, comment it =).



回答3:

I suggest you to keep slash argument enabled, expecially if you have already uploaded resources (ie. SCORM) and put this in the server {} section of your nginx virtual host

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