3.7 install on Centos7 Nginx - css and .js files not loading

3.7 install on Centos7 Nginx - css and .js files not loading

by Colin Matheson -
Number of replies: 2

I am installing a fresh Moodle on a new server (Centos7, nginx, mariadb, php-fpm7.2).

The install gets to the create an admin user page and the page doesn't have any styles and I can't enter an admin password.

The web console says that this file can't be loaded

http://MYSITE.COM/moodle/lib/javascript.php/1561054045/lib/requirejs/require.min.js

this is my nginx configuration file:

server {

        listen       80 default_server;

        listen       [::]:80 default_server;

        server_name  10.1.15.111 cusd-moodle.carmelunified.org;

        root         /usr/share/nginx/html;

index      index.html index.htm;


        # Load configuration files for the default server block.

        include /etc/nginx/default.d/*.conf;


        location / {

try_files $uri $uri/ =404;

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

        }


        error_page 404 /404.html;

            location = /40x.html {

        }


        error_page 500 502 503 504 /50x.html;

            location = /50x.html {

        }


      # php parsing

  


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

include /etc/nginx/mime.types;

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

        try_files $uri =404;

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

        fastcgi_index index.php;

fastcgi_param   PATH_INFO       $fastcgi_path_info;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        include fastcgi_params;

    }

    }

}

I have tried several other variation on the php location line and contents of the php location block but still can't get that page to load. 

Any suggestions would be appreciated.

Average of ratings: -
In reply to Colin Matheson

Re: 3.7 install on Centos7 Nginx - css and .js files not loading

by Ken Task -
Picture of Particularly helpful Moodlers

https://docs.moodle.org/37/en/Nginx

Similar

https://moodle.org/mod/forum/discuss.php?d=385114#p1557177

and ... via command line:

moodlecode/admin/cli/install.php doesn't talk to web service thus no 'special protections' such as the admin user password.

If using CLI, still might have to revisit later. :| but server up. smile

'SoS', Ken

In reply to Ken Task

Re: 3.7 install on Centos7 Nginx - css and .js files not loading

by Colin Matheson -
Hi Ken,
Yeah I tried so many different versions and suggestions from the docs, moodle forums, and other sites with recommendations for nginx configuration. Got it installed via command line but pages wouldn't load even though php was working with nginx: tested via a phpinfo() page. After two days of trying every recommended nginx configuration gave up and just set it up on apache. Worked the first time (from the web installer no less)!
It would be great if someone with more web server experience than me could write documentation on LEMP moodle setup on the most recent CentOS and/or Ubuntu LTS. There are obviously some finicky parts that are causing people problems.