XMPP/jabberd14服务安装与测试

来源:互联网 发布:js手动触发resize事件 编辑:程序博客网 时间:2024/06/06 09:34

安装

$tar zxf jabberd14-1.6.1.1.tar.gz

$ cdjabberd14-1.6.1.1

$./configure

checking for socket... no

checking for socket in -lsocket... no

configure: error: Couldn't find required functionsocket

 $sudo yum groupinstall “Development Tools”

 

$./configure

checking for syslog... yes

checking for libpopt...configure: error: no 

$ sudo yuminstall popt-devel

 

$ ./configure

checking for GNUTLS... no

No package 'gnutls' found

configure: error:Couldn't find required GnuTLS installation

 $ sudo yuminstall gnutls-devel

 

$./configure

checking for idna.h... no

configure: error:Couldn't find required libidn installation 

$ sudo yuminstall libidn-devel

 

$./configure

checking pth.h usability... no

checking pth.h presence... no

checking for pth.h... no

configure: error:Couldn't find required libpth installation

 $ sudo yuminstall pth-devel

 

$./configure

checking expat.h presence... no

checking for expat.h... no

configure: error:Couldn't find required libexpat installation

 $ sudo yuminstall expat-devel

 

$./configure

You may now type 'make' to build your new Jabber system.

Type 'makeinstall' to install then.

 WARNING:

Your jabberd14 build will neither supportPostgreSQL nor MySQL.

You will have to reconfigure the server to storedata in files.

Please see at README.filespool on how to dothis.

 

$ make

 

mio_tls.cc:37:22:error: libtasn1.h: No such file or directory 

$ sudo yuminstall libtasn1-devel

 

xmlnode.cc: In function'xmlnode_list_item_t* xmlnode_get_tags(xmlnode_t*, const char*, xht_struct*,pool_struct*)':

xmlnode.cc:913: error:invalid conversion from 'const char*' to 'char*'

xmlnode.cc:914: error:invalid conversion from 'const char*' to 'char*'

xmlnode.cc: In function 'xmlnode_t*xmlnode_select_by_lang(xmlnode_list_item_t*, const char*)':

xmlnode.cc:1836: error:assignment of read-only location '* strchr(lang, 45)'

 

修改代码:

$ diff jabberd/lib/xmlnode.ccjabberd/lib/xmlnode.cc.origin

882,884c882,884

<    const char *next_step = NULL;

<    const char *start_predicate = NULL;

<    const char *end_predicate = NULL;

---

>    char *next_step = NULL;

>    char *start_predicate = NULL;

>    char *end_predicate = NULL;

1836c1836

<          ((char*)strchr(lang, '-'))[0] = 0;

---

>          strchr(lang, '-')[0] = 0;

  

/usr/include/gnutls/openpgp.h:312: error: too few arguments to function 'intgnutls_certificate_set_openpgp_key_file(gnutls_certificate_credentials_st*,const char*, const char*, gnutls_openpgp_crt_fmt_t)'

mio_tls.cc:615: error: at this point infile

/usr/include/gnutls/openpgp.h:342: error: too few arguments to function 'intgnutls_certificate_set_openpgp_keyring_file(gnutls_certificate_credentials_st*,const char*, gnutls_openpgp_crt_fmt_t)'

mio_tls.cc:634: error:at this point in file

mio_tls.cc:653: error:'gnutls_certificate_set_openpgp_trustdb' was not declared in this scope

 

修改代码:

[grid@h1 jabberd14-1.6.1.1]$ diffjabberd/mio_tls.cc jabberd/mio_tls.cc.origin

615c615

<          ret =gnutls_certificate_set_openpgp_key_file(current_credentials, pubfile, privfile,GNUTLS_OPENPGP_FMT_BASE64);

---

>          ret =gnutls_certificate_set_openpgp_key_file(current_credentials, pubfile,privfile);

634c634

<          ret = gnutls_certificate_set_openpgp_keyring_file(current_credentials,file, GNUTLS_OPENPGP_FMT_BASE64);

---

