基于CentOS构建Moodle网络教学系统

时间:2023-06-08 08:18:04 公文范文 来源:网友投稿

摘要:采用Moodle这一开源软件来构建网络教学系统已成为国内外众多教育机构的选择,但是目前国内一些 Moodle网络教学系统的性能并不十分稳定。文章提出了从软件方面解决这一问题的方法,详细介绍了安装CentOS和配置Moodle所需的Web系统的过程,最后提出了构建稳定的Moodle系统所需努力的方向。

关键词:CentOS;Moodle;网络教学系统

中图分类号:G434 文献标识码:A文章编号:1009-3044(2011)26-6415-05

Buliding Moodle Online Teaching System Based on CentOS

LIUKai

(School of Computer Science, Sichuan University of Science & Engineering, Zigong 643000, China)

Abstract: The use of Moodle open source software to build online teaching system has become the choice of foreign and domestic educational institutions, but the performance of some domestic Moodle online teaching system is not very stable. To solve this problem, this paper presents a solution to this problem from a software approach, expounds the process of installing CentOS and configuring Web system of Moodle, and proposes some method to building a stable Moodle system in future.

Key words: centos; moodle; online teching system

Moodle是目前世界上使用最为广泛的开源网络教学系统之一。为了使该系统能够有一个稳定的运行环境,必须寻找一个稳定的服务器操作系统。在网络操作系统中,安全性和稳定性最高的是Unix操作系统,但是该系统对计算机硬件配置环境要求很高,一般教育部门很难提供这样高端的网络环境。而Windows的服务器操作系统跟Moodle搭配,协调性欠佳。Moodle 主要是在Linux系统下使用Apache, MySQL 和 PHP 开发的,因此,将Moodle安装在Linux环境下能够达到最好的协调性,并发挥Moodle的最佳性能。在众多的Linux服务器版本中,Red Hat Enterprise Linux是世界上最著名,使用最为广泛的操作系统,但是该系统的升级需要用户支付相关费用,如果不升级,又会给系统带来安全性问题。昂贵的升级费用给经费较为紧张的教育部门带来了困难。而CentOS系统恰恰在这二者之间做到了平衡。CentOS是来自于Red Hat Enterprise Linux系统依照开放源代码规定释出的源代码所编译而成。由于出自同样的源代码,因此有些要求高度稳定性的服务器以CentOS替代商业版的Red Hat Enterprise Linux使用。最重要的是CentOS的升级是免费的。本文将探讨采用这一系统来构建Moodle网络教学系统的方法。

1 安装CentOS系统

CentOS系统可以采用光盘安装,硬盘安装,网络安装,U盘安装几种方式。由于现在网络和大容量U盘的普及,本文采用U盘安装。其工作原理是,从U盘启动,通过grub引导CentOS系统安装:

1.1 对U盘格式化

此处的操作的目的是在U盘上创建一个主分区,并将其激活(目的是从U盘启动时能够正确引导),推荐使用工具:DiskGenius分区,主分区至少5G,fat32分区格式,激活为主分区。

1.2 安装grub

使用工具:grubinst-1.1-bin-w32.zip和grub4dos-0.4.4.zip。首先将grubinst-1.1-bin-w32.zip解压,运行grubinst_gui.exe在“磁盘”选项选择U盘,“分区列表”选项选择“整个磁盘(MBR)”将引导代码写入U盘mbr。在“选项”区选中“不保存原来的mbr”、“不引导原来的mbr”、“启动时不搜索软盘”、点击“安装”即可。grubinst将grub4dos启动代码安装到MBR/BS。 然后安装grub4dos:将grub4dos-0.4.4.zip解压,将grldr和menu.lst两个文件复制到主分区。从U盘启动时,计算机将MBR里的grub启动代码装入内存,该代码将grldr装入内存并运行,grub根据menu.lst里的引导配置做相应的引导事项。

1.3 添加linux安装引导

在menu.lst最后添加: title Install CentOS 5.6

root (hd0,0)

kernel /isolinux/vmlinuz text

/* 注意: 为使安装顺利进行,此处参数设置为text,表示以文本模式安装。如果不设置,默认以图形模式安装,系统自动检测显卡,系统如不能正确配置显卡驱动程序,会自动为显示器设置较高刷新率,从而导致在较低刷新率下才能正常工作的液晶显示器产生黑屏现象。*/

initrd /isolinux/initrd.img

title CentOS Linux rescue

root (hd0,0)

kernel /isolinux/vmlinuz linux rescue

initrd /isolinux/initrd.img

1.4 下载安装文件

如CPU支持64位计算,则下载64位版本的CentOS,从CentOS官方网站.cn/qkpdf/dnjl/dnjl201126/dnjl20112640.pdf" style="color:red" target="_blank">原版全文

选择/dev/sda1,也就是U盘的第1个分区存放着8个iso文件,接下来就显示Welcome to CentOS开始读入光盘镜像开始安装,安装目的地选择hda。分区设置:/boot 100MBext3,/boot分区不能位于卷组中,因为引导装载程序无法从逻辑卷中读取。需单独创建。如硬盘总容量320G,其各分区设置如表1。

