OpenSIPS is an Open Source SIP proxy/server for voice, video, IM, presence and any other SIP extensions.OpenSIPS is a multi-functional, multi-purpose signaling SIP server used by carriers, telecoms or ITSPs for solutions like Class4/5 Residential Platforms, Trunking / Wholesale, Enterprise / Virtual PBX Solutions, Session Border Controllers, Application Servers, Front-End Load Balancers, IMS Platforms, Call Centers, and many others – see the full Set of Features.
搜索一下网上安装opensips的文章基本都是源码安装的,虽然从源码安装并不是十分困难,但是在安装过程中需要处理各种依赖库。并且在某些系统上会出现编译不过的问题,在阿里云的服务器上很容易就通过源码安装好了opensips。但是由于阿里云的ecs没有经典网络,所以无法在公网ip绑定服务,导致客户端无法正常连接。如果有在阿里云部署服务的,那么可能会在这个地方失败。
在内网尝试部署的时候出现了另外一个问题,那就是源码编译不过去。搜索了一下发现其实可以通过ubuntu的apt命令进行安装,不过官方的apt源限定了linux的发行版本。所以在安装之前最好先确认一下,建议使用ubuntu18.04.
OpenSIPS Releases:
OpenSIPS related packages:
- OpenSIPS CLI – OpenSIPS CLI tool for managing OpenSIPS 3
Supported Platforms:
Supported Architectures:
- amd64
官方apt连接地址:https://apt.opensips.org
1.添加opensips apt源:
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 049AD65B
echo "deb https://apt.opensips.org bionic 3.1-releases" >/etc/apt/sources.list.d/opensips.list
echo "deb https://apt.opensips.org bionic cli-nightly" >/etc/apt/sources.list.d/opensips-cli.list
2.安装opensips
sudo apt install opensips
3. 添加opensips-cli apt源(3.1版本的opensips将原有的cli命令行工具拆分了,需要单独安装,如果不安装无法创建使用命令行工具,例如创建数据库添加用户等):
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 049AD65B
echo "deb https://apt.opensips.org bionic cli-nightly" >/etc/apt/sources.list.d/opensips-cli.list
4.安装opensips-cli
apt install opensips-console
5.安装mysql server,配置数据库连接
apt install mysql-server
sudo mysql_secure_installation
6.修改配置文件:
# vi /usr/local/etc/opensips/opensips.cfg
listen=udp:192.168.1.124:5060 # CUSTOMIZE ME
# vi /usr/local/etc/opensips/opensipsctlrc
DBENGINE=MYSQL
DBPORT=3306
DBHOST=127.0.0.1
DBNAME=opensips
DBRWUSER=opensips
DBRWPW="opensipsrw"
DBROOTUSER="root"
到目前安装部分就完成了,不过如果这时候执行opensipsdbctrl create可能会出现下面的错误信息:
# opensipsdbctl create
ERROR: could not load the script in /usr/local//lib64/opensips/opensipsctl/opensipsdbctl.mysql for database engine MYSQL
ERROR: database engine not loaded - tried 'MYSQL'
这是由于安装的时候缺少mysql文件导致的,缺少的文件从源代码中找。我整理了一份,可以直接将这个文件解压后放入opensipsctl目录下。
下载链接:https://obaby.lanzous.com/io04cnakwwh
然后再次创建数据库即可,通过以下命令添加用户:
# opensipsctl add 10001 123456
ERROR: domain unknown: use usernames with domain or set default domain in SIP_DOMAIN
# 如果出现上面的错误信息,修改opensipsctlrc将SIP_DOMAIN的注释去掉,填写自己的域名或者IP地址
# opensipsctl add 10001@testtest.com.cn 123456
new user '10001@testtest.com.cn' added
然后就可以通过客户端链接了,例如linphone(windows版本下载链接:https://www.linphone.org/releases/windows/app/Linphone-4.2.5-win32.exe,下载页面链接:https://new.linphone.org/technical-corner/linphone?qt-technical_corner=2#qt-technical_corner):
在服务器可以通过 opensipsctl ul show命令查看连接的客户端:
1 comment
ERROR: could not load the script in /usr/lib64/opensips/opensipsctl/opensipsdbctl.mysql for database engine MYSQL
ERROR: database engine not loaded – tried ‘MYSQL’
解决办法:rpm包未包含mysql模块,需访问官网下载提供的对应安装版本的db_mysql rpm包安装即可