Windows系統XAMPP安裝Moodle教程


  

一.安裝工具下載: 

  系統環境:

     Operating System: Windows 10 Enterprise 64-bit (10.0, Build 17134) 

  集成軟件:

    XAMPP Version: 7.2.10,XAMPP主要就是搭建apache服務器和mysql數據庫。XAMPP(Apache+MySQL+PHP+PERL)是一個功能強大的建站集成軟件包。當然你也可以使用easy PHP或者wamp或帝國軟件,這些都是集成包。你要是不想使用的話可以自己單獨安裝后自己配置。這里我使用xampp 7.2.10。 

    xampp最新版下載地址:https://www.apachefriends.org/index.html

    安裝Moodle 3.5.2的要求: PHP 7.0, MariaDB 5.5.31 or MySQL 5.5.31 or Postgres 9.3 or MSSQL 2008 or Oracle 10.2

  Moodle下載:

    Moodle最新版下載地址:https://download.moodle.org/releases/latest/ 

    Moole 3.5.2+ :  后面的+表示Moodle是穩定版

   如果要使用和我一樣的版本的話,使用下面的下載地址:

        鏈接:https://pan.baidu.com/s/1b0j2MLhdz1GzrXRiRVhFnA
        提取碼:tg73

 

二.安裝環境配置:

  由於我的電腦上已經有IIS服務器了,IIS服務器使用的是80端口,你如果安裝apache的話也會使用80端口,這樣會造成沖突,所以我們需要配置IIS的端口。當然你的電腦上沒有IIS的話不用執行下面的步驟:

  1.使用Windows+R打開運行,輸入compmgmt.msc 打開計算機管理

  

  2.定位到IIS管理,點擊關閉

  

  3.點擊綁定,修改端口

  

  4.點擊開始,然后在瀏覽器中輸入localhost:81,可以看到已經可以訪問到IIS了,這樣端口就修改完成了。

  

三.開始安裝

  1.xampp安裝:

  

  

  這里是讓你不要安裝到C:\Program Files(x86)文件夾下,因為它沒有安裝權限。UAC就是

  

     

     

    我這里安裝到了D:\xampp,之后就一直下一步就行

    

    安裝完后,打開D:\xampp\xampp-control.exe

    

     

     這里一定要保證apache和MySQL是綠色的才可以安裝后面的步驟。

     apache啟動常見錯誤

        1.1有其他程序在占用80端口,你直接netstat找到占用端口的程序后,啟動任務管理器,找到對應的程序結束后就可以。

        

        1.2有其他程序占用80端口,任務管理器結束不了的話修改apache的監聽端口為82,然后重啟apache服務器。

          注意:如果在這里修改為82端口后,之后訪問apache的地址為: localhost:82  沒有修改的話直接 localhost 就可以

        

        

        當你在瀏覽器中輸入localhost后可以看到這個界面時表示apache已經正確安裝

    mysql啟動常見錯誤:

      以前安裝過MySQL57或MySQL,沒有卸載干凈。

      1.在環境變量PATH中將MySQL刪除

      

    2.管理員運行cmd,cd 到D:\xampp\mysql\bin

    

    輸入sc query mysql,查看一下名為mysql的服務:  

              

      發現之前確實有安裝過。

     命令sc delete mysql,刪除該mysql

               

     輸入安裝命令mysqld install    

               

     此時,查看xampp-control.exe就可以發現mysql的服務就正常啟動了

  2.Moodle安裝

    將下載的moodle-latest-35.zip解壓后,拷貝其中的moodle文件夾到D:\xampp\htdocs

      

   將下載的語言包zh_cn.zip解壓后拷貝到D:\xampp\htdocs\moodle\lang下

    

 

   在瀏覽器地址欄(之后默認都是在地址欄中輸入)中輸入localhost/moodle   如果你之前改過Apache的端口為82 ,則這里應該輸入localhost:82/moodle

    

  直接一直next:

  

         

   

  

  到了這一步會有以下錯誤:

   

   

  這里寫下這些錯誤的解決方法(你也可以直接點擊后的文字查看官方的文檔,此時你必須在第一步選擇英文安裝才能看到官方的英文文獻),不想看的看我的解決方法:

  2.1Wrong $CFG->dbtype: you need to change it in your config.phpfile, from 'mysql' to 'mariadb'.

    修改D:\xampp\htdocs\moodle\config.php  

