# CentOS7 源码构建安装ejabberd
# 安装测试环境Win10应用商店版CentOS
# 1.安装所需依赖
yum -y install make
yum -y install gcc
yum -y install gcc-c++
yum -y install kernel-devel
yum -y install m4
yum -y install ncurses-devel
yum -y install openssl-devel
yum -y install unixODBC-devel
yum -y install libtool
yum -y install libtool-ltdl-devel
yum -y install automake
yum -y install autoconf
yum -y install wx
yum -y install fop
yum -y install expat-devel
yum -y install libyaml-devel
yum -y install dos2unix
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
安装Erlang/OTP 22.0 ,可参考:CentOS 7 系统安装 Erlang/OTP 22.0 (opens new window)
# 2.下载源码
git clone git://github.com/processone/ejabberd.git ejabberd
# 3.配置生成 Makefile
cd ejabberd
windows换行符\r\n 替换成linux 换行符
sed -i 's/\r//' autogen.sh
./autogen.sh
windows换行符\r\n 替换成linux 换行符
sed -i 's/\r//' configure.ac
sed -i 's/\r//' Makefile.in
sed -i 's/\r//' configure
sed -i 's/\r//' vars.config.in
sed -i 's/\r//' aclocal.m4
sed -i 's/\r//' install-sh
2
3
4
5
6
重新configure 一下
autoreconf -vif
以上两步可解决: error: cannot find input file: `vars.config
# 4.编译
./configure --enable-user=ejabberd --enable-mysql
成功编译如下图所示:
这会告诉配置,准备安装的程序以名为ejabberd的用户一起运行,因此请创建该用户或告诉使用其他本地用户。不建议以root用户运行
注意:要构建ejabberd,您将需要Internet访问,因为依赖项将根据所选选项进行下载。
构建配置脚本允许多个选项。要获取完整列表,请运行以下命令:
./configure --help
-–bindir=/
: Specify the path to the user executables (whereepmd
andiex
are available).-–prefix=/
: Specify the path prefix where the files will be copied when running themake install
command.-–enable-user[=USER]
: Allow this normal system user to execute the ejabberdctl script (see section ejabberdctl (opens new window)), read the configuration files, read and write in the spool directory, read and write in the log directory. The account user and group must exist in the machine before runningmake install
. This account doesn't need an explicit HOME directory, because/var/lib/ejabberd/
will be used by default.-–enable-pam
: Enable the PAM authentication method (see section pam (opens new window)).-–enable-tools
: Enable the use of development tools.-–enable-mysql
: Enable MySQL support (see section databases (opens new window)).-–enable-pgsql
: Enable PostgreSQL support (see section databases (opens new window)).-–enable-sqlite
: Enable SQLite support (see section databases (opens new window)).-–enable-redis
: Enable Redis support to use for external session storage.-–enable-zlib
: Enable Stream Compression (XEP-0138) using zlib.-–enable-lager
: Use lager Erlang logging tool instead of standard error logger.–-enable-debug
: Compile with+debug_info
enabled.–-enable-elixir
: Build ejabberd with Elixir extension support.–-enable-all
: Enable all previous options.--enable-latest-deps
: Makes rebar use latest versions of dependences developed alongside ejabberd instead of version specified in rebar.config. Should be only used when developing ejabberd.
Here are other available options, that are experimental and not recommended:
–-enable-hipe
: Compile natively with HiPE, not recommended.
# 5.安装
make install
默认情况下,创建的文件和目录为:
/usr/local/etc/ejabberd/
: Configuration directory:ejabberd.yml
: ejabberd configuration fileejabberdctl.cfg
: Configuration file of the administration scriptinetrc
: Network DNS configuration file for Erlang
/usr/local/lib/ejabberd-19.09.65/
:ebin/
: Erlang binary files (*.beam)include/
: Erlang header files (*.hrl)priv/
: Additional files required at runtimebin/
: Executable programslib/
: Binary system libraries (*.so)msgs/
: Translation files (*.msgs)
/usr/local/sbin/ejabberdctl
: Administration script (see section ejabberdctl (opens new window))/usr/local/share/doc/ejabberd/
: Documentation of ejabberd/usr/local/var/lib/ejabberd/
: Spool directory:.erlang.cookie
: Erlang cookie file (see section cookie (opens new window))acl.DCD, ...
: Mnesia database spool files (*.DCD, *.DCL, *.DAT)
/usr/local/var/log/ejabberd/
: Log directory (see section [logfiles]):ejabberd.log
: ejabberd service logerlang.log
: Erlang/OTP system log
# 7.手动启动
如果运行报错 $'\r': command not found 执行如下两条命令 将文件格式转成unix编码格式
dos2unix /usr/local/sbin/ejabberdctl
dos2unix /usr/local/etc/ejabberd/ejabberdctl.cfg
2
# 启动
cd /usr/local/sbin
ejabberdctl start
2
# 查看启动状态
ejabberdctl status
# 停止
ejabberdctl stop
更多指令https://docs.ejabberd.im/admin/guide/managing/#ejabberdctl (opens new window)
# 8.在您的ejabberd服务器上注册一个XMPP帐户
ejabberdctl register admin localhost 123456
其中 admin:代表要注册一个admin账号,localhost:服务器地址,123456:admin账号的密码
修改配置
vim /usr/local/etc/ejabberd/ejabberd.yml
修改web服务器的ip地址,默认是 "::"
-
port: 5280
ip: "localhost"
module: ejabberd_http
request_handlers:
/admin: ejabberd_web_admin
/.well-known/acme-challenge: ejabberd_acme
2
3
4
5
6
7
设置ip为 localhost
编辑ejabberd配置文件,为您创建的XMPP帐户授予管理权限
acl:
admin:
user:
- "admin": "localhost"
local:
user_regexp: ""
loopback:
ip:
- 127.0.0.0/8
- ::1/128
access:
configure:
admin: allow
2
3
4
5
6
7
8
9
10
11
12
13
设置vim蓝色注释看不清楚在vim内修改
:hi comment ctermfg =darkyellow
1
更多配置请参考:https://docs.ejabberd.im/admin/configuration/ (opens new window)
# 9.重新启动ejabberd以加载新配置
ejabberdctl restart
# 10.登录后台管理页面
http://localhost:5280/admin/ (opens new window)
已授权用户登录:admin
# 
未授权用户登录:summergao
# 11.总结
# 
yum install expat-devel
yum install libyaml-devel
# 测试
测试ejabberd服务器Rest API (opens new window)
使用Spark、pandion客户端测试ejabberd服务器 (opens new window)
# 参考
https://docs.ejabberd.im/admin/installation/#install-from-source-code (opens new window)
https://blog.csdn.net/w690333243/article/details/80344690 (opens new window)