+ -
当前位置:首页 → 问答吧 → 使用开源协议软件搭建即时通讯服务器

使用开源协议软件搭建即时通讯服务器

时间:2008-09-19

来源:互联网

作者:liheng
Email:liheng_2006 at hotmail.com

Jabber 是著名的即时通讯服务服务器,它是一个自由开源软件,能让用户自己架即时通讯服务器,可以在Internet上应用,也可以在局域网中应用。
XMPP(可扩展消息处理现场协议)是基于可扩展标记语言(XML)的协议,它用于即时消息(IM)以及在线现场探测。它在促进服务器之间的准即时操作。这个协议可能最终允许因特网用户向因特网上的其他任何人发送即时消息,即使其操作系统和浏览器不同。XMPP的技术来自于Jabber,其实它是 Jabber的核心协定,所以XMPP有时被误称为Jabber协议。Jabber是一个基于XMPP协议的IM应用,除Jabber之外,XMPP还支持很多应用。
关于 Jabber 的详细内容,大家可以上 Jabber 的官方网页:www.jabber.org 查看。
Opernfire 是一个在开源 GPL 和商业双许可的即时通讯服务器。Openfire 的即时通讯服务采用了广泛采用的开放协议---XMPP。Openfire 非常容易安装与管理,同时 Openfire也提供了非常高的安全性与性能。Openfire 支持WINDOWS、LINUX、MAC平台。目前最新的版本是:Openfire-3.5.2。在本例中我使用的是 Linux 版本。关于 Openfire 的详细内容,大家可以上 Openfire 的官方网页:http://www.igniterealtime.org/projects/openfire/index.jsp
Spark 是一款开源的、多平台的即时通讯客户端。它提供了嵌入式聊天室、集成电话、高安全性支持。还为用户提供了非常好的体验功能,如在线拼写校验,聊天室标签、交谈记录等。Spark 支持 Windows、Linux、MAC 平台,目前最新的版本是:Spark-2.5.8。关于 Spark 的详细内容,大家可以上 Spark 的官方网页:http://www.igniterealtime.org/projects/spark/index.jsp
安装
下面我就来向大家介绍一下如何配置 Openfire 来构建企业内的即时通讯服务器。首先我还是向大家介绍一下我的环境:
Openfire 服务器OS:RedHat Enterprist Linux 5.0
Openfire 版本:Openfire
MYSQL 版本:mysql-5.1.52a
Spark 版本:Spark-2.5.8
Apache 版本:http-2.2.6
Java 版本:jre1.6

由于Openfire 是使用 Java 开发的,需要Java环境支持,请确保你的系统中已经安装了 JRE。建议使用最新的JRE 版本: jre1.6。可以到 java的官方站点:www.java.com 上下载。
配置JAVA 环境
[root @test ~] # cp jre-6u6-linux-i586.bin /usr/local
[root @test ~] # cd /usr/local
[root @test local] # ls –l | grep jre
-rwxr--r-- 1 root root 19750740 6月 28 11:14 jre-6u6-linux-i586.bin
[root @test local] # ./jre-6u6-linux-i586.bin
此时将显示二进制许可协议。通读许可协议。按空格键显示下一页。读完许可协议后,输入 yes 继续安装。
JRE 安装在其自身的目录中。在本例中,它将安装在 /usr/local/jre1.6.0_6 目录中。当安装完成时,您将看到 Done(完成)字样。
[root @test local] # ln –s /usr/local/jre1.6.0_6/plugins/i386/ns7/libjavaplugin_oji.so /usr/lib/firefox-1.0.4/plugins/
安装mysql。在本例中我要使用 mysql 来作为 Openfire服务器使用的数据库,但这并不是必须的,因为 Openfire 本身内置有数据库,你可以选择使用 Openfire 内置的数据库,也可以使用外置数据数据库。
[root @test local] # tar xzvf /root/mysql-5.0.51a-linux-i686.tar.gz
[root @test local] # ln –s mysql-5.0.51a-linux-i686 mysql
[root @test local] # cd mysql
[root @test mysql] # mv /etc/my.cnf /etc/my.cnf.bak
[root @test mysql] # cp support-files/my-medium.cnf /etc/my.cnf