$CFG->dbtype    = 'mariadb';

    

  2.2需要 Intl 擴展改善國際化支持,例如與語言區適應的排序及國際域名。

  (Intl extension is required to improve internationalization support, such as locale aware sorting and international domain names.)

    網頁服務及Moodle網絡功能需要 XMLRPC 擴展。

  (The XMLRPC extension is useful for web services and Moodle networking.)

   網絡服務和某些插件需要安裝可選的 SOAP 擴展。

  (Installing the optional SOAP extension is useful for web services and some plugins.)


   修改D:\xampp\php\php.ini 將intl,xmlrpc,soap前面的分號去掉

    

    

    

  2.3PHP字節碼緩存提高性能且降低對內存的要求。Moodle完全支持並建議使用OPC緩存擴展

  (PHP opcode caching improves performance and lowers memory requirements, OPcache extension is recommended and fully supported.)

 

  修改D:\xampp\php\php.ini 查找到[opcache]所在的位置添加以下代碼

  

[opcache]
opcache.enable = 1
opcache.memory_consumption = 128
opcache.max_accelerated_files = 10000
opcache.revalidate_freq = 60
; Required
for Moodle opcache.use_cwd = 1 opcache.validate_timestamps = 1 opcache.save_comments = 1 opcache.enable_file_override = 0
zend_extension=opcache.so
; If something does not work
in Moodle ;opcache.revalidate_path = 1 ; May fix problems with include paths ;opcache.mmap_base = 0x20000000 ; (Windows only) fix OPcache crashes with event id 487 ; Experimental for Moodle 2.6 and later ;opcache.fast_shutdown = 1 ;opcache.enable_cli = 1 ; Speeds up CLI cron ;opcache.load_comments = 0 ; May lower memory use, might not be compatible with add-ons and other apps.

  

  然后,在php.ini的文檔的最末尾添加

[ExtensionList]
zend_extension=php_opcache.dll

  

 

  

  2.4您的數據庫在使用 Antelope 作為文件格式。在MySQL和MariaDB實現完全 UTF-8 支持需要使用 Barracuda 文件格式。請切換至 Barracuda 文件格式。詳見以下文檔MySQL full unicode support(Your database uses Antelope as the file format. Full UTF-8 support in MySQL and MariaDB requires the Barracuda file format. Please switch to the Barracuda file format. See the documentation MySQL full unicode support for details.)

   為了能完整支持 UTF-8 ,MYSQL 和 MariaDB 兩者都需要您把您的 MySQL 配置 \'innodb_file_per_table\' 為 \'ON\'。請參考文檔以便了解細節(For full support of UTF-8 both MySQL and MariaDB require you to change your MySQL setting 'innodb_large_prefix' to 'ON'. See the documentation for further details.)

 

  修改D:\xampp\mysql\bin|\my.ini 分別在對應位置添加下列代碼

[client]
default-character-set = utf8mb4

[mysqld]
innodb_file_format = Barracuda
innodb_file_per_table = 1
innodb_large_prefix

character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
skip-character-set-client-handshake

[mysql]
default-character-set = utf8mb4

      

  

  

   Antelope和Barracuda均為innodb存儲引擎的文件格式,Antelope為默認格式,非壓縮;Barracuda為壓縮格式;兩者主要的不同在於對大數據量的存儲時所占用的空間差異。
若要使用innodb的壓縮功能,則必須使用innodb_file_format=Barracuda,不然沒有作用。

  2.5已經檢測到你的網站沒有使用 HTTPS 來增加安全。強烈建議您將您的網站改用HTTPS 以增加安全性,並改進與其他系統的整合。(It has been detected that your site is not secured using HTTPS. It is strongly recommended to migrate your site to HTTPS for increased security and improved integration with other systems.)

   

 

  這個是讓你安裝SSL 證書,就是提供https的訪問,我這里不需要,這個問題可以跳過不用修改,需要的查看 https://docs.moodle.org/35/en/Transitioning_to_HTTPS

   

  在解決完以上問題后,在xampp-control重啟Apache和mysql服務,然后點擊瀏覽器頁面最下面的重新加載按鈕

  如果重新加載后出現以下畫面表示可以繼續

  

  如果還是出現2.4的問題,那么你要執行以下命令:

  以管理員身份啟動cmd,定位到D:\xampp\mysql\bin下

mysql -u root -p

  表示以root身份登錄到mysql

  

