安装Moodlezh:

来自MoodleDocs
stephen Liu讨论 | 贡献2009年2月24日 (二) 06:26的版本
跳转至:导航、​搜索

首先,不要驚慌! :-)

本指南說明第一次如何安裝Moodle,對於其中一些步驟有很多的細節試圖涵蓋大多數可能的web伺服器設定,所以這一頁看起來很長且複雜,不要驚慌,一旦你知道如何作你就可以在幾分鐘內安裝好Moodle!

如果您有問題請仔細閱讀此頁-在這裡回答了最常見的問題。如果您仍然有問題,你可以從Moodle社區透過moodle.org 使用Moodle尋求幫助。

安裝Apache、MySQL及PHP(AMP)提供了另一個操作說明來安裝Moodle在很多受歡迎的平台上。

另一個選擇是聯絡Moodle夥伴提供的Moodle主機,他可以幫你完整地維護Moodle,這樣你就可以忽略這裡的所有細節然後直接進到教育訓練中!

警告: 有些web主機廠商提供像是Fantastico一次點擊的Moodle安裝程式,雖然這些通常有效,但有時他們就是不能用或是eb主機使用很舊的Moodle版本,假如這些安裝有一個出錯,你最好的選擇通常還是從這裡的操作說明從頭開始,這幾乎肯定比較快。

假如你想執行Moodle在你自己的電腦上,這一頁看起來有點複雜,那麼請看我們的如何使用Moodle的完整安裝套件Windows版Mac OS版的指南,這將允許你建構一個Moodle站台但是這個主機不是在internet上的。


目錄

需求

Moodle主要是在Linux上使用ApacheMySQLPHP開發(有時也被稱作LAMP平台),但也有在Windows XP/2000/2003 (WAMP)、Solaris 10 (Sparc 及 x64)、Mac OS X及Netware 6作業系統上測試,支援的資料庫有PostgreSQL、Oracle及Microsoft SQL Server。

安裝Moodle在Winodws平台上的程序(如Windows Server、IIS及MSSQL)跟在LAMP平台上的程序有些微的不同,見Windows 2003的IIS安裝有更詳細資料。

在Windows Vista上安裝Moodle這一頁有助於解決在Windows Vista上安裝Moodle的空白頁問題

要安裝Moodle的需求如下:

硬體

  • 硬碟空間:160MB的空間 (最小),你會需要更多的空間來儲存你的教學資料。
  • 記憶體:256MB (最小)、1GB (建議),一般的經驗法則是1G的RAM讓Moodle可以支援50個 同時的使用者,但是這得視你的硬體及軟體的搭配來看。
    • 注意如果你使用的是託管帳戶: 大部分商業網站上的託管帳戶會滿足硬碟及記憶體的需求,然而你應該聯絡你的web主機後台來確認你在註冊前就是符合的,詢問關於PHP記憶體限制或是MySQL問題的限制特別的重要,假如你要的主機沒有提供滿足這些需求的服務,或是你已經註冊了,加如他們不改變的話,詢問他們為什麼並且考慮移到其它的地方。

