安裝web服務器
我們將安裝含有PHP和MariaDB的nginx 全球資訊網伺服器。
nginx和PHP的安裝及設定
為了提高效能,我們選擇使用下一代Debian版本Stretch來安裝nginx 1.10和PHP7。 先在 /etc/apt/preferences檔案末尾加入以下幾行 。
Package: *
Pin: release n=jessie
Pin-Priority: 600編輯 /etc/apt/sources.list,加入stretch的套件來源於jessie的下方
deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi接著更新下列套件
$ sudo apt-get update然後安裝所需要的套件
$ sudo apt-get install -y -t stretch nginx php7.0-fpm php7.0-cli php7.0-xmlrpc php7.0-curl php7.0-gd php7.0-intl php7.0-soap php7.0-mysql php-apcu php7.0-zip php7.0-xml php7.0-mbstring php7.0-tidy php7.0-ldap php7.0-intl php7.0-pspell graphviz aspell驗證
使用一台電腦透過Wi-Fi連上MoodleBox ,並在瀏覽器輸入網址 http://moodlebox.home/ 。 將顯示"歡迎在Debian使用nginx!"的網頁。編輯 /etc/nginx/sites-available/default 檔案來設定Web伺服器,以下是它的內容:
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name moodlebox;
location / {
try_files $uri $uri/ =404;
}
location ~ [^/]\.php(/|$) {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_read_timeout 300;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "max_execution_time=300\n upload_max_filesize=50M \n post_max_size=50M";
client_max_body_size 50M;
}
}最後一行 fastcgi_param和client_max_body_size允許提高資料夾的最大授權儲存容量到50 MB,以及腳本可執行時間最大到300秒。
重新啟動Web服務器:
驗證
MariaDB的安裝
在安裝過程中,要定義資料庫的主要使用者帳號為 root 。如上所述,我們需定義一個安全性強的密碼。 本安裝密碼設定為Moodlebox4$。
設定資料庫使用者帳號root的密碼(如果安裝過程沒有設定)
驗證
設定並建立Moodle的MariaDB資料庫
因Moodle 3.1.2+版本需要使用的MariaDB 以utf8mb4編碼來修正錯誤。這裡安裝的MariaDB的版本已經是正確的。只是要進行其他設定。 在/etc/mysql/mariadb.conf.d/50-server.cnf添加的幾行字。 在 [mysqld] 區段中加入:
然後,重新啟動MariaDqB。
現在,我們可以新建Moodle使用的資料庫了。
Last updated
Was this helpful?