[root @test mysql] # chown –R mysql .
[root @test mysql] # chgrp –R mysql .
[root @test mysql] # ./scripts/mysql_install_db --user=mysql &
[root @test mysql] #chown –R root .
[root @test mysql] # chown –R mysql data
[root @test mysql] #./bin/mysqld_safe --user=mysql &
[root @test mysql] # netstat –tlunp | grep 3306
[root @test mysql] # cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root @test mysql] # chmod 755 /etc/init.d/mysqld
[root @test mysql] # chkconfig —add mysqld
[root @test mysql] # chkconfig —level 35 mysqld on
[root @test mysql] # mkdir /usr/local/mysql/lib/mysql
[root @test mysql] # mkdir /usr/local/mysql/include/mysql
[root @test mysql] # chown root.mysql /usr/local/mysql/lib/mysql
[root @test mysql] # chwon root.mysql /usr/local/mysql/include/mysql
[root @test mysql] # ln –s /usr/local/mysql/lib/* /usr/local/mysql/lib/mysql
[root @test mysql] ## ln –s /usr/local/mysql/include/* /usr/local/mysql/include/mysql
[root @test mysql] # echo “/usr/local/mysql/lib/mysql” >> /etc/ld.so.conf
[root @test mysql] # ldconfig
安装apache
[root @test mysql] # cd ..
[root @test local] # tar xzvf /root/httpd-2.2.6.tar.gz
[root @test mysql] # cd httpd-2.2.6
[root @test httpd-2.2.6] # ./configure –prefix=/usr/local/apache --enable-so --enable-rewrite
[root @test httpd-2.2.6] # make
[root @test httpd-2.2.6] # make install
[root @test httpd-2.2.6] # echo “/usr/local/apache/bin/apachectl start” >> /etc/rc.local

安装php-5.2.3
[root @test httpd-2.2.6] # cd ..
[root @ test local] # tar -zvxf /root/php-5.2.6.tar.gz
[root @ test local] # mkdir -p /usr/local/php
[root @ test local] # cd php-5.2.6
[root @ test php-5.2.6] # ./configure —prefix=/usr/local/php
—with-apxs2=/usr/local/apache/bin/apxs —with-mysql=/usr/local/mysql
—with-mysqli=/usr/local/mysql/bin/mysql_config —with-xml —with-png
—with-jpeg —with-zlib —with-freetype —with-gd —enable-track-vars —enable-mbstring=all
[root @ test php-5.2.6] # make
[root @ test php-5.2.6] # make install
[root @ test php-5.2.6] # cp php.ini-dist /usr/local/php/lib/php.ini

注:编辑apache配置文件httpd.conf,以apache支持php
[root @ test php-5.2.6] # vi /usr/local/apache/conf/httpd.conf
# 添加如下二行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

# 定位至DirectoryIndex index.html
修改为:
DirectoryIndex index.php index.html

# 这里将网站根目录指定到/var/www:
找到DocumentRoot “/usr/local/apache/htdocs”
修改为:DocumentRoot “/var/www”
找到
修改为:
在 mysql 中建立数据库 openfire
[root @ test php-5.2.6] # /usr/local/mysql/bin/mysql
mysql > CREATE DATABASE openfire;
mysql > exit;
将 Openfire 的数据库资料导入 mysql
[root @ test php-5.2.6] # cat /usr/local/openfire/resource/database/openfire_mysql.sql | /usr/local/mysql/bin/mysql openfire
出于安全考虑,为mysql 用户 root 设置密码
[root @ test php-5.2.6] # /usr/local/mysql/bin/mysqladmin –u root password 123456
[root @ test php-5.2.6] # /usr/local/openfire/bin/openfire start
查看 openfire 控制台端口9090 &9091是否已经打开
[root @ test php-5.2.6] # netstat –tlunp



=700) window.open('http://linux.chinaunix.net/bbs/attachments/month_0807/20080706_30d29ffdb71a6aa5fcba7zN9vFqbunmg.jpg');" onload="if(this.offsetWidth>'700')this.width='700';if(this.offsetHeight>'700')this.height='700';" >

作者: 6317131a   发布时间: 2008-09-19

