[论坛 配置] 教你用phpBB2配置一个安全的Linux论坛
时间:2005-08-17
来源:互联网
台上工作。PhpBB2这个论坛软件程序安装非常简单,而且不断有升级版本出现。全球网络上大概有600万个使用phpBB2的站点。PhpBB2 最大的优点是可以进行外挂模块的开发,以建立个人的网页风格。PhpBB2功能强大包含系统信息也比较多,所以,您必须要了解到这个软件有可能会产生一些安全上的漏洞的。
一、搭建phpBB2论坛
1、phpBB2 论坛搭建的必需软硬件:
除了要搭建一个基于LAMP的网络构架、还要有运行phpBB2的软件必需的PHP-MYSQL模块和php-odbc模块,可以使用命令检测:
#rpm –qa|grep php-mysql;rpm –qa|grep php-odbc
系统要求:
软件:它要求内核(Kenerl)至少在2.2以上。KDE 2.0,桌面颜色至少16位增强色。
硬件:中央处理器:奔腾II 450 以上 ,内存 128 兆 ,硬盘空间 600兆 。
2.phpbb2软件和汉化包下载:
#wegt http://www.phpbb.com/files/releases/phpBB-2.0.14.tar.bz2
#wegt http://jaist.dl.sourceforge.net/sourceforge/phpbb/lang_chinese_simplified.tar.gz
#wegt http://jaist.dl.sourceforge.net/sourceforge/phpbb/subSilver_chinese_simplified.tar.gz
3. 软件安装: 将下载的软件拷贝到/tmp目录下,执行:
#tar –zxvf phpBB-2.0.14.tar.gz “建立一个目录:/tmp/phpBB2”
#cd phpBB2/language/
#tar –zxvf root/lang_chinese_simplified..tar.gz
#cd /root/phpBB2/templates
#tar –zxvf /root/subSilver_chinese_simplified.tar.gz
两个中文汉化包要分别拷贝到:phpBB2/language/ 和 /phpBB2/templates
目录下然后解压,注意不要放错位置,否则的程序会出现乱码。
4.为phpbb2建立数据库:
# mysql –u root –p
Enter password: xxxxxxxxx
Your Mysql connection id is 3 to server version: 4.11
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
Mysql>; create database phpbb2; “为phpbb2建立数据库”
Query OK, 1 row affected (0.01 sec)
Mysql>;grant all privileges on phpbb2.* to phpbbuser@localhost identified by ‘76543981’ ; “将建立的 phpbb2权限给phpbbuser 帐号,并且设定密码”
mysql>;quit
Bye
5. 测试刚建立的数据库与帐号是否可以使用:
# mysql –u phpbbuser –p
Enter password: xxxxxxxxx
Your Mysql connection id is 3 to server version: 4.11
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
Mysql>; connect phpbb2;
Connection id: 5
Current database: phpbb2
mysql>;quit
Bye
6.开始安装phpbb2:
安装前需要说明的是:Mysql服务器名称为 localhost ,这个是 Mysql 的服务器名称,不是 Linux服务器名称。通常 Mysql 的服务器名称是: localhost 。Mysql 数据库名称为 phpbb2 ,Mysql 帐号为 phpbbuser 且密码为上面设定值。
#cd /tmp/phpBB2
# chmod 666 config.php “让config.php脚本可执行”
# mv phpBB2 /var/www/html/phpbb2 “移动文件phpBB2目录到apache确省目录中”
进行网络安装,phpBB2 的安裝非常简单,打开Linux的浏览器在地址栏直接输入:http://主机名/phpbb2 后会出现对话框让你填写一些系统信息见图-1。
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open(this.src);}" onmousewheel="return imgzoom(this);" alt="" />
填写系统信息
填写内容
说明
Basic Configuration
基本设定
Default broad language
chinese[simplified]
语言设定
Database Type
mysql4.x
数据库类型和版本
Choose Your installation mothod
install
安装方式(升级或全新安装)
Database Configuration
数据库设定
Database Server Hostname
localhost
数据库主机名称
Your Database Name
phpbb2
数据库名称
Database User
phpbbuser
数据库用户帐号
Database Password
XXXXXXXXXXX
数据库用户帐号数据库密码
Prefix for table in database
phpbb_
数据库表格字首
Admin Configuration
系统管理员设定
Admin mail address
[email protected]
系统管理员电子邮件
Domain name
192.168.1.3
网络名称或IP地址
Server port
80
Apache服务器管理端口
Script path
/phpbb2/
脚本存放路径
Administrator Username
cao
数据库管理员帐号
Administrator Password
xxxxxxxx
数据库管理员密码
Administrator Password(Cofirm)
xxxxxxxx
数据库管理员密码确认
填写结束后按“开始安装 ”按钮进行安装,系统如果出现图-2表示安装成功,如果有错误会自动退回到图-1的对话框让你从新设定。
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open(this.src);}" onmousewheel="return imgzoom(this);" alt="" />
3、安全设定
测试成功后系统提醒你出于安全考虑,删除安装文件(防止他人使用这些文件修改系统信息),
#chmod 644 config.php
# rm –rf install
# rm –rf contrib
4、再次登录系统,由于删除了config.php 文件,所以只能以系统管理员的身份登录,登录后对话框下边会出现“论坛管理员控制面板”(这个选项对于普通帐户是隱藏的)点击即可进入(见图-3)。
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open(this.src);}" onmousewheel="return imgzoom(this);" alt="" />
phpBB2 的论坛管理员控制面板,一共六个大版面:系统管理、版面管理、普通管理、团队管理、风格管理、会员管理。在系统管理版面里包含您论坛的各项统计资料. 任何时候您都可以通过点击控制面板左上方的控制面板首页返回到这一页. 而点击在控制面板左上方的 phpBB 标志图示可以回到您的论坛首页.在这个画面左方的其他链接,允许您控制论坛的所有管理选项.每个版面里有各项功能的使用详解。另外在论坛的首页的“FAQ”中有200页的常见问题回答。这样你也可以自己轻松搭建论坛了。
5. 为phpBB2论坛加速
如果您曾经浏览phpBB2论坛的网页,如果发现PHP 的速度较慢,这是由于 PHP 的程序代码去调用了太多的函式库,而这些函式库每次调用都需要由硬盘读出来,有没有办法提升 PHP 的执行速度啊。如果我们可以将这些在硬盘里面的函式库先读到高速缓存中( Cache ),由于内存的速度可比硬盘快多了。如此一来的话,当然可以提升不少速度。这里我们介绍一款授权在 GPL 上面的可以对 PHP 程序代码进行快取并且予以优化的软件,那就是 MM Cache官方网站在:http://www.turcksoft.com/ 。目前 MM Cache 最新版本:2.4.6 。
1、软件下载和安装
wegt http://jaist.dl.sourceforge.net/sourceforge/turck-mmcache/turck-mmcache-2.4.6.tar.gz
cd /usr/local
tar -xvf turck-mmcache-2.4.6.tar
cd turck-mmcache-2.4.6
export PHP_PREFIX=”/usr”
$PHP_PREFIX/bin/phpize
./configure--enable-mmcache=shared --with-php-config=$PHP_PREFIX/bin/php-config
make;make install
修改/usr/local/lib/php.ini 文件,加入以下内容:
extension=”mmcache.so”
mmcache.shm_size=”16”
mmcache.cache_dir=”/tmp/mmcache”
mmcache.enable=”1”
mmcache.optimizer=”1”
mmcache.check_mtime=”1”
mmcache.debug=”0”
mmcache.filter=””
mmcache.shm_max=”0”
mmcache.shm_ttl=”0”
mmcache.shm_prune_period=”0”
mmcache.shm_only=”0”
mmcache.compress=”1”
然后建立快存取数据目录:
#mkdir /tmp/mmcache
#chmod 0777 /tmp/mmcache
从新启动Apache服务器:
#/usr/local/httpd/bin/apachectl start
安装MM Cache后网页速度明显加快了,具体数据可以查看:http://sourceforge.net/projects/turck-mmcache/ 对比报告。
作者: ioly 发布时间: 2005-08-17
1. php
BB2.0.11安全漏洞分析和清除方法:
phpBB2是一个用php脚本语言编写的论坛,该论坛的低于2.0.11版本有个严重的漏洞,就是 viewtopic.php允许远程执行命令。viewtopic.php是phpBB2论坛脚本文件中的一个,用于查看帖子内容。通过该漏洞攻击者可以在服务上运行任何代码。Net-Worm.Perl.Santy.a是一个使用perl脚本代码编写蠕虫病毒,通过该phpBB2漏洞远程执行系统命令入侵主机,一旦入侵成功并获得运行,就开始向google发送请求,搜索可以入侵的主机。 如果你使用phpBB2版本低于2.0.11,那么需要清除该蠕虫病毒。
(1)清除病毒步骤:
打开viewtopic.php文件,在以下代码前加入一行:$topic_id = $post_id = false;
if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) )
{
$topic_id = intval($HTTP_GET_VARS[POST_TOPIC_URL]);
}
else if ( isset($HTTP_GET_VARS['topic']) )
{
$topic_id = intval($HTTP_GET_VARS['topic']);
}
另外还要将viewtopic.php文件中以下代码:
$join_sql_table = ( !isset($post_id) ) ? '' : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 ";
$join_sql = ( !isset($post_id) ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id";
$count_sql = ( !isset($post_id) ) ? '' : ", COUNT(p2.post_id) AS prev_posts";
$order_sql = ( !isset($post_id) ) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC";
替换为:
$join_sql_table = ( empty($post_id) ) ? '' : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 ";
$join_sql = ( empty($post_id) ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id";
$count_sql = ( empty($post_id) ) ? '' : ", COUNT(p2.post_id) AS prev_posts";
$order_sql = ( empty($post_id) ) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC";
然后点击“开始”-“搜索”-“文件或文件夹”在文件名称中输入“m1h020f”,找到后全部删除即可。截至到目前为止,该蠕虫还没有更新的变种。已经得到了很到的控制。
2. phpBB2.0.12安全漏洞分析和解决除方法:
phpBB 2.0.12版本中存在两个安全漏洞,其中一个很严重,允许任意用户都可以获取管理权限,另外一个漏洞会导致服务器路径泄露。第一个漏洞存在于includes/sessions.php文件中,其对$sessiondata['autologinid']变量的类型及比较操作存在问题,远程攻击者可以通过伪造特别的变量值使用判断用户合法性的操作始终返回真,从而使用任意用户可以在不知道口令的情况下以管理员的身份认证成功。第二个漏洞在于viewtopic.php文件中,由于对消息的过滤不充分,使路径泄露成为可能。远程攻击者可以利用这个漏洞获取管理权限。解决方法,升级版本到2.0.14。
步骤:
1.数据库的备份:
phpBB2本身可以备份自己的数据,点击phpBB2 的论坛管理员控制面板“普通管理”-》“数据库工具管理:备份”-》“选择整体备份选项”,即可完成论坛数据的整体备份,见图-4.
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open(this.src);}" onmousewheel="return imgzoom(this);" alt="" />
图-4 phpBB2论坛的数据备份
备份产生的文件是:phpbb_db_backup.sql,可以看出是一个sql文件。
2. 使用网络备份mysql数据:
phpBB2本身不能进行网络备份,这时可以使用Mysql数据的导出和导入工具:mysqldump。
(1)本地备份:
使用 mysqldump进行备份非常简单,如果要备份数据库” phpbb_db_backup ”,使用命令:
#mysqldump –u -p phpbb_db_backup >; /usr/backups/mysql/ phpbb_db_backup.2005.5.6
还可以使用gzip命令对备份文件进行压缩:
#mysqldump phpbb_db_backup | gzip >; /usr/backups/mysql/ phpbb_db_backup.2005.5.6。gz
恢复数据使用命令:
#mysql –u -p phpbb_db_backup </usr/backups/mysql/phpbb_db_backup.2005-5-6
(2)网络备份
将MYSQL数据放在一台计算机上是不安全的,所以应当把数据备份到局域网中其他计算机中。假设Mysql服务器IP地址是:192.168.1.3。局域网使用Linux的远程计算机IP地址是192.168.1.17;局域网使用Windows的远程计算机IP地址是192.168.1.18。
把MYSQL数据备份到使用Linux的远程计算机需要在两端都安装NFS协议(Network File System),远程NFS计算机安装NFS协议后还要修改配置文件:/etc/exports,加入一行:
/usr/backups/mysql/ 192.168.1.17 (rw, no_root_squash)
表示将/usr/backups/mysql/目录共享。这个目录具有远程root用户读写权限。保存NFS配置文件,然后使用命令:
#exportfs -a –r
然后重新启动NFS服务:
#service nfsd start
远程计算机设定后,在MYSQL服务器/mnt 目录下建立一个backup_share目录:
#mkdir /mnt/backup_share
将远程的Linux计算机的/usr/backups/mysql/目录挂载到MYSQL服务器的/mnt/backup_share目录下:
# mount -t nfs 192.168.1.17:/usr/backups/mysql /mnt/backup_share
将目录挂载进来后,只要进入/mnt/backup_share 目录,就等于到了IP地址:192.168.1.7那部NFS 计算机的/usr/backups/mysql 目录中。下面使用mysqldump把“phpbb_db_backup”备份到远程计算机:
# mysqldump phpbb_db_backup >; /mnt/backup_share/ phpbb_db_backup.2005-5-6
把MYSQL数据备份到使用Windows的远程计算机需要在Linux端安装Samab协议。然后Windows计算机上建立一个目录(/arc)并且共享,赋予其读写权限。同样在MYSQL服务器/mnt 目录下建立一个backup_share1目录,然后进行挂载:
# mount -t smbfs -o username=cjh, password=XXXX //192.168.1.18/arc /mnt/backup_share
最后使用命令进行备份:
# mysqldump phpbb_db_backup >; /mnt/backup_share/ phpbb_db_backup.2005-5-6
3. 升级最新phpBB2论坛版本步骤:
下载最新版本phpBB-2.0.14解压到一个临时目录,先备份原数据,然后将原来的 config.php 文件覆盖临时目录下的 config.php ,删除原phpBB2安装目录,把最新版本phpBB2移动到/var/www/html/目录下:
# mv phpBB2 /var/www/html/phpbb2
然后在浏览器中输入:http://localhost/phpbb2/install/update_to_2014.php 升级自动进行,系统如果出现图-5表示升级成功:
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open(this.src);}" onmousewheel="return imgzoom(this);" alt="" />
图-5 phpBB2 版本升级界面
升级结束后同样要删除安装文件(防止他人使用这些文件修改系统信息),
#chmod 644 config.php
# rm -rf install
# rm -rf contrib
然后进行数据恢复,点击phpBB2 的论坛管理员控制面板“普通管理”-》“数据库工具管理:恢复”,即可恢复到论坛数据备份时的状况。
2.其他安全措施
1.管理员权限
phpBB2 的系统管理员具有最大的权限,而该权限可能会与其它的板主权限相冲突而造成不可预期的错误,所以最好不要让系统管理员当版主。另外用root权限运行MYSQL也不太安全,这里推荐使用其他用户运行MYSQL。方法是:
# mysql -u root -p
Enter passwordxxxxxxxx
………
mysql>;update user set user="cao" where user="root";
mysql>; flush privileges;
mysql>;quit
Bye
以后就得通过cao帐号访问mysql数据库了。
2.php配置文件的安全设定:
phpinfo和get_cfg_var函数主要用于调试程序是否正常,当LAMP安装结束后应当禁止其使用,编辑php.ini文件加入一行:〕
disable_functions = phpinfo,get_cfg_var
这样可以避免泄漏系统服务信息。关于php和Apache其他安全措施可以查看笔者的:教您如何应用PHP开发出安全的应用程序,链接:http://tech.ccidnet.com/pub/article/c1113_a239881_p1.html
phpBB2功能强大包含系统信息也比较多,所以,您必须要了解到这个软件有可能会产生一些安全上的漏洞的。建议您随时注意 phpBB2 官方网站安全频道:http://www.phpbb.com/security/这里不定期的会有一些安全技术公告,可以帮助您的 phpBB2论坛使用更加安全。
参考文献:http://www.phpbb.com/phpBB/viewtopic.php?t=112052
http://software.newsforge.com/article.pl?sid=04/12/23/2320205
作者: ioly 发布时间: 2005-08-17
作者: ioly 发布时间: 2005-08-17
作者: yzhkp 发布时间: 2005-08-17
作者:曹江华
怎么成了你写的,链接:http://www.ccw.com.cn/server/yyjq/htm2005/20050802_09K19.htm
作者: goodcjh2005 发布时间: 2005-08-18
作者: ak472000 发布时间: 2005-08-18
作者: ioly 发布时间: 2005-08-18
作者: ioly 发布时间: 2005-08-18
作者: ak472000 发布时间: 2005-08-18
作者: Kenbaby 发布时间: 2005-08-23
作者: linuxunix1 发布时间: 2005-08-23
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28