Raspberry安裝moodle3.7
一、安裝apache2+mariadb9+php7.3
Step1)安裝apache與mysql
#sudo apt-get install apache2 mysql-server mysql-client
Step2)安裝moodle3.7需要php7.1以上版本,樹梅派3預設套件庫只允許安裝php7.0,需要新增套件庫網址。
#sudo apt install ca-certificates apt-transport-https -y
#wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
#echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
#sudo apt update
Step3) 安裝php7.3套件
#sudo apt install libapache2-mod-php7.3 php7.3-cli php7.3-common php7.3-curl php7.3-mbstring php7.3-mysql php7.3-xml php7.3-json php7.3-intl php7.3-soap -y
Step4)安裝php7.3後,Apache啟動php7.3
#sudo a2enmod php7.3
#sudo service apache2 restart
Step5)建立與瀏覽phpinfo.php,看看mysql模組是否安裝完成
二、安裝moodle
Step1)安裝git,用於下載moodle程式碼
#sudo apt install git
Step2)使用tmp資料夾下載moodle程式碼
#cd /tmp
#sudo git clone git://git.moodle.org/moodle.git
#cd moodle
#sudo git branch -a
#sudo git branch --track MOODLE_37_STABLE origin/MOODLE_37_STABLE
#sudo git checkout MOODLE_37_STABLE
Step3)將moodle程式碼從tmp搬移到/var/www/html下,建立資料夾moodledata用於儲存moodle檔案與資料。
#sudo cp -R /tmp/moodle /var/www/html/
#sudo mkdir /var/moodledata
#sudo chown -R www-data /var/moodledata
#sudo chmod -R 777 /var/moodledata
#sudo chmod -R 0755 /var/www/html/moodle
Step4)修改mysqld的設定
#sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf
在[mysqld]下方新增以下設定
default_storage_engine = innodb
innodb_file_per_table = 1
innodb_file_format = Barracuda
重新啟動mysqld
#sudo service mysql restart
Step5)登入mariadb(mysql)資料庫
#sudo mysql -u root -p
新增資料庫
mysql>CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
註:utf8mb4使用4byte的UTF-8編碼
Step6)新增moodle的mariadb(mysql)資料庫使用者
mysql>create user 'moodledb'@'localhost' IDENTIFIED BY 'mypass';
mysql>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO moodledb@localhost IDENTIFIED BY 'mypass';
Step7)使用網頁進行安裝
#sudo chmod -R 777 /var/www/html/moodle
安裝完成後,執行下方指令。
#sudo chmod -R 0755 /var/www/html/moodle
Step8)瀏覽http\\IP\moodle\install.php ,使用網頁安裝moodle。
Step9 innodb_large_prefix要設定為ON
#sudo mysql -u root -p
mysql> set global innodb_large_prefix = `ON`;
參考資料
(1)Raspberry Pi 安裝 LAMP(PHP 7.3)
https://dotblogs.com.tw/sideprogrammer/2019/01/13/raspberry-pi-install-lamp
(2)Step-by-step Installation Guide for Ubuntu
https://docs.moodle.org/37/en/Step-by-step_Installation_Guide_for_Ubuntu#Step_1:_Install_Ubuntu