軟體

  • Web伺服器軟體,大多數人使用Apache,但是Moodle應該可以在任何支援PHP的web伺服器下執行的很好,像是在Windows平台上的IIS,PHP把需求強加於web伺服器的版本上,然而這些是複雜的而且一般的意見是使用你選擇的web伺服器最新的版本。
  • PHP腳本語言,(請注意安裝使用PHP-Accelerator安裝Moodle會有問題),目前有兩個版本(或分支)的PHP可用:PHP4及PHP5而版本的需求列於下。
    • Moodle 1.4版或之後的版本:PHP4 (4.1.0版或之後)或PHP5 (5.1.0版或之後)可以支援。
    • Moodle 1.6版或之後的版本:PHP4 (4.3.0版或之後)或PHP5 (5.1.0版或之後)可以支援。
    • 未來Moodle 2.0版或之後將不再支援PHP4並且需要PHP5 (5.2.8版或之後)。
    • PHP設定,檢查你的php.ini設定或是.htaccess檔案(假如你使用Apache的話),這些設定使用ON/OFF作為他們的值,你可以用1來取代ON,用0來取代OFF,如果你喜歡的話。
      • register_globals 必須是OFF
      • safe_mode需要是OFF。
      • memory_limit至少應該要16M (Moodle 1.7建議使用32M而Moodle 1.8或之後的版本建議使用40M),大型站台可能需要超過128M的記憶體,PHP 5.2.x比以前的PHP版本需要較高的memory_limit值,64為原作頁系統也需要更多的記憶體。
      • session.save_handler需要設為FILES。
      • magic_quotes_gpc應該是ON,(到2.0時建議關掉)
      • magic_quotes_runtime需要是OFF。
      • file_uploads需要是ON。
      • session.auto_start需要是OFF。
      • session.bug_compat_warn需要是OFF。
    • PHP擴充及函式庫
      • Moodle 1.6或之後的版本建議使用mbstring擴充。
      • Moodle 1.6或之後的版本建議使用iconv擴充。
      • 要看紀錄頁產生的動態圖片需要安裝GD函式庫FreeType 2函式庫跟擴充。(Freetype支援在PHP的5.x版時是GD擴充的一部分)
      • 假如你使用MySQL資料庫時需要mysql擴充,注意在有些Linux版本(很明顯的就是Red Hat)上這是選項安裝。
      • 假如你使用PostgesSQL資料庫時需要pgsql擴充。
      • (實驗性質的)SQLite 3資料庫支援需要pdo及pdo_sqlite擴充。
      • Moodle 1.8或之後的版本建議使用curl擴充。
      • Moodle 1.8或之後的版本建議使用tokenizer擴充。
      • Moodle網路功能(Moodle 1.8或之後的版本)需要curl及openssl擴充。
      • Moodle網路功能(Moodle 1.8或之後的版本)需要xmlrpc擴充。
      • Moodle 1.8或之後的版本建議使用ctype擴充。
      • 其他PHP擴充需要來支援其他Moodle選擇性的功能,特別是外部認證且/或註冊(例如LDAP認證的LDAP擴充及聊天伺服器的sockets擴充)。
  • 可以是用的資料庫伺服器:MySQLPostgreSQL可以完全支援並且建議使用在任何的Moodle的版本上,Microsoft SQL Server 及Oracle的支援在Moodle 1.7版時加入,MySQL是多人的選擇因為它很受歡迎,但是也有些支持PostgreSQL的論點,特別是假如你計畫有一個大型的佈署時。
    • Moodle 1.5版,MySQL (3.23或之後的版本)或PostgreSQL (7.4或之後的版本)。
    • Moodle 1.6版,MySQL (4.1.12或之後的版本)或PostgreSQL (7.4或之後的版本)。
    • Moodle 1.7版,MySQL (4.1.12或之後的版本)、PostgreSQL (7.4或之後的版本)或Microsoft SQL Server 2005 (9版或SQL Server Express 2005)
    • Moodle 1.8或之後的版本,MySQL (4.1.12或之後的版本)、PostgreSQL (8.0或之後的版本)或Microsoft SQL Server 2005 (9版或SQL Server Express 2005)
MySQL 注意:針對Moodle 1.6或之後的版本,假如你使用拉丁語的話你只可以使用MySQL 4.1.12版。假如你使用非拉丁語的話,你需要MySQL 4.1.16或之後的版本,目前在MySQL

組態檔裡的MySQL設定"strict mode"必須是OFF (設成""或"MYSQL40")。

PostgreSQL注意:PostgreSQL 7.4被推薦使用在較早期的Moodle版本,自Moodle 1.8版之後只有PostgreSQL 8.0及以上的版本才可支援。
  • 為了展示或是中小型的安裝,Moodle 2.0也含括了(實驗性質)的SQLite 3資料庫的支援,這個設定不需要資料庫伺服器,它是以資料庫檔案儲存在伺服器的一個目錄裡。

目錄

多少使用者?

除了硬體及軟體的需求外,你也需要由Moodle所能處理的使用者人數來考慮Moodle安裝的容量,有兩個地方要規劃:

