在Ubuntu上安装与配置ejabberd

1. 安装node

    执行apt-get install ejabberd也可登陆官网https://www.process-one.net下载软件包安装。mysql


2. 启停服务git

    ejabberdctl restart / stop /start / stop / statusgithub

注:有时使用ejabberdctl start启动时会有“Failed RPC connectionto the node ejabberd@ubuntu12: nodedown”之类的报错,此时可从/etc/init.d/ejabberd start启动。sql


3. 建立用户数据库

3.1 使用命令注册用户ubuntu

例如要在localhost上注册用户“user1”,密码为“123456”:浏览器

    ejabberdctl register user1localhost 123456app

 

3.2 修改配置文件ide

编辑文件/etc/ejabberd/ejabberd.cfg,在

 %% Admin user

{acl, admin,{user, "", "localhost"}}.

后(约第57行)添加

{acl, admin, {user, "user1","localhost"}}.

{access, configure, [{allow, admin}]}.

 

3.3 重启

    ejabberdctl restart

 

3.4 访问管理界面

用浏览器访问http://192.168.10.142:5280/admin,用户名为user1@localhost,密码为123456。登陆后界面以下图所示:

wKiom1XKMPmTirfAAAIP9XGhOG4546.jpg

 

4 链接Mysql

4.1 mysql中建立数据库和用户

create database ejabberd default character set utf8 collate utf8_general_ci;

grantall privileges on ejabberd.* to ej_user@'localhost' identified by 'ej123456';

 

4.2 初始化数据库

经过apt-get安装的ejabberd不带有数据库初始化脚本,如果手动安装,则mysql脚本位于ejabberd/lib/ejabberd/priv/sql/mysql.sql。也可直接从https://github.com/processone/ejabberd/blob/master/sql/mysql.sql下载该脚本。

用如下命令导入数据

mysql -u ej_user -p ejabberd < mysql.sql

此时可能会出现这个错误:

ERROR 1214 (HY000) at line 99: The usedtable type doesn't support FULLTEXT indexes

缘由为mysql 5.5不支持全文索引,将该表的存储引擎改成MyISAM可解决该问题。

 

4.3 修改配置文件

修改文件/etc/ejabberd/ejabberd.cfg

注释{auth_method,internal}.

取消注释{auth_method,odbc}.

取消注释并修改数据库链接信息{odbc_server, {mysql, "server","database", "username", "password"}}.

修改模块,大约从579行开始,在原模块后增长_odbc,如:

{mod_last_odbc,

{mod_offline_odbc,

{mod_privacy_odbc,

{mod_private_odbc,

{mod_pubsub_odbc,

{mod_roster_odbc,

{mod_vcard_odbc,

 

4.4 编译Mysql模块

ejabberd默认没有mysql模块,需手动编译,不然在启动时将出现如下报错:

=ERROR REPORT==== 2015-08-11 23:55:24 ===

C(<0.684.0>:ejabberd_check:63) : ejabberd is configured to use 'mysql', but the following Erlang modules are not installed: '[mysql,                     


mysql_auth,

mysql_conn,

mysql_recv]'

=INFO REPORT==== 2015-08-11 23:55:24 ===

    application: ejabberd

    exited: {bad_return,{{ejabberd_app,start,[normal,[]]},

                         {'EXIT',database_module_missing}}}

    type: temporary

 

https://svn.process-one.net/ejabberd-modules/mysql/trunk/下载模块的源码,使用命令erlc  *.erl编译src中的模块,将获得mysql_auth.beammysql.beammysql_conn.beammysql_recv.beam四个文件,将其放入/usr/lib/ejabberd/ebin/中,将能正常启动ejabberd

 

4.5 添加用户

使用以下命令添加用户

ejabberdctl register rootlocalhost 123456

用浏览器访问http://192.168.10.142:5280/admin,用户名为root@localhost,密码为123456

相关文章
相关标签/搜索