我的配置:
我已经通过浏览器完成了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;
}
}
我已经尝试过这些解决方案:
他们没有工作......
答案 0 :(得分:5)
请在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;
}
答案 1 :(得分:4)
这是我的简单nginx配置,适用于moodle> = 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;
}
}