打开 Firefox 浏览器,在地址栏里输入:http://127.0.0.1:9090 进入 openfire Tool 页面,开始安装设置 openfire,在你开始设置之前,首先选择适合于你的语言,这里我们当然选择“中文(简体)Simlified Chinese(zh_CN)”。


=700) window.open('http://linux.chinaunix.net/bbs/attachments/month_0807/20080706_460ce59e6608861ed665ZKDqV6RyadmH.jpg');" onload="if(this.offsetWidth>'700')this.width='700';if(this.offsetHeight>'700')this.height='700';" >

作者: besthome   发布时间: 2008-09-19

点击“continue”,开始一步设置---服务器设置,这里保持默认即可



=700) window.open('http://linux.chinaunix.net/bbs/attachments/month_0807/20080721_e20e6f3c299494214d3brbEiQnJZ0xFv.jpg');" onload="if(this.offsetWidth>'700')this.width='700';if(this.offsetHeight>'700')this.height='700';" >

作者: 织羽   发布时间: 2008-09-19

点击“继续”,开始下一步设置----数据库设置,如果你使用一个外部数据库的话,就选择“标准数据库连接”,若使用 openfire 自带的数据库的话,就选择“嵌入的数据库”。在本例中因为我使用的数据库是 mysql ,所以选择“标准数据库连接”



=700) window.open('http://linux.chinaunix.net/bbs/attachments/month_0807/20080721_bcc8d46ac101b99833d90X9IYM9VMJzt.jpg');" onload="if(this.offsetWidth>'700')this.width='700';if(this.offsetHeight>'700')this.height='700';" >

作者: ing1024   发布时间: 2008-09-19

点击“继续”,开始下一步设置



=700) window.open('http://linux.chinaunix.net/bbs/attachments/month_0807/20080721_9738e8f0c74b8e465f16PJI4odVSwGI5.jpg');" onload="if(this.offsetWidth>'700')this.width='700';if(this.offsetHeight>'700')this.height='700';" >

作者: 17772   发布时间: 2008-09-19

数据库驱动选项: 选择使用数据库的类型,有 mysql、mssql、oracel 等供选择,本例中选择 mysql。
JDBC驱动程序类: 此处保持默认即可。
数据库URL: jdbc:mysql://[local_host]:3306/[database_name],将 [local_host] 改成mysql 服务器的IP地址,这里我是在本机操作,所以[local_host]q我设置成:127.0.0.1。[database_name]改成刚刚创建的 openfire 的数据库 openfire.
用户名: 输入可以登录 mysql 服务器的用户名,这里我输入mysql 服务器默认的管理员 root
密码: 输入mysql 服务器管理员root 的密码;
Minimum Connecti****: 设置连接 openfire 服务器的最小连接
Maximum Connexti****: 设置连接 openfire 服务器的最大连接
连接超时: 设置连接 openfire 服务器的连接超时的时间
点击“继续”按钮,开始下一点设置




=700) window.open('http://linux.chinaunix.net/bbs/attachments/month_0807/20080721_a78d4d2b2e6a15e166fepuJQYtZkPjag.jpg');" onload="if(this.offsetWidth>'700')this.width='700';if(this.offsetHeight>'700')this.height='700';" >

作者: 翅膀   发布时间: 2008-09-19

因为此例中,并没有使用 LDAP 服务器,只要选择“初使设置”即可。点击“继续”,开始下一步设置



=700) window.open('http://linux.chinaunix.net/bbs/attachments/month_0807/20080721_3202d7acb3f114c18f1bCAOj93v0hO53.jpg');" onload="if(this.offsetWidth>'700')this.width='700';if(this.offsetHeight>'700')this.height='700';" >

作者: 奇跡の海   发布时间: 2008-09-19

设置登录 openfire 管理控制台管理员帐户 admin 的密码,如果在这里没有设置,单击“跳过这一步”的话,默认密码是 admin 。管理员电子邮件地址可以保持默认,也可以根据自身的情况设置,没有多大影响。点击“继续”,开始下一步设置



=700) window.open('http://linux.chinaunix.net/bbs/attachments/month_0807/20080721_6aeecf08f9fb217abe31OnDVcrn1l7Zd.jpg');" onload="if(this.offsetWidth>'700')this.width='700';if(this.offsetHeight>'700')this.height='700';" >

作者: dorgel   发布时间: 2008-09-19