安装完成后,可能无法启动。此时应该修复CentOS Grub引导,重启计算机后,进入linux rescue 模式,选择安装iso文件在sda1

选择continue,挂载安装文件,注意不要选择read-only模式。出现sh#后,输入chroot /mnt/sysimage ,因为我们安装好的系统被挂载在/mnt/sysimage下面, 输入#cd /boot/grub ,#vigrub.conf按:修改,将里面的(hd1,0)全部改为(hd0,0),保存退出。在命令行中执行 grub-install /dev/hda。修改/boot/grub/menu.lst,将其中的(hd?,?)修改为(hd0,0),保存退出。拨下移动硬盘重启。如果系统不能进入图形界面,则需要安装显卡驱动。方法:先查询到本机显卡驱动型号后,下载显卡驱动至U盘,以root用户登录系统输入,

#mkdir /mnt/flash

#mount -t vfat /dev/sda1/mnt/flash

#cd /mnt/flash

进入显卡驱动所在目录,输入#sh ./NVIDIA-Linux-x86_64-260.19.36.run 安装好后,若需启动CentOS系统图形界面,输入#startx。

2 安装Web服务器所需软件

2.1 安装MySQL数据库

基于二级制代码安装,需要下载mysql-5.5.12-linux2.6-x86_64.tar.gz。在命令行中输入如下命令:

#groupadd mysql

#useradd -r -g mysql mysql

#cd /usr/local

#tar zxvf /path/to/mysql-VERSION-OS.tar.gz

#ln -s full-path-to-mysql-VERSION-OS mysql

#cd mysql

#chown -R mysql .

#chgrp -R mysql .

#scripts/mysql_install_db --user=mysql

#chown -R root .

#chown -R mysql data

#Next command is optional

#cp support-files/my-medium.cnf /etc/my.cnf

#bin/mysqld_safe --user=mysql &

#Next command is optional

#cp support-files/mysql.server /etc/init.d/mysql.server

为MySQL root 用户设置密码,

#./bin/mysqladmin -u root password "new-password"

#./bin/mysqladmin -u root -h localhost password " new-password"

运行#./bin/mysql_secure_installation

删除缺省创建的test数据库和匿名用户的选项,并测试运行mysql,

#service mysqld start

Starting MySQL. [OK]

#mysql -u root -p

#Enter password:

mysql>create database moodle; /*新建数据库moodle*/

mysql>\q

Moodle平台的安装和配置需要在文本模式下新建Moodle数据库存储目录,命令如下:

#mkdir /usr/local/apache/moodledata

#cp moodle.zip /usr/local/apache/htdocs

#cd /usr/local/apache/htdocs

#unzip moodle.zip

#chown -R apache:apache /usr/local/apache/moodledata

2.2 安装OpenSSL

#tar zxvf openssl-1.0.0d.tar.gz

#cd openssl-1.0.0d

#./configure--prefix=/usr/local/ssl/--shared

#make&&make install

以下命令更新系统openssl版本

#mv /usr/bin/openssl /usr/bin/openssl.OFF

#ln -s /usr/local/ssl/bin/openssl/usr/bin/openssl

#ln -s /usr/local/ssl/include/openssl /usr/include/openssl

以下命令配置库文件搜索路径

#echo "/usr/local/ssl/lib">> /etc/ld.so.conf

#/sbin/ldconfig -v

查看版本号,验证是否安装正确

#openssl version –a

2.3 安装Curl

#tar zxvf curl-7.16.2.tar.gz

#./configure--prefix=/usr/local/curl --with-ssl=/usr/local/ssl

#make&&make install

2.4 安装gd库以及相关的软件包

2.4.1 安装zlib-1.2.4

#tar xzvf zlib-1.2.4.tar.gz

#cd zlib-1.2.4

#./configure --shared

#make&&make install

2.4.2 安装 jpeg8

#cd /usr/local/src

#tarzvxf jpegsrc.v8c.tar.gz

#cd jpeg-8c

#./configure --prefix=/usr/local/jpeg8/ --enable-shared --enable-static

#make && make install

2.4.3 安装libpng

#tar zvxf libpng-1.5.2.tar.gz

#cd libpng-1.5.2

#./configure

#make&&make install

2.4.4 安装 freetype

#cd /usr/local/src

#tar zvxffreetype-2.4.4.tar.gz

#cd freetype-2.4.4

#./configure --prefix=/usr/local/freetype/

#mkdirusr/local/freetype/include/freetype2/freetype/internal

#make && make install

2.4.5 安装libxml2-2.7.8.tar

#tar zvxflibxml2-2.7.8.tar.gz

#cd libxml2-2.7.8

#./configure

#make&&make install

#cp xml2-config /usr/bin

2.4.6 安装Fontconfig

#tar zxvf fontconfig-2.4.2.tar.gz

#cd fontconfig-2.4.2

#export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH

#./configure --prefix=/usr/local/fontconfig--with-freetype-config=/usr/local/freetype/bin/freetype-config

#make&&make install

2.4.7 安装libiconv

#tar zxvf libiconv-1.13.1.tar.gz

#cd libiconv-1.13.1

#./configure --prefix=/usr/local/libiconv/

#make&&make install

2.4.8 安装libmcrypt

#tar -zxvf libmcrypt-2.5.8.tar.gz

#cd /usr/local/src/libmcrypt-2.5.8/

#./configure

#make && make install

2.4.9 安装libltdl

#cd libmcrypt-2.5.8/libltdl

#./configure --enable-ltdl-install

#make&&make install

2.4.10 安装 libxslt

#tar -zxf libxslt-1.1.22.tar.gz

#cd libxslt-1.1.22

#mkdir /usr/local/libxslt

#./configure --prefix=/usr/local/libxslt--with-libxml2-dir=/usr/local/lib

#make&&make install

2.4.11 安装GD-2.0.35库

#tar vxjf gd-2.0.35.tar.bz2

#mkdir -p /usr/local/gd

#cd gd-2.0.35

#./configure --prefix=/usr/local/gd--with-jpeg=/usr/local/jpeg8/ --with-png-dir=/usr/local/lib/ --with-zlib --with-freetype=/usr/local/freetype/ --with-libxml-dir=/usr/local/lib/ --with-fontconfig=/usr/local/fontconfig

#make&&make install

#cpgd.h /usr/local/lib

2.5 安装Apache

#tar zxvf httpd-2.2.19.tar.gz

#cd httpd-2.2.19

#./configure --prefix=/usr/local/apache --with-mysql=/usr/local/mysql--with-ssl=/usr/local/ssl--enable-so --enable-rewrite --enable-modules=all --enable-mods-shared=all

#make&&make install

#useradd apache

#chown -R apache.apache /usr/local/apache

在/etc/rc.d/rc.local文件中加入一行

/usr/local/apache/bin/apachectl start 这样每次重新启动系统以后,apache也会随系统一起启动.

#vi /usr/local/apache/conf/httpd.conf

启动Apache中的php选项,找到下面两行

DirectoryIndex index.php #修改默认启动页

DocumentRoot #指定主目录(/usr/local/apache2/htdocs)

ServerName 127.0.0.1:80

2.6 编译php

#tar jxvf php-5.3.6.tar.bz2

#cd php-5.3.6

#./configure --prefix=/usr/local/php/ --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs --with-jpeg-dir=/usr/local/jpeg8/ --with-libxml-dir=/usr/local/libxml2/ --with-zlib --with-gd=/usr/local/gd/ --with-freetype-dir=/usr/local/freetype/ --with-png-dir=/usr/local/lib/ --enable-mbstring --with-iconv=/usr/local/libiconv/ --with-curl=/usr/local/curl/ --with-openssl=/usr/local/ssl/ --enable-tokenizer --with-xmlrpc --enable-ctype --with-mcrypt --with-mhash --with-pdo-mysql --enable-pcntl --enable-soap --with-mysqli=/usr/local/mysql/bin/mysql_config

--with-pdo-mysql=/usr/local/mysql--enable-zip --with-pear --enable-sockets--enable-intl

#make&&make install

#cp php.ini-production /usr/local/php/etc/php.ini

在文件httpd.conf中找到AddType application/x-gzip.gz.tgz所在行,在其下添加以下内容:

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

即可,(注意#Listen 127.0.0.1:80前面的#号不能去掉,User 后改为apache Group后改为 apache, ServerName 改为127.0.0.1:80, DirectoryIndex 后添加index.php,)然后重启apache服务

#/usr/local/apache/bin/apachectl restart

3 测试服务器

在/usr/local/apache/htdocs/目录里新建一个PHP文件phpinfo.php,在其中添加以下代码:,然后在客户端的浏览器访问https://服务器IP地址或域名/phpinfo.php。如果看到PHP的信息页面,则表示PHP运行环境配置成功。

4 结论

如今网络安全问题频现,要构建一个功能完善且健壮性强的Moodle教学系统,后续研究还包括许多工作,如安装openssh安全的远程登录服务器以便于远程维护网站,对MySQL数据库进行安全性设置,安装linux系统下的杀毒软件clamAV,为Apache安装防DDOS的模块mod_evasive等等。

参考文献:

[1] Installing Moodle-MoodleDocs[EB/OL].https://docs.moodle.org/20/en/Installing_Moodle.

[2] 梁如军.CENTOS 5系统管理[M].北京;电子工业出版社,2008.

[3] 张勤,杨章明.Linux服务器配置全程实录[M].北京:人民邮电出版社,2010:20-228.

[4] 杨明华.Linux系统与网络服务管理技术大全[M].北京:电子工业出版社,2008.

[5] SANDRA K.JOHNSON.Linux服务器性能调整[M].北京:清华大学出版社,2009.

[6] Mohan Krishnamurthy Madwachar.Linux网络安全实践[M].北京:科学出版社,2009.

[7] 冷罡华.UBUNTU SERVER最佳方案[M].北京:电子工业出版社,2009:76.

[8] 何世晓,田钧.Linux系统管理员[M].北京:机械工业出版社,2007.

推荐访问:构建 教学 系统 网络 CentOS