show global variables like "innodb_file_format%";
set global innodb_file_format=Barracuda;
set global innodb_large_prefix=ON;
 set global innodb_file_format_max=Barracuda;
show global variables like "innodb_file_format%";

  

  然后重新啟動mysql服務,然后重新加載頁面就可以。

  點擊繼續安裝:

  

  出現這個界面,說明正在開始安裝,你要等好一會。安裝完后繼續:

  

  

  這幾個紅色的為必填項,是設置你一會要登錄的管理員賬號,一定要記住。其他信息自己填,不填也可以,然后繼續。這里有點慢,大家要等一會。

  在這里等一會之后如果出現登錄頁面則表示正常。如果一直是空白頁面你則需要進行以下步驟:

  (1)在D:\xampp\php\php.ini文件中,

    ;open_basedir =

    這句是注釋掉的,改為(XAMPP集成安裝路徑)如下:   

open_basedir = "D:\xampp"

    open_basedir用來限制網站文件訪問路徑

  

  (2)D:\xampp\moodledata這個文件夾本來在Moodle外,需要將其移動到D:\xampp\htdocs\moodle下

    

    修改在D:\xampp\htdocs\moodle\config.php文件中   

$CFG->dataroot  = 'D:\\xampp\\htdocs\\moodle\\moodledata';

    

    

    這兩步處理好后,在瀏覽器輸入localhost/moodle/admin/index.php,訪問不會空白了,但是出現如下問題:

      Fatal error: Maximum execution time of 30 seconds exceeded in D:\xampp\htdocs\moodle\lib\classes\component.php on line 752

      這是因為你的上面修改config.php中的$CFG->dataroot 后面的路徑中丟了\\,這里是 \\ 不是 \,重新修改刷新后就會出現下面問題

      

      Warning: is_readable(): open_basedir restriction in effect. File(/db/renamedclasses.php) is not within the allowed path(s): (D:\xampp) in D:\xampp\htdocs\moodle\lib\classes\component.php on line 1236

      修改如下:

      D:\xampp\htdocs\moodle\admin目錄下index.php文件里有如下代碼段:      

if ((isset($_GET['cache']) and $_GET['cache'] === '0')
        or (isset($_POST['cache']) and $_POST['cache'] === '0')
        or (!isset($_POST['cache']) and !isset($_GET['cache']) and empty($_GET['sesskey']) and empty($_POST['sesskey']))) {
    // Prevent caching at all cost when visiting this page directly,
    // we redirect to self once we known no upgrades are necessary.
    // Note: $_GET and $_POST are used here intentionally because our param cleaning is not loaded yet.
    // Note2: the sesskey is present in all block editing hacks, we can not redirect there, so enable caching.
    define('CACHE_DISABLE_ALL', true);

    // Force OPcache reset if used, we do not want any stale caches
    // when detecting if upgrade necessary or when running upgrade.
    if (function_exists('opcache_reset')) {
        opcache_reset();
    }
    $cache = 0;

} else {
    $cache = 1;
}

      這段代碼為檢測Moodle是否有緩存信息和關鍵數據保護檢測。會根據不同的情況給cache字段賦值。   

        (1)將這段代碼注釋或刪除掉,使得moodle平台在第一次安裝后進入該頁面不去考慮cache值的設置,而直接進入平台的主頁面。  

           

        (2)在目錄欄內輸入localhost/moodle/index.php?cache=1。然后對平台進行操作時,數據庫和緩存中會有新生成數據的寫入。 之后再輸入http://localhost/moodle/admin/user.php進入登陸界面

           

            

            當然,你也可以換成中文。

        (3)此時再在index.php文件中恢復上述注釋或刪除的代碼段。再次打開Moodle平台時,檢測機制會順利的通過,而不會出現因檢測語句冗余而產生的頁面重定向循環問題。


   至此,Moodle安裝成功!!!

  

  最后,提供Moodle官網下載插件的鏈接:

    https://moodle.org/plugins

  插件安裝方法:

    https://docs.moodle.org/all/zh/index.php?title=%E5%AE%89%E8%A3%85%E6%8F%92%E4%BB%B6&variant=zh

 

參考網址:

  https://blog.csdn.net/shiyongchun8212/article/details/83415585

  https://blog.csdn.net/zcyzsy/article/details/52012664 

  https://blog.csdn.net/wll_1017/article/details/54860881

   https://www.jb51.net/article/52530.htm


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM