2017-04-24 99 views
0

我的配置: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

他們沒有工作......

+0

您的錯誤消息顯示'.php'腳本與pathinfo,但您的配置不支持pathinfo。請參閱[本配方](https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/)以獲取指導。 –

+0

@RichardSmith我讀過你發送的文章,爲我的代碼添加了一些修改,但是和我做的幾乎一樣,沒有發生任何事情。我的代碼的fastcgi_split_path_info與文章上的略有不同。我仍然有同樣的問題... –

+0

您的'location〜\ .php $'語句只接受沒有pathinfo的URI。最後的'$'表示它們在'.php'之後完成。也許你需要改變。 –

回答

0

我的繼承人平原對於moodle工作正常的nginx配置> = 3.1

server { 
     listen 80; 
     server_name someservername.com; 
     root /var/www; 
     index index.php index.html index.htm; 

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

} 
1

請在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; 

       }