>          ret =gnutls_certificate_set_openpgp_keyring_file(current_credentials, file);

 

643,649c643,666

---

>      //load GnuPG trustdb

>      if(j_strcmp(xmlnode_get_localname(cur), "trustdb") == 0) {

>          char const *const file =xmlnode_get_data(cur);

>

>          if (file == NULL) {

>               log_warn(NULL,"Initializing TLS subsystem: <trustdb/> element inside the TLSconfiguration, that does not contain a file-name.");

>               continue;

>          }

>

>          // load the GnuPG trustdb

>          ret =gnutls_certificate_set_openpgp_trustdb(current_credentials, file);

>          if (ret < 0) {

>               log_error(NULL,"Error loading GnuPG trustdb %s: %s", file, gnutls_strerror(ret));

>               continue;

>          }

>      }

  

修改代码:

$ diff jabberd/log.ccjabberd/log.cc.origin

89c89

<      pos= (char*)strchr(zone,'.');

---

>      pos= strchr(zone,'.');

 

$ sudo make install


配置数据库

$ mysql -uroot -p
mysql> CREATEDATABASE jabber CHARACTER SET utf8;

mysql> usejabber;
mysql> grant allon jabber.* to jabber@localhost identified by 'secret'; 
mysql> \.mysql.sql

Jabber数据库账号:mysql -ujabber –psecret


启动

命令:

jabberd [-B] [-c config] [-d mask | -D] [-H dir] [-v] [-V] [-Z zone(s)] [-Idir]

 

jabberd是jabber server的核心,包括由指定逻辑扩展的,从配置文件定义的共享对象中加载的路由功能。

 

(man jabberd)

选项:

-B  在后台运行jabberd进程。

-c  指定配置文件。默认使用/usr/local/etc/jabber.xml

-U <user>  以<user>运行jabberd

-d <mask>  运行时输出调试信息。并使-B参数失效。

-D  类似-d但使所有类型的调试输出生效。

-H <dir>  设置相对路径的根目录。

-v –V 输出jabberd版本信息。

-Z <zones>  限制调试信息输出为代码中给定的区域。

-I <dir>  从目录导入数据到当前配置文件中配置的存储引擎。


进程pid文件:

/usr/local/var/run/jabberd/jabber.pid


测试

/usr/local/bin/jabberd

/usr/local/etc/jabber.xml

/usr/local/var/run/jabberd/jabber.pid

 

$ telnet localhost 5222


打开流:

<stream:stream  to='localhost' xmlns='jabber:client'  xmlns:stream='http://etherx.jabber.org/streams'>

<iq id='reg1' type='set'> <queryxmlns='jabber:iq:register'> <username>jack</username> <password>jack</password> <name>jack</name> <email></email></query> </iq> 

<iq id='reg1' type='get'> <queryxmlns='jabber:iq:register'/> </iq>


返回:

<?xmlversion='1.0'?><stream:streamxmlns:stream='http://etherx.jabber.org/streams'id='6cc2218ce8448cf8c3ef475570f0a6e504d3d603'xmlns='jabber:client'><stream:error><improper-addressingxmlns='urn:ietf:params:xml:ns:xmpp-streams'/><textxmlns='urn:ietf:params:xml:ns:xmpp-streams' xml:lang='en'>Did not specify avalid toargument</text></stream:error></stream:stream>Connectionclosed by foreign host.

  

注册用户1: 

<stream:stream  to='localhost' xmlns='jabber:client'  xmlns:stream='http://etherx.jabber.org/streams'>

返回:

<?xmlversion='1.0'?><stream:streamxmlns:stream='http://etherx.jabber.org/streams'id='cdbabffceef5d6c17dbaae6df94fefdae2484c2d' from='localhost'xmlns='jabber:client'>

<iq id='reg1' type='get'><queryxmlns='jabber:iq:register'/></iq>

<iq id='reg1' type='set'>  <queryxmlns='jabber:iq:register'>   <username>jack</username>   <password>jack</password>   <name>jack</name>   <email></email>  </query> </iq>

0 0
原创粉丝点击