Nginx
Moodle:安裝過程中出錯
我正在嘗試安裝 Moodle,一切似乎都很好,但是當涉及到管理員使用者創建過程時,似乎沒有 CSS 文件,並且“更新配置文件”按鈕不執行任何操作。所以我卡在頁面上
moodle/user/editadvanced.php?id=2
我還附上了網站的截圖。
我已經嘗試了所有可能的方法,例如將權限更改為 777,或者使用 root 使用者、Nginx 使用者和該目錄的所有者。但每次安裝後它都保持不變。
我已經搜尋過這個問題,但找不到解決方案。我正在按照關於HowToForge的教程安裝 Moodle。
我的moodle數據位置:
/var/moodledata
我的 Moodle 目錄:
/var/www/career/moodle/
我的 Nginx 配置文件:
server { listen 80; listen 443 ssl spdy; server_name domain.com; keepalive_timeout 70; root /var/www/domain; #ssl on; gzip on; ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # managed by Certbot ssl_protocols TLSv1.2; ssl_ciphers EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4:!3DES; ssl_dhparam /etc/nginx/conf.d/dhparam.pem; ssl_prefer_server_ciphers on; ssl_session_tickets off; ssl_session_cache shared:SSL:10m; add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; "; add_header X-Frame-Options "DENY"; spdy_headers_comp 6; spdy_keepalive_timeout 300; access_log /var/log/nginx/career.access.log; error_log /var/log/nginx/career.error.log; location / { root /var/www/career; #try_files $uri $uri/ = /404.html; if ($request_uri ~ ^/(.*)\.html$) { return 302 /$1; } try_files $uri $uri/ $uri.html $uri.php?$args; index index.php index.html; add_header Strict-Transport-Security "max-age=63072000; includeSubdomains" always; } error_page 404 /404.html; location = /404.html { root /var/www/career; internal; } error_page 405 /405.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/career; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~* \.php$ { root /var/www/career; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass php-fpm; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; #if ($request_uri ~ ^/([^?]*)\.php($|\?)) { return 302 /$1; } try_files $uri = 404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_intercept_errors on; fastcgi_ignore_client_abort off; fastcgi_connect_timeout 60; fastcgi_send_timeout 180; fastcgi_read_timeout 180; fastcgi_buffers 256 16k; fastcgi_buffer_size 32k; fastcgi_temp_file_write_size 256k; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } }
嘗試過的 Moodle 版本: 3.5.1 和 3.2.9
數據庫創建步驟:
CREATE DATABASE DATABASENAME DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON DATABASENAME.* TO 'DB_USER'@'localhost' IDENTIFIED BY 'PASSWORD';
Mysql 版本: 5.5.56-MariaDB MariaDB 伺服器
我個人認為它的權限問題,由於某種原因,Moodle 可能無法訪問文件或安裝它。但即使我給了它 777 對
moodledata
dir 和moodle
dir 的許可。更新
我看到一些文件沒有載入和失去,如下圖所示。
我替換了
location .php
nginx.conf 文件,現在它工作得很好。現在斜線參數工作正常。新
location
:location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_index index.php; fastcgi_pass php-fpm; (or 127.0.0.1:9000) include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; }