Moodle环境搭建

发布时间 2023-11-25 13:10:58作者: Fintech技术汇

Environment (Windows OS)

Apache and PHP8 installation reference

PHP Installation

reference:

  1. download PHP 8.0.3 https://windows.php.net/downloads/releases/php-8.0.30-Win32-vs16-x64.zip
  2. unzip to a folder, e.g. D:\Tool\PHPEnv\php-8.0.30
  3. copy php.ini-development and name the file as php.ini
  4. edit php.ini: change ;extension_dir = "ext" to extension_dir = "D:\Tool\PHPEnv\php-8.0.30\ext"

Apache Installation

  1. download binary from https://www.apachelounge.com/download/VS17/binaries/httpd-2.4.57-win64-VS17.zip
  2. unzip to a folder e.g. D:\Tool\PHPEnv\Apache24
  3. copy "D:\Tool\PHPEnv\php-8.0.30\libsodium.dll" to "D:\Tool\PHPEnv\Apache24\bin\libsodium.dll"
  4. edit config file: D:\Tool\PHPEnv\Apache24\conf\httpd.conf
  • change Define SRVROOT "c:/Apache24" to Define SRVROOT "D:/Tool/PHPEnv/Apache24"
  • (optional) uncomment #ServerName www.example.com:80 and change www.example.com to localhost
  • add below content under line: #LoadModule xml2enc_module modules/mod_xml2enc.so
#加载PHP
LoadModule php_module 'D:\Tool\PHPEnv\php-8.0.30\php8apache2_4.dll'

#将PHP配置文件加载到Apache配置文件中,共同生效
PHPIniDir 'D:\Tool\PHPEnv\php-8.0.30'

#配置Apache分配工作给PHP模块,把PHP代码交给PHP处理
#即.php后缀名的文件
AddType application/x-httpd-php .php

  • add below in the end of file httpd.conf
<IfModule mpm_winnt_module>
 ThreadStackSize 8888888
</IfModule>
  1. open command line and go to D:\Tool\PHPEnv\Apache24\bin folder
  2. run httpd.exe and open http://localhost in browser, it works fine if you can see "It works!" in browser

PHP and Apache integration test

  1. go to folder D:\Tool\PHPEnv\Apache24\htdocs
  2. create a file named test.php and copy below content to this file
<?php
	//test
	echo 'Hello php!';
?>
  1. run httpd in cmd
  2. open url in browser: http://localhost/test.php and verify if "Hello php!" is shown.

MySql Installation

download URL: https://dev.mysql.com/downloads/mysql/

reference: https://blog.csdn.net/weixin_43423484/article/details/124408565

https://zhuanlan.zhihu.com/p/420917888#:~:text=在 Windows 上配置免安装版 MySQL 8.0 1 1 下载并安装,my.ini 在 D%3A%2Fmysql%2F 内新建文本文件 my.ini,在其中写入以下内容: ... More items

  1. create database named moodle after installation

Moodle

  1. version 4.2.2
  2. Branch: MOODLE_402_STABLE
  3. go to folder D:\Tool\PHPEnv\Apache24\htdocs and put moodle code in this folder
  4. run httpd and open http://localhost/hackathon_2023/install.php in browser
  5. configure moodle in the opened guide