Categories
PHP Windows

How to fix moodle Installation error of Nginx in windows

Moodle (Modular Object-Oriented Dynamic Learning Environment) is a free and open-source LMS (learning management system) written in PHP and distributed under the GPL License.

As a Windows user, I prefer to use Laragon as a powerful universal development environment for PHP. And for the server, I always go for Nginx.

Do you ever face any setup errors during the installation process of moodle in the Nginx server?

There are several solutions to fix it but we try to follow the best practice.

Slash arguments error of Nginx in Moodle installation process

This is usually happened because ‘slash arguments’ compatible ‘location’ block to your vhosts ‘server’ in your Nginx configuration.

We have the default Nginx configuration file below

server {
    listen 8080;
    listen 8443 ssl;
    server_name moodle.test *.moodle.test;
    root "D:/moodle";
    
    index index.html index.htm index.php;
 
    location / {
        try_files $uri $uri/ /index.php$is_args$args;
		autoindex on;
    }
    
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass php_upstream;		
        #fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    # Enable SSL
    ssl_certificate "E:/laragon/etc/ssl/laragon.crt";
    ssl_certificate_key "E:/laragon/etc/ssl/laragon.key";
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
    ssl_prefer_server_ciphers on;
	
	
    charset utf-8;
	
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
    location ~ /\.ht {
        deny all;
    }
}

# This file is auto-generated.
# If you want Laragon to respect your changes, just remove the [auto.] prefix

Just replace the red location block with the new location block

location ~ [^/]\.php(/|$) {
fastcgi_split_path_info  ^(.+\.php)(/.+)$;
fastcgi_index            index.php;
fastcgi_pass             php_upstream;
include                  fastcgi_params;
fastcgi_param   PATH_INFO       $fastcgi_path_info;
fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

Reload the previous Installation page. I think It should be fixed now.

Happy Coding 😃

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.