這一指南是說明如何第一次安裝 Moodle。其中有些步驟是在詳細說明網頁伺服器的設定,因此這文件可能看起來長又複雜。不必驚慌,一旦您知道如何做,您可以在幾分鐘之內安裝好 Moodle!
如果您遇到困難,請仔細讀這一文件,--大多數常見的問題在此都有答案。 如果您還是有問題,您可以從 Moodle 幫助尋求幫助。
另一個方法是聯絡一家 虛擬主機出租服務公司 它可以完全為你安裝並維護 Moodle,這樣您就可以不管這些,並直接開始教學工作了!
此文件的章節:
Moodle 基本上是在 Linux 發展出來,它使用 Apache, MySQL 和 PHP (有時也被稱為LAMP平台),但也在 PostgreSQL 測試過,並在 Windows XP, Mac OS X 和 Netware 6 操作系統測試過。
安裝 Moodle 的需前如下:
- 網頁伺服器軟體。大多數人使用 Apache, 但是 Moodle 在任何能夠支持 PHP 的網頁伺服器上都能正常運作,比如 Windows 平台上的IIS。
- PHP 腳本語言 (4.1.0版或以後)。 PHP 5 要在 Moodle 1.4. 版以後才有支援
- 一個能運作的資料庫伺服器: MySQL 或 PostgreSQL 是完全支援,並推薦使用在 Moodle上。
大多數的網頁主機基本上都支持上述的程式。如果您是和少數不支援這些功能的網頁主機簽約,問他們為什麼沒有,並考慮換一家公司。
如果您想在自己的電腦上跑 Moodle ,而所有這些看起來有點棘手,那麼請看我們的指南: 安裝 Apache, MySQL and PHP。 它提供一些在常用平台上逐步安裝的指令。
有兩種方法可以拿到 Moodle,經由壓縮包和經由 CVS。這些在下載頁有詳細的解釋: http://moodle.org/download/
在下載並解壓縮這些檔案之後,或經由 CVS 取出這些檔案之後,您將會跑出一個稱為"moodle"的資料夾,包含有一些檔案和資料夾。
您若不是把整個資料夾搬到您的網頁伺服器文件目錄中,這時您的網站將位於 http://yourwebserver.com/moodle, 就是要直接複製所有的內容貼到主要網頁伺服器文件目錄中,在這種情況下您的網站將是 http://yourwebserver.com
如果您要下載 Moodle 到您的本地電腦,然後傳到您的遠端網頁伺服器主機上, 通常較好的方法是以單一檔案方式上傳,然後在伺服器上解壓縮。即使像 Cpanel 的出租網站主機也都允許您在 "檔案管理"終將檔案解壓縮。
您跳過這一節也沒有關係,但這是 Moodle 各資料夾的內容的簡短摘要,可幫助您弄清楚頭緒:
config.php - 包含各種基本設定。這檔案不是隨著 Moodle而來 - 您需要在安裝過程建立它。 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/ - 顯現和管理用戶的程式碼
要執行安裝腳本程式 (install.php),只要用網頁瀏覽器進入您的 Moodle的主要 URL,或直接執行 http://yourserver/install.php 。
(安裝程式將會設定一個 session cookie。若您的瀏覽器以跳出視窗來警告您,要確定您把瀏覽器設定為能接受 cookie!)
Moodle 將會偵測必要的設定,並由一些螢幕畫面引導您建立一新的設定檔,稱為 config.php 。在這過程結束,Moodle 會在正確的地方寫入這個檔案,否則的話,您可以從安裝程式中按一按鈕來下載它, 然後上傳 config.php 到伺服器的 Moodle 主目錄中。
安裝程式一路上會測試您的伺服器環境,並提供建議來解決問題。就大多數常見問題而言,這些建議已經足夠了,但若您卡住了,閱讀下面更多的訊息,或許能救您一把。
4.1 檢查網頁伺服器的設定
首先,要確定您的網頁伺服器是被設定成使用 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 檔中加上這一行。
AcceptPathInfo on第三,Moodle 需要啟動一些 PHP 設定才能工作。在大多數的伺服器上,這些都已經是預設的設定了。 然而,有些 PHP 伺服器 (以及一些較新的 PHP 版本) 可能有些設定不一樣。 以下是 PHP的設定檔中應加上去的 (通常是指 php.ini):
magic_quotes_gpc = 1 (最好有,但不是必要) magic_quotes_runtime = 0 (必要) file_uploads = 1 session.auto_start = 0 session.bug_compat_warn = 0如果您再您的伺服器上無法改寫 httpd.conf 或 php.ini檔,或者您的 Moodle所在的伺服器同時在跑其他應用程式,需要不同的設定,那別擔心,您通常還是可以"覆蓋"掉預設的設定。
要這樣做,您需要在Moodle的主要目錄中建立一個檔案,稱之為.htaccess ,並包含下列幾行文字。 這只有在 Apache 伺服器上有效,並且在主要設定中允許"覆蓋"。
DirectoryIndex index.php index.html index.htm <IfDefine APACHE2> AcceptPathInfo on </IfDefine> 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您也可以界定上傳檔案的最大限制:
LimitRequestBody 0 php_value upload_max_filesize 2M php_value post_max_size 2M最簡單的做法就是從lib/htaccess複製樣本檔,並編輯它以符合您的需要。它包含有進一步的指示。例如, 在 Unix 系統上:
cp lib/htaccess .htaccess
4.2 建立一資料庫
您需要在您的資料庫系統中建立一個空的資料庫 (例如 "moodle") ,並指定一特殊用用戶(例如 "moodleuser") 具有存取資料庫的權限 (且只有這資料庫)。若您只是要測試這伺服器,您可以使用 "root" 用戶,但是若在正式運作的伺服器上,千萬別這樣做,因為如果駭客發現了這密碼,那您整個資料庫系統將有很大的風險,且不只是一個資料庫。
如果您是租用虛擬網站主機,他們可能有一個透過網頁的控制面板,讓您能建立您的資料庫。
這Cpanel 系統是其中最普遍的一個。要在 Cpanel建立資料庫:
- 點選 "MySQL Databases" 圖示。
- 在資料庫欄位中打入 "moodle" ,並點選 "Add Database"。
- 輸入一個用戶名稱和密碼 (不是您在別處使用的)到相對的欄位,然後點選 "Add User"。
- 現在使用 "Add User to Database" 按鈕來讓這新用戶帳號對新資料庫具有全部"ALL"的權力。
- 注意,很可能這用戶名稱和資料庫名稱,在您申請您的 Cpanel帳號名稱時就以被決定了。所以當輸入這一資訊到Moodle安裝程式時 - 請使用完整名稱。
如果您可以直接使用 Unix 指令,您可以藉著打入指令來做同樣的事。
以下是一些用於 MySQL 的 Unix 指令的範例 :
# mysql -u root -p > CREATE DATABASE moodle; > GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER ON moodle.* TO moodleuser@localhost IDENTIFIED BY 'yourpassword'; > quit # mysqladmin -p reload以及用在 PostgreSQL的指令:
# su - postgres > psql -c "create user moodleuser createdb;" template1 > psql -c "create database moodle;" -U moodleuser template1 > psql -c "alter user moodleuser nocreatedb;" template1
4.3 建立一資料目錄
Moodle也需要在您的伺服器的硬碟上有一些空間,好存放上傳的檔案,比如說,課程文件和用戶圖像。
Moodle 安裝程式會努力試著為您建立這個目錄,但是若不行,那您就必須自己動手建立它。
為了安全,這目錄最好是無法透過網頁直接存取的。要這樣做最間單的方式就是把把這資料目錄放在網頁目錄之外,但是如果您一定要放在網頁目錄之內,那保護的方法就是在資料目錄建一檔案,稱為 .htaccess,並包含這一行字:
deny from all要確定 Moodle 可以儲存上傳的檔案到這一目錄,檢查這網頁伺服器軟體 (如 Apache) 有權限在這一目錄中讀取,寫入,和執行。
On Unix machines, this means setting the owner of the directory to be something like "nobody" or "apache", and then giving that user read, write and execute permissions.
On Cpanel systems you can use the "File Manager" to find the folder, click on it, then choose "Change Permissions". On many shared hosting servers, you will probably need to restrict all file access to your "group" (to prevent other webhost customers from looking at or changing your files), but provide full read/write access to everyone else (which will allow the web server to access your files).
Speak to your server administrator if you are having trouble setting this up securely. In particular some sites that use a PHP feature known as "Safe Mode" may require the administrator to create this directory properly for you.
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 the "admin" page for the rest of the configuration.
The first time you access this admin page, you will be presented with a GPL "shrinkwrap" 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 (in green or red) 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).
某些 Moodle的模組需要持續的檢查以執行其工作。舉例來說,Moodle 需要定期檢查討論區,這樣它才可以用電子郵件寄貼文副本給那些訂閱該討論區的人。
做這些事情的腳本程式釋放於管理目錄中,稱為 cron.php。然而,它不會自己執行,因此您要設定一個機制 使這腳本定期運作(例如 每五分鐘或每十分鐘)。這提供氇一個"心跳", so that the script can perform functions at periods defined by each module. 這種定期的機制被稱為cron service。
注意,執行 Cron 的機器 不需要與執行Moodle的電腦是同一台。舉例來說,如果您有一個受限制的虛擬網站出租服務, 無法有 cron 的服務,那您可以在另一台伺服器上或在您的家用電腦上執行 cron。 最重要的是 cron.php 檔案會被定期的執行。
這腳本的負擔不會很高,所以5分鐘通常是很合理的,但若您擔心的話,您可以加長時間間格,比如15分鐘,或甚至30分鐘。 但是最好不要間格太長,因為經常延遲寄出的郵件會減緩課程中的活動。
首先,直接從您的瀏覽器去執行它,看它能否正常作:
http://example.com/moodle/admin/cron.php現在,您作某些設定來自動並定期的執行這腳本。
在 Windows系統上
最簡單的方式是利用這小包裹moodle-cron-for-windows.zip經由安裝一個小 Windows 服務,可把事情變得非常簡單。執行它,然後置之不理!
在虛擬網站租用服務上
Your web-based control panel may have a web page that allows you to set up this cron process. For example, on Cpanel system, look for a button called "Cron jobs". In there you can put the same sort of Unix commands as listed below.
在 Unix 上使用指令
There are different command line programs you can use to call the page from the command line. Not all of them may be available on a given server.
For example, you can use a Unix utility like 'wget':
wget -q -O /dev/null http://example.com/moodle/admin/cron.phpNote in this example that the output is thrown away (to /dev/null).
The same thing using lynx:
lynx -dump http://example.com/moodle/admin/cron.php > /dev/nullAlternatively you could use a standalone version of PHP, compiled to be run on the command line. The advantage with doing this is that your web server logs aren't filled with constant requests to cron.php. The disadvantage is that you need to have access to a command-line version of php.
/opt/bin/php /web/moodle/admin/cron.phpUsing the crontab program on Unix
All that Cpanel does is provide a web interface to a Unix utility known as crontab. If you have a command line, you can set up crontab yourself using the command:
crontab -eand then adding one of the above commands like:
*/5 * * * * wget -q -O /dev/null http://example.com/moodle/admin/cron.php通常,這"crontab"指令會把您帶到'vi' 編輯器。藉著按下"i",您會進入"插入設模式",然後打入上面那一行,然後按 ESC 離開插入模式。您打入":wq"就會儲存並退出,或用":q!"(不加引號)退出而不儲存。
現在 Moodle 已經能正常運轉了,您可以建立一新課程來試玩看看。
從管理頁面中選擇 "創建一新課程"(或首頁的管理連結)。
填寫好這表格,特別注意這課程格式。在這階段您不需要擔心太多的細節,因為每一個設定,稍後教師都可以加以更改。注意:這黃色問號的幫助圖示到處都有,可以在各方面提供脈絡式的幫助。
按下 "儲存變更",然後您會看到新表格,那兒可讓您指派教師給這一新課程。You can only add existing user accounts from this form - 如果您想要建立一個新教師帳號,那麼若不是要求這教師為他們自己申請一新帳號(建登入頁面),就是要在管理頁面,使用"新增一新用戶"來為他建立帳號。
一旦完成,這課程就可以開始製作了,而且它可以由首頁的 "課程" 連結進入這課程中。
請參見 "教師手冊" ,可找到建立課程的更多細節。
快樂地探索且快樂地Moodling!
若您喜歡 Moodle,請考慮 捐款 幫助我們應付我們的花費!
版本: $Id: install.html,v 1.3 2008/07/27 16:28:41 kiang Exp $