jabberd服务器安装过程。(gentoo下实现)
最近jabberd2.0.9放出,于是试着安装了一下。1、安装软件包:
emerge --sync
emerge openssl libidn mysql jabberd
就050824日,以上程序相对应的版本是0.9.7g、0.5.18、4.0.25-r2、2.0.9。emerge jabberd后就自动建立了jabber用户和组,无须自己添加。
2、创建jabberd的mysql数据库。
/usr/bin/mysql_install_db
3、启动mysql
/etc/init.d/mysql start
4、设定mysql密码
/usr/bin/mysqladmin -u root password 'YourPassword'
5、将mysql加入启动项
rc-update add mysql default
6、创建jabber用户及认证库
cp /usr/share/doc/jabberd-2.0.9/tools/db-setup.mysql.gz /tmp
cd /tmp
gunzip db-setup.mysql.gz
mysql -u root -p
mysql>\. db-setup.mysql
7、为jabber的mysql用户设定密码
GRANT select,insert,delete,update ON jabberd2.* to jabberd2@localhost IDENTIFIED by 'YourPassword';
quit
8、jabberd配置
cd /etc/jabberd/
nano -w sm.xml
修改类似下面
<id>your ip address</id> 《--------改动处
<pidfile>/var/jabberd/pid/sm.pid</pidfile> 《--------改动处
<!-- Router connection configuration -->
<router>
<!-- IP/port the router is waiting for connections on -->
<ip>your ip address/ip> <!-- default: 127.0.0.1 --> 《--------改动处
<port>5347</port> <!-- default: 5347 -->
<!-- Log configuration - type is "syslog", "file" or "stdout" -->
<log type='file'> 《--------改动处,将syslog改为file
<!-- If logging to syslog, this is the log ident -->
<ident>jabberd/sm</ident>
<!-- If logging to syslog, this is the log facility
(local0 - local7) -->
<facility>local3</facility>
<!-- If logging to file, this is the filename of the logfile -->
去掉此行的注释
<file>/var/jabberd/log/sm.log</file>
去掉此行的注释
</log>
<!-- MySQL driver configuration -->
<mysql>
<!-- Database server host and port -->
<host>localhost</host>
<port>3306</port>
<!-- Database name -->
<dbname>jabberd2</dbname>
<!-- Database username and password -->
<user>jabberd2</user>
<pass>your jabberd2's password</pass> 《--------改动处
ctrl+x保存退出。
nano -w router.xml
改动如下:
<!-- The process ID file. comment this out if you don't need to know
to know the process ID from outside the process (eg for control
scripts) -->
<pidfile>/var/jabberd/pid/router.pid</pidfile> 《--------改动处
<!-- Log configuration - type is "syslog", "file" or "stdout" -->
<log type='file'> 《--------改动处
<!-- If logging to syslog, this is the log ident -->
<ident>jabberd/router</ident>
<!-- If logging to syslog, this is the log facility
(local0 - local7) -->
<facility>local3</facility>
<!-- If logging to file, this is the filename of the logfile -->
去掉此行的注释
<file>/var/jabberd/log/router.log</file>
去掉此行的注释
</log>
保存。
nano -w c2s.xml
改动如下:
<pidfile>/var/jabberd/pid/c2s.pid</pidfile> 《--------改动处
<!-- Router connection configuration -->
<router>
<!-- IP/port the router is waiting for connections on -->
<ip>your ip address</ip> <!-- default: 127.0.0.1 --> 《--------改动处
<port>5347</port> <!-- default: 5347 -->
<!-- Log configuration - type is "syslog", "file" or "stdout" -->
<log type='file'> 《--------改动处
<!-- If logging to syslog, this is the log ident -->
<ident>jabberd/c2s</ident>
<!-- If logging to syslog, this is the log facility
(local0 - local7) -->
<facility>local3</facility>
<!-- If logging to file, this is the filename of the logfile -->
去掉此行的注释
<file>/var/jabberd/log/c2s.log</file>
去掉此行的注释
<id>your ip address</id> 《--------改动处
保存退出。
s2s.xml and resolver.xml修改过程参照上面的。
9、备份jabber文件,创建新的jabber文件。
mv /etc/init.d/jabber /root/backup/jabber.YYDDMM
在/etc/init.d目录中建一个空文件jabber,改权限为:755,用户和属组为:root:root。并将下面的内容粘贴上:
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-im/jabberd/files/jabber.init.gentoo,v 1.1 2005/01/31 23:05:41 humpback Exp $
depend() {
need net
use mysql postgresql slapd
provide jabber-server
}
components="router resolver sm c2s s2s"
my_start() {
local component="$1"
ebegin "-> Starting ${component}"
start-stop-daemon --start --chuid jabber:jabber --background \
--exec "/usr/bin/${component}"
eend $?
}
my_stop() {
local component="$1"
ebegin "-> Stopping ${component}"
pidfile="/var/jabberd/pid/${component}.pid"
start-stop-daemon --stop --exec "/usr/bin/${component}" \
--pidfile "${pidfile}"
eend $?
}
start() {
ebegin "Starting Jabber Server"
local started=''
local failed=''
for i in ${components}; do
if ! my_start "${i}"; then
failed="${failed} ${i}"
else
started="${started} ${i}"
fi
done
if [[ -n ${failed} ]]; then
eerror
eerror "The following components failed to start:"
eerror "->${failed}"
eerror
eerror "Trying to stop started components"
for i in ${started}; do
my_stop "${i}"
done
false
fi
eend $?
}
stop() {
ebegin "Stopping Jabber Server"
local failed="" i=""
for i in ${components}; do
if ! my_stop "${i}"; then
failed="${failed}${i}"
fi
done
if [[ -n ${failed} ]]; then
eerror
eerror "The following components failed to stop:"
eerror "->${failed}"
eerror
eerror "Please kill the processes manually and reset"
eerror "this service to a stopped state using"
eerror "-> ${0} zap"
eerror
false
fi
eend $?
}
保存。(附件为jabber文件)
10、添加jabber为开机运行
rc-update add jabber default
11、运行jabberd
/etc/init.d/jabber start
* Starting Jabber Server ...
* -> Starting router ... [ ok ]
* -> Starting resolver ... [ ok ]
* -> Starting sm ... [ ok ]
* -> Starting c2s ... [ ok ]
* -> Starting s2s ... [ ok ] 12、运行gaim,注册并使用jabber,如图。
图1, 注册。
图2, 添加帐户。
图3,交谈。
图4,jabber用户认证信息。
页:
[1]