瀏覽的使用者:能夠瀏覽你的Moodle站台的最大人數,這是你公司內或你的課程的數目(任一個較大的)。
並行資料庫使用者:並行資料庫使用者的最大數目(這是Moodle的活動像是測驗須要的),這是使用者同時使用Moodle的數目,在一個教育機構,使用你的時間表/名冊來取得這個數字。

一旦你知道你的使用者數目,假如你安裝的Moodle能夠支援這個容量的話你就可以開始工作了,確切的用戶數端賴於你的硬體/軟體/網路組合,通常安裝記憶體數量是決定的因素但是一個有較快的處理器也可以幫忙降低頁面載入的時間。

對一台伺服器來說一般的經驗法則是同時在線的最多使用者約等於 RAM (GB) * 50且最多瀏覽的人數約等於同時在線的最多使用者 * 5,例如,一個有500台電腦的大學在任何時候有100個使用者大約就需要2GB的RAM在伺服器上才可以支援同時使用的人數。

  • 注意假如你使用託管帳戶:詢問你的供應商並行資料庫連結數及處理器載入的限制,這樣可以大概估計你安裝的Moodle可以管理多少使用者。
  • 注意: 截至2007年8月31日Moodle 1.8.2+版不建議大型安裝,特別是假如你有很多的課程數(例如20,000+),主要的原因是關於ROLES的程式碼在資料庫查詢時仍然不能完全最佳化而且需要一些時間,假如你計畫使用1.8.x版的程式碼在大型機構,請確認你有充分的時間來作自己的測試及效能分析工具,請更新到Moodle 1.9!!

[從之前的版本更新]Moodle從1.8.3+版本有一些改善(見這一篇討論:http://moodle.org/mod/forum/discuss.php?d=83281),Moodle 1.9在很多方面甚至有很多的改善而且這是建議的版本。

目錄

下載及複製檔案

有兩個方法可以取得Moodle,可以用壓縮檔或透過CVS的管理

下載壓縮檔

download.moodle.org頁面:有兩種形式的壓縮檔提供了不同版本、作業系統及壓縮型態的使用。

  1. "標準的版本" (只有Moodle檔案)及
  2. 幾個作業系統"完整安裝套件" (包含了在web環境創建Moodle的程式),請見完整安裝套件更多資訊。

大多數的這些操作是針對標準版本的,下載壓縮檔然後使用下面的兩個命令解壓縮到你的檔案結構中:

tar -zxvf [filename]
unzip [filename]

從CVS下載

要使用CVS,在CVS管理頁有幫助的說明,全部的Moodle CVS repository也可以瀏覽。

假如你要使用CVS,執行CVS Checkout命令。

目錄的創建安置

在上述的程序中,你將會有一個叫"moodle"的目錄,這個目錄包含了很多的檔案及資料夾。

對於標準的套件,你可以將整個資料夾放在你的web伺服器的文件目錄裡,這樣子網站會放在http://你的網址/moodle,或是你可以複製所有的內容直接丟到主要的web伺服器文件目錄,這樣子網站會只是http://你的網址

提示: 假如你下載Moodle到你的電腦中然後上傳到你的web網站,通常上傳整個壓縮檔會較好,然後在伺服器上解壓縮,每個像cPanel的web主機介面允許你在"File Manager"解壓縮。

moodle目錄結構

你可以安全地跳過這節,但這裡有一個Moodle資料夾內容的快速總結,來幫助你定位:

config.php - 含有基本設定,這個檔案不是在Moodle裡的 - 你可以執行install.php或手動產生。
install.php - 這個腳本可以用來產生config.php
version.php - 定義目前Moodle程式碼的版本
index.php - 站台前頁
admin/ - 管理整個伺服器的程式碼
auth/ - 認證使用者的外掛模組
blocks/ - 在很多頁面的方塊外掛模組
calendar/ - 管理及顯示日曆的程式碼
course/ - 顯示及管理課程的程式碼
doc/ - Moodle的說明文件(例如這一頁)
files/ - 顯示及管理上傳檔案的程式碼
lang/ - 不同語言的文字,每個語言一個目錄
lib/ - Moodle核心程式函式庫
login/ - 處理登入及帳號創建的程式碼
mod/ - 所有主要的Moodle課程模組在這裡
pix/ - 通用網站圖案
theme/ - 佈景主題可以改變網站外觀。
user/ - 顯示及管理使用者的程式碼

目錄

設定你的系統

為了確認Moodle可以安裝成功,你需要確認web伺服氣得設定是正確的,接著創見一個空白資料庫給Moodle使用,最後在你的硬碟新增Moodle的目錄來儲存你的材料及你上傳的其他檔案到你的課程裡。

檢查web伺服器設定

  • 首先確認你的web伺服器已經設定使用index.php作為預設的網頁(也許除了index.html、default.htm等等),在Apache裡可以在httpd.conf檔案裡使用DirectoryIndex參數,我的設定通常看起來像這樣:
DirectoryIndex index.php index.html index.htm
只要確認index.php是在列表中(最好是放在開頭以提昇效率)。
  • 再來,假如你是使用Apache 2,那麼你應該開啟AcceptPathInfo變數,這個變數允許腳本可以像http://server/file.php/arg1/arg2這樣的傳參數,允許你的資源之間的相關連結以及提供給使用你Moodle網站的使用者可以加速效能是至關重要的,你可以增加這幾行到你的httpd.conf檔裡來開啟。(注意:這個設定或任何相同設定不需要在Apache 1設定)
AcceptPathInfo on

再次檢查PHP設定

Moodle需要很多PHP的設定是啟用的才能執行,這些在需求這一節有提到並且在多數的伺服器上這些已經是預設值,然而有些PHP伺服器(以及一些最近的PHP版本)可能有些設定不一樣,所以再次檢查設定是否正確是有用的,這些定義在PHP的組態檔中(通常叫php.ini)或是在Apache .htaccess檔裡:

register_globals = 0         ;(必須)
safe_mode = 0                ;(必須)
memory_limit = 40M           ;(不同:最小16M、32M Moodle v1.7、40M Moodle v1.8、128M 大型站台)
session.save_handler = files ;(除非你使用另外的處理器,e.g. mm)   
magic_quotes_gpc = 1         ;(手選但不必要,在2.0版時非常建議設為0)
magic_quotes_runtime = 0     ;(需要)
file_uploads = 1
session.auto_start = 0       ;(需要)
session.bug_compat_warn = 0

你也可能想樣設定其他的php.ini檔的設定在你已經在編輯的時候,例如,你可能想要重設最大上傳附件檔案的容量,這個預設是2M(megabytes),如果要設到16 Megabytes:

post_max_size = 16M
upload_max_filesize = 16M

目錄

webserver使用.htaccess檔及PHP設定

假如你可以直接編輯你的伺服器檔案你就使用上面的操作,但是假如你的Moodle是設在虛擬主機上,或是在你的伺服器上沒有權限存取httpd.confphp.ini,或是你的Moodle所在的伺服氣上有不一樣設定需求的應用程式時,那麼不用擔心,通常你仍然可以覆寫預設值,這只有在Apache伺服氣上並且只有在主要的Apache組態上當Overrides有開啟時就可以作,Moodle有提供你可以使用的htaccess檔,或是你可以自己手動產生這個檔。

  • 使用預設的htaccess檔,最容易的就是複製moodle/lib/htaccess這個範例檔,然後編輯以適合你的需要,它包含了進一步的指示,例如在Unix的殼下:
cd moodle
cp moodle/lib/htaccess .htaccess
  • 建立你自己的檔案,另一種方式你可以在Moodle的主目錄下產生自己的.htaccess檔,這個檔含有像下面的幾行。
DirectoryIndex index.php index.html index.htm
php_value memory_limit 40M (adjust to your version of Moodle)
php_flag magic_quotes_gpc 1
php_flag magic_quotes_runtime 0
php_flag file_uploads 1
php_flag session.auto_start 0
php_flag session.bug_compat_warn 0
假如你是安裝Apache 2版,增加這幾行:
<IfDefine APACHE2>
    AcceptPathInfo on
</IfDefine>
不然就是增加這一行:
AcceptPathInfo on
另外也可選擇性地增加定義上傳檔案大小的設定,例如增加這幾行:
LimitRequestBody 0
php_value upload_max_filesize 2M
php_value post_max_size 2M
這幾行的值是2M,你可以之後改變這個值來允許上傳較大的檔案。
  • 有些共享主機不允許.htaccess檔案,這樣的話可能需要放php.ini檔在這個站得每個子目錄下,要這樣作的話你可以使用你的編輯器在moodle主目錄裡產生php.ini檔案然後再複製到所有的子目錄下,php.ini檔的語法跟在.htaccess的有點不同 - 你不可以使用php_value及php_flag開頭的設定,看一下範例如下:
upload_max_filesize = 2M
post_max_size = 2M
在產生php.ini檔及你所需要的指令在裡面,執行腳本http://tips-scripts.com/php_ini_copy或是手動複製php.ini到所有的子目錄。
  • 有些共享主機使用suPHP,這個需要些微不同的設定,假如有錯誤,試著產生下面的兩個檔案然後上傳到你的moodle目錄:php.ini (範例):
register_globals = 0
display_errors = 0
.htaccess (範例):
suPHP_ConfigPath /home/cPanelName/public_html/moodle

改變上面的路徑來配合你安裝moodle的實際路徑。

  • 注意: 使用.htaccess檔只能作為[1]因為它會影響你的Moodle站台效能並且造成瀏覽的時候頁面載入變慢。

目錄

創建空白資料庫

你需要創建一個空白資料庫(例如"moodle")在你的資料庫系統以及一個特別的使用者(例如 "moodleuser")來存取這個資料庫(並且只能存取這個資料庫),假如你想要測試你的伺服器你也可以使用"root"使用者,但是對一個產品系統來說不建議使用:假如駭客發現了密碼那麼你的整個資料庫系統就處在風險之中,那時就不是只有一個資料庫了。

警告: 謹記,截至Moodle 1.5.x版,Moodle不能跟MySQL 5.x版的strict模式設定搭配使用(STRICT_TRANS_TABLES 且/或 STRICT_ALL_TABLES) -- 見論壇討論,所以假如你使用MySQL 5.x,編輯MySQL組態檔(在Windows叫"my.ini"而在Unix/Linux叫"my.cnf")然後將該選項註解起來或是設成sql-mode=,在改變完設定後你必須重新啟動MySQL,

假如你不能存取你的伺服器,使用PHPMyAdmin (或另一種MySQL客戶端程式)然後輸入命令SET @@global.sql_mode=
; (確定使用單引號並且不要忘記分號)。

使用託管伺服器

假如你正使用web主機,他們可能會有控制的web介面來給你創建資料庫。

cPanel系統是最受歡迎的一個系統。 使用cPanel創建資料庫:

  1. 點擊MySQL Databases圖示。
  2. 在New Database欄位輸入moodle然後點擊Create Database
  3. 在各自的欄位輸入usernamepassword (沒有一個其他地方使用)然後點擊Create User
    注意usernamedatabase的名稱很可能是你cPanel帳號名稱加_作開頭,並且縮到16個字元,在輸入這個資訊到Moodle的安裝程式時 - 使用完整的名稱。
  4. 現在使用Add Users to Databases按鈕並且給予這個新的使用者帳號ALL權限給這新的資料庫。

繼續建立資料目錄

使用SQLite資料庫

SQLite是一個實作自我獨立、無伺服器、零組態、交易的SQL資料庫引擎的軟體函式庫。

Moodle 2.0提供了SQLite3資料庫安裝的實驗性質支援,這樣子就不用設定資料庫,資料庫檔案將由安裝程式建立,預設資料庫檔案會儲存在Moodle的data目錄裡(見建立資料目錄),在安裝的時候,web伺服器必須在資料庫檔案儲存的目錄下有寫入的權限,在安裝後,web伺服器必須有讀寫資料庫檔案的權限。

繼續建立資料目錄

使用命令列

假如你有使用Unix或Windows命令列的權限那麼你可以藉由輸入命令來作同樣的事,假如你想使用MySQL資料庫你可以使用MySQL客戶端程式這樣作(你輸入的命令用粗體字表示):

- 開始MySQL客戶端程式:

#mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.22-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

- 提示變成"mysql>"是表示你現在是在MySQL客戶端程式工作,在MySQL工作時,所有的輸入的命令必須以分號來結束,(假如你沒有加分號按下Enter鍵,你會得到繼續的符號'->',這給你第二次機會來輸入分號並按Enter。)

- 開始確認是否有叫做"moodle"的資料庫 - 假如有你應該以下面所有的命令還改變名稱:

mysql> SHOW DATABASES;
+-------------------------+
| Database                |
+-------------------------+
| information_schema      |
| mysql                   |
| test                    |
+-------------------------+
3 rows in set (0.03 sec)

- 建立一個資料庫來儲存Moodle的資料表,我們稱作"moodle",因為上面列表沒有一個這樣的名稱,但是假如你需要你可以改變。

mysql> CREATE DATABASE moodle;
Query OK, 1 row affected (0.00 sec)

- 更改"moodle"資料庫預設的字元編碼及校對為UTF8,假如你是安裝或較早的版本就不用管這個步驟):

mysql> ALTER DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Query OK, 1 row affected (0.00 sec)

- 創建一個使用者及密碼來存取這個"moodle"資料庫並且允許資料庫存取權限,我們將用使用者"moodleuser"及密碼"yourpassword",在你的安裝弄得不一樣是較好的主義但是很多人會保持使用者名稱為"moodleuser",記住你設的使用者名稱及密碼,你在稍後的組態檔中會需要到,這是一個很長的命令所以用Return鍵來分成幾行。

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,
    -> DROP,INDEX,ALTER ON moodle.*
    -> TO moodleuser@localhost IDENTIFIED BY 'yourpassword';
Query OK, 0 rows affected (0.01 sec)
安全警告:不要用上面所顯示的一樣密碼,確認你有很安全的密碼(混合字母跟數字還有大小寫),避免允許資料庫的"ALL"權限。
注意:對於MySQL 4.0.1或較早版本,你不需要CREATE TEMPORARY TABLES權限。

- 跳出MySQL客戶端程式:

mysql> QUIT
Bye
#

- 使用mysqladmin程式重新載入允許資料表:

#mysqladmin -u root -p reload
Enter password:
#

這裡有使用PostgreSQL資料庫的範例命令:

  # su - postgres
  > psql -c "create user moodleuser createdb;" template1
  > psql -c "alter user moodleuser with encrypted password 'yourpassword';" template1
  > psql -c "create database moodle with encoding 'unicode';" -U moodleuser template1
  > psql -c "alter user moodleuser nocreatedb;" template1
  > su - root
  # /etc/init.d/postgresql reload

假如上面的Postgres創建資料庫命令(>psql -c "create database moodle...")有出現錯誤你可以這樣試:

psql -c "create database moodle with template=template1 encoding = 'unicode' owner =  moodleuser 
location = '/var/mydata';"

假如創建資料庫的命令詢問密碼,在處理前執行這一行'encrypted password'。

另見

目錄

創建資料目錄

Moodle還需要一些空間在你伺服器上的硬碟上來儲存上傳的檔案,像是課程文件及使用者照片,Moodle安裝程式會試著為你創建moodledata目錄但是假如失敗的話你必須手動建立一個目錄。

安全警告:為了安全起見,這個目錄是不能透過web來直接存取這是很重要的,最簡單的方式就是把它放在web站台根目錄以外的地方(根目錄這個資料夾就是你的URL主要的部份 -就是第一個/的地方;舉例來說在http://your.domain.com/moodle/admin/cron.php,它就是http://your.domain.com/)。

但是假如你必須在web目錄裡創建(而且你是使用Apache以及web伺服器的組態允許.htaccess檔案來限制存取目錄的話)那麼可以建一個叫.htaccess來保護資料目錄,這個檔有這幾行:

order deny,allow
deny from all

假如你使用IIS,你需要編輯資料目錄的屬性(從Internet Information Services管理控制台)並且拒絕任何人從web來存取資料夾。

假如你沒有保護資料目錄免於直接從web存取的話,任何人就能模仿你的Moodle站台上的任一個使用者(包括admin使用者!!!),而你的所有課程材料會在大型的網站上用到。

所有權與權限:要確認Moodle可以在這個目錄上傳檔案,確認web伺服器軟體有權限可以在這個目錄讀、寫及執行,在Unix機器上,這個設定是指目錄的所有權者有點像是"nobody"或"apache",接著給這個使用者讀、寫及執行的權限,舉例來說,要改變使用者為"nobody"你可以使用:

chown -R nobody:apache moodledata

要改變權限讓所有權者有讀、寫及執行權限,使用下面的操作:

chmod -R 0770 moodledata

注意:假如你得到permission denied這樣的訊息,試試chmod -R 0770 moodledata然後調整設定這樣會比較安全,較安全的設定是chmod -R 0750 moodledata,根據config-dist.php的註解,"在託管主機的系統上你可能需要確認你的群組沒有權限而其他人有所有的權限,"要這樣作你可以使用chmod -R 707 moodledata,另外參考安全頁

請記住預設情況下moodle會指出moodle資料目錄創建在web目錄裡的警告,但是除非這個目錄可以被放到你想要的目錄,你可以稍後再移動或改變目錄的位置,但是假如你這樣作,確認編輯config.php檔的設定;如果moodledata是在一個叫data的目錄下的話,那麼它就會像這樣:

$CFG->dataroot  = '/data/moodledata';

CPanel及託管主機

在cPanel系統上你可以使用"File Manager"來尋找資料夾,點擊它,然後選擇"Change Permissions",在很多共享主機伺服器上,你可能需要將所有檔案限制為你的"群組" (來避免其他的託管主機上的客戶來找或改變你的檔案),但是提供完全的讀/寫權限給任何人(這將允許web伺服器存取你的檔案), 假如你在安全的設定上有問題的話跟你的伺服器的管理員說,特別是在要在一個使用PHP的"Safe Mode"功能的站台上要創建一個可用的資料目錄是不可能的。

Table of Contents

Run the installer script to create config.php

To run the installer script (install.php), just try to access your Moodle main URL using a web browser, or access http://yourserver/install.php directly.

(The Installer will try to set a session cookie. If you get a popup warning in your browser make sure you accept that cookie!)

Moodle will detect that configuration is necessary and will lead you through some screens to help you create a new configuration file called config.php. At the end of the process Moodle will try and write the file into the right location, otherwise you can press a button to download it from the installer and then upload config.php into the main Moodle directory on the server.

Along the way the installer will test your server environment and give you suggestions about how to fix any problems. For most common issues these suggestions should be sufficient, but if you get stuck, check in the Installation Forum for more help.

Table of Contents

Go to the admin page to continue configuration

Once the basic config.php has been correctly created in the previous step, trying to access the front page of your site will take you to the "admin" page for the rest of the configuration.

The first time you access this admin page, you will be presented with a GPL "shrink wrap" agreement with which you must agree before you can continue with the setup.

Now Moodle will start setting up your database and creating tables to store data. Firstly, the main database tables are created. You should see a number of SQL statements followed by status messages that look like this:

CREATE TABLE course (
   id int(10) unsigned NOT NULL auto_increment,
   category int(10) unsigned NOT NULL default '0',
   password varchar(50) NOT NULL default '',
   fullname varchar(254) NOT NULL default '',
   shortname varchar(15) NOT NULL default '',
   summary text NOT NULL,
   format tinyint(4) NOT NULL default '1',
   teacher varchar(100) NOT NULL default 'Teacher',
   startdate int(10) unsigned NOT NULL default '0',
   enddate int(10) unsigned NOT NULL default '0',
   timemodified int(10) unsigned NOT NULL default '0',
   PRIMARY KEY (id)
) TYPE=MyISAM;

SUCCESS

...and so on, followed by: Main databases set up successfully.

If you don't see these, then there must have been some problem with the database or the configuration settings you defined in config.php. Check that PHP isn't in a restricted "Safe Mode" (commercial web hosts sometimes have safe mode turned on). You can check PHP variables by creating a little file containing <?php phpinfo() ?> and looking at it through a browser. Check all these and try this page again.

Scroll down the very bottom of the page and press the "Continue" link.

You should now see a form where you can define more configuration variables for your installation, such as the default language, SMTP hosts and so on. Don't worry too much about getting everything right just now - you can always come back and edit these later on using the admin interface. The defaults are designed to be useful and secure for most sites. Scroll down to the bottom and click "Save changes".

If (and only if) you find yourself getting stuck on this page, unable to continue, then your server probably has what I call the "buggy referrer" problem. This is easy to fix: just turn off the "secureforms" setting, then try to continue again.

Next you will see more pages that print lots of status messages as they set up all the tables required by the various Moodle module. As before, they should all be green.

Scroll down the very bottom of the page and press the "Continue" link.

The next page is a form where you can define parameters for your Moodle site and the front page, such as the name, format, description and so on. Fill this out (you can always come back and change these later) and then press "Save changes".

Finally, you will then be asked to create a top-level administration user for future access to the admin pages. Fill out the details with your own name, email etc and then click "Save changes". Not all the fields are required, but if you miss any important fields you'll be re-prompted for them.

Make sure you remember the username and password you chose for the administration user account, as they will be necessary to access the administration page in future.

(If for any reason your install is interrupted, or there is a system error of some kind that prevents you from logging in using the admin account, you can usually log in using the default username of "admin", with password "admin".)

Once successful, you will be returned to the home page of your new site! Note the administration links that appear down the left hand side of the page (these items also appear on a separate Admin page) - these items are only visible to you because you are logged in as the admin user. All your further administration of Moodle can now be done using this menu, such as:

  • creating and deleting courses
  • creating and editing user accounts
  • administering teacher accounts
  • changing site-wide settings like themes etc

But you are not done installing yet! There is one very important thing still to do (see the next section on cron).

Table of Contents

Installing Moodle Using Command Line

Template:Moodle 2.0

Installing Moodle Using command line is just as easy as installing Moodle using web browser.

  • First Go to the moodle root directory and then to admin directory inside the moodle root.
$cd /var/www/html/moodle/admin
  • Then simply use the following syntax to run the moodle command line installer (this is a long command which has been split over 3 lines, so type as one line)
$php cliupgrade.php --lang=en --webaddr=http://www.example.com --moodledir=/var/www/html/moodle 
                    --datadir=/var/moodledata --dbtype=mysql --dbhost=localhost --dbname=moodle 
                    --dbuser=root --prefix=mdl --verbose=1 --interactivelevel=2 

More information about the options can be found using $php cliupgrad.php --help

Then you will see the following list of available options

--lang		 		Valid installed language for installation. Default is English(en)
--webaddr			Web address for the Moodle site
--moodledir			Location of the moodle web folder
--datadir			Location of the moodle data folder (should not be web visible)
--dbtype			Database type. Default it mysql
--dbhost			Database host. Default localhost
--dbname			Database name. Default is moodle
--dbuser			Database user. Default is blank
--dbpass			Database password. Default is blank
--prefix			        Table prefix for above database tables. Default is mdl
--verbose			0 No output, 1 Summarized output(Default), 2 Detailed output
--interactivelevel	        0 Non interactive, 1 Semi interactive(Default), 2 Interactive
--help				print out this help

When you choose non interactive mode without any options all the default values are assumed.

Table of Contents

Set up cron

Moodle's background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the Cron instructions.

Set up backups

Please refer to the backup instructions.


Table of Contents

Create a new course

Now that Moodle is running properly, you can try creating a new course to play with.

Select "Create a new course" from the Admin page (or the admin links on the home page).

Fill out the form, paying special attention to the course format. You don't have to worry about the details too much at this stage, as everything can be changed later by the teacher. Note that the yellow help icons are everywhere to provide contextual help on any aspect.

Press "Save changes", and you will be taken to a new form where you can assign teachers to the course. You can only add existing user accounts from this form - if you want to create a new teacher account then either ask the teacher to create one for themselves (see the login page), or create one for them using the "Add a new user" on the Admin page.

Once done, the course is ready to customize, and is accessible via the "Courses" link on the home page.

See also

cs:Instalace nl:Installatiegids pl:Instalacja Moodle pt:Instalação do Moodle ru:Установка Moodle sk:Inštalácia zh:安装Moodlezh: