Moodle
はじめに
私のサイトには、プログラミング言語の入門記事が豊富にある。これは共有するべき私の財産であり、多くの人に活用してもらいたい。入門記事は筆者の視点で書かれている為、より教材として活用してもらうためにMoodleのインストールや教材のインストールについて記述する。PHPやMoodleなどはソースコードからインストールする場合、沢山の設定が必要なので力尽きそうになるが根気強くやるべきである。私もこのメモを残すまでに何度もインストールしては削除を繰り返している。作業したコマンドなどをメモしながらやる事で、最終的に手順書が出来るのでそういうやり方もいい。
Moodleのインストールに必要なもの
PHPのところにMoodleに必要なライブラリやデータベース、PHPのインストール手順を記述してある。これらが終わっている事がMoodleのインストールの前提条件となる
MySQLにMoodleのユーザを作成
-bash-3.00$ /opt/app/mysql/bin/mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.1.18
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database moodle;
Query OK, 1 row affected (0.01 sec)
mysql> grant select, insert, update, delete, create, drop, file, index, alter, create temp
orary tables on *.* to 'moodle'@'localhost' identified by 'moodle' with max_queries_per_ho
ur 0 max_connections_per_hour 0 max_updates_per_hour 0;
Query OK, 0 rows affected (0.07 sec)
mysql> quit;
Bye
Moodleのインストールを考える
Moodleのダウンロードと展開
自分のホームディレクトリに展開する
cd /usr/local/apache2/htdocs
wget http://download.moodle.org/stable15/moodle-1.5.3.tgz
tar -zxvf moodle-1.5.3.tgz
httpd.confの修正と再起動
DirectoryIndexにindex.phpが追加されていない場合は追加する。Aliasによりホームディレクトリのmoodleへリンクさせる。この時の注意としては、Alias /moodle/というように最後にスラッシュを入れると正常に動作しない。
DirectoryIndex index.html index.html.var index.php index.xhtml
Alias /moodle "/Users/okitasatoshi/moodle/"
-bash-3.00$ sudo /usr/local/apache2/bin/apachectl restart
Moodleの動作確認
http://www.oklab.org/moodle/へアクセスすると初期設定ウィザードが出てくるのでウィザードどおり設定する。
文字化け対応
MySQLはUTF-8のキャラクタセットになっている.
mysql> show variables like 'char%';
+--------------------------+--------------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /opt/app/mysql/share/mysql/charsets/ |
+--------------------------+--------------------------------------+
7 rows in set (0.02 sec)
mysql> quit
Bye
http://tsuttayo.sytes.net/php/char_trn/index.htmlでPHPの文字化けについて書かれているのでphp.iniをUTF-8へ修正する。その後mysql上でdrop database moodleを行い、データベースを再作成。またホームディレクトリにあるmoodleとmoodledataディレクトリを削除して再展開。
これにより、UTF-8での文字化けを解消できた。また出力するHTMLがXHTML1.0になっていた。

