由于工作缘故,需要安装个 VoIP Server做个测试,看了网上的指导,决定采用 OpenSIP 做SIP Server,搜了下网上教程,发现有些不太全,这里把我的成功经历写一下,方便有需要的朋友。
我的安装平台是 CentOS 6.5, 64位,可以使用如下命令查看:
[root@EA-SERVER ~]# lsb_release -a LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch Distributor ID: CentOS Description: CentOS release 6.5 (Final) Release: 6.5 Codename: Final
[root@EA-SERVER ~]# yum -y install wget gcc bison flex zlib-devel openssl-devel mysql-server mysql-devel2. 下载软件
[root@EA-SERVER ~]# wget http://opensips.org/pub/opensips/latest/src/opensips-1.10.0_src.tar.gz
[root@EA-SERVER ~]# tar xf opensips-1.10.0_src.tar.gz
[root@EA-SERVER ~]# cd opensips-1.10.0-tls/ [root@EA-SERVER ~]# make menuconfig文本图形配置界面如下图所示:
OpenSIPS Main Configuration Menu ___________________________________________ | | | ---> Configure Compile Options | | Compile And Install OpenSIPS | | Cleanup OpenSIPS sources | | Generate OpenSIPS Script | | Exit & Save All Changes | |___________________________________________| Press h for navigation help.
(1) 进入Configure Compile Options->Configure Excluded Modules, 勾选 db_mysql;返回保存;
(2) 进入Compile And Install OpenSIPS,此时开始编译和安装,结束后会返回到菜单界面
(3) 进入Exit & Save All Changes 退出;
5. 设置数据库配置
安装好的配置文件在 /usr/local/etc/opensips/ 目录下,编辑 opensipsctlrc 文件,将如下几行前的 # 号去掉,其他不变,保存:
DBENGINE=MYSQL
DBHOST=localhost
DBNAME=opensips
DBRWUSER=opensips
DBRWPW="opensipsrw"
DBROOTUSER="root"
然后使用如下命令创建数据库,注意输入mysql管理员密码
[root@EA-SERVER ~]# opensipsdbctl create6. 安装 rtpproxy
下载
[root@EA-SERVER ~]# git clone git://sippy.git.sourceforge.net/gitroot/sippy/rtpproxy安装
[root@EA-SERVER ~]# cd rtpproxy [root@EA-SERVER ~]# ./configure&&make&&make install
[root@EA-SERVER ~]# rtpproxy -l xxx.xxx.xxx.xxx -s udp:xxx.xxx.xxx.xxx:7890 -F
7. 配置opensips
在命令行下输入 osipsconfig 会进入opensips 功能文件配置界面
OpenSIPS Main Configuration Menu _______________________________________ | | | ---> Generate OpenSIPS Script | | Exit & Save All Changes | |_______________________________________| Press h for navigation help.选择 Generate OpenSIPS Script->Residential Script->Configure Residential Script, 勾选 USE_AUTH, USE_DBACC, USE_DBUSRLOC, USE_DIALOG,USE_NAT;
然后返回选择 Generate Residential Script, 则会保存文件到 /usr/local/etc/opensips/opensips_residential_xxxx-xx-xx_xx:xx:xx.cfg, 回到usr/local/etc/opensips/目录下,将原有的opensips.cfg文件重命名,将新创建的cfg文件保存为opensips.cfg文件,然后打开 opensips.cfg 文件,编辑:
(1). 替换listen=udp:xxx.xxx.xxx.xxx:5060为服务器地址
(2). 替换modparam("rtpproxy", "rtpproxy_sock", "udp:xxx.xxx.xxx.xxx:7890") # CUSTOMIZE ME 为服务器地址;
8. 创建测试账户
[root@EA-SERVER ~]# opensipsctl add [email protected] 123456 [root@EA-SERVER ~]# opensipsctl add [email protected] 1234569. 启动服务
[root@EA-SERVER ~]# opensipsctl start10. 使用 SIP 客户端 SipDroid或者IMSDroid在 Android 手机上可以测试101和102通话了。