系统相关
首页 > 系统相关> > Moodle 3.0 – CSS和Javascript不加载 – 对NGINX的请求与实际路径不兼容

Moodle 3.0 – CSS和Javascript不加载 – 对NGINX的请求与实际路径不兼容

作者:互联网

我的配置:

> Ubuntu 14.04
> Nginx 1.4.6
> PHP 5.5.9
> Moodle 3.0

我已经通过浏览器完成了Moodle 3.0的安装,并且没有加载css或javascript.这是NGINX错误日志:

2017/04/24 20:48:23 [error] 3277#0: *601 open() "/var/www/html/moodle/theme/image.php/clean/core/1493057621/moodlelogo" failed (20: Not a directory), client: 10.0.2.2, server: localhost, request: "GET /theme/image.php/clean/core/1493057621/moodlelogo HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/index.php"
2017/04/24 20:48:23 [error] 3277#0: *601 open() "/var/www/html/moodle/lib/javascript.php/1493057621/lib/requirejs/require.min.js" failed (20: Not a directory), client: 10.0.2.2, server: localhost, request: "GET /lib/javascript.php/1493057621/lib/requirejs/require.min.js HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/index.php"
2017/04/24 20:48:23 [error] 3277#0: *601 open() "/var/www/html/moodle/theme/javascript.php/clean/1493057621/footer" failed (20: Not a directory), client: 10.0.2.2, server: localhost, request: "GET /theme/javascript.php/clean/1493057621/footer HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/index.php"
2017/04/24 20:48:24 [error] 3277#0: *609 open() "/var/www/html/moodle/theme/styles.php/clean/1493057621/all" failed (20: Not a directory), client: 10.0.2.2, server: localhost, request: "GET /theme/styles.php/clean/1493057621/all HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/index.php"
2017/04/24 20:48:24 [error] 3277#0: *611 open() "/var/www/html/moodle/lib/javascript.php/1493057621/lib/javascript-static.js" failed (20: Not a directory), client: 10.0.2.2, server: localhost, request: "GET /lib/javascript.php/1493057621/lib/javascript-static.js HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/index.php"
2017/04/24 20:48:24 [error] 3277#0: *611 open() "/var/www/html/moodle/theme/image.php/clean/core/1493057621/moodlelogo" failed (20: Not a directory), client: 10.0.2.2, server: localhost, request: "GET /theme/image.php/clean/core/1493057621/moodlelogo HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/index.php"
2017/04/24 20:48:24 [error] 3277#0: *606 open() "/var/www/html/moodle/lib/javascript.php/1493057621/lib/requirejs/require.min.js" failed (20: Not a directory), client: 10.0.2.2, server: localhost, request: "GET /lib/javascript.php/1493057621/lib/requirejs/require.min.js HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/index.php"
2017/04/24 20:48:24 [error] 3277#0: *606 open() "/var/www/html/moodle/theme/javascript.php/clean/1493057621/footer" failed (20: Not a directory), client: 10.0.2.2, server: localhost, request: "GET /theme/javascript.php/clean/1493057621/footer HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/index.php"
2017/04/24 20:48:25 [error] 3277#0: *609 open() "/var/www/html/moodle/lib/javascript.php/1493057621/lib/javascript-static.js" failed (20: Not a directory), client: 10.0.2.2, server: localhost, request: "GET /lib/javascript.php/1493057621/lib/javascript-static.js HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/index.php"
2017/04/24 20:48:25 [error] 3277#0: *609 open() "/var/www/html/moodle/theme/image.php/clean/core/1493057621/moodlelogo" failed (20: Not a directory), client: 10.0.2.2, server: localhost, request: "GET /theme/image.php/clean/core/1493057621/moodlelogo HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/index.php"
2017/04/24 20:48:25 [error] 3277#0: *609 open() "/var/www/html/moodle/lib/javascript.php/1493057621/lib/requirejs/require.min.js" failed (20: Not a directory), client: 10.0.2.2, server: localhost, request: "GET /lib/javascript.php/1493057621/lib/requirejs/require.min.js HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/index.php"
2017/04/24 20:48:25 [error] 3277#0: *609 open() "/var/www/html/moodle/theme/javascript.php/clean/1493057621/footer" failed (20: Not a directory), client: 10.0.2.2, server: localhost, request: "GET /theme/javascript.php/clean/1493057621/footer HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/index.php"

似乎该路径正在考虑将某些.php文件作为目录.
这是我的服务器配置:

server {
    listen      8080;
    server_name localhost;

    # Root #
    root /var/www/html/moodle/;
    index index.php index.html index.htm;

    location ~ \.php${
        if (!-f $document_root$fastcgi_script_name) {
            rewrite ^ 404;
        }
        include fastcgi_params;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

我已经尝试过这些解决方案:

Solution 1

Solution 2

他们没有工作……

解决方法:

请在nginx.conf文件的服务器部分添加以下配置代码.

location / {
             root /var/www/yourwebsite.com;
             index index.php index.html index.htm;

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

      # php parsing
      location ~ .php${
                         root /var/www/yourwebsite.com;
                         try_files $uri =404;
                         fastcgi_pass unix:/tmp/php5-fpm.sock;
                         fastcgi_index index.php;
                         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                          include fastcgi_params;
                          fastcgi_buffer_size 128k;
                          fastcgi_buffers 256 4k;
                          fastcgi_busy_buffers_size 256k;
                          fastcgi_temp_file_write_size 256k;

               }

标签:nginx,javascript,css,ubuntu-14-04,moodle
来源: https://codeday.me/bug/20190722/1501445.html