Opensips server environment construction

Opensips server environment construction

introduction:

本博文介绍linux环境下的opensips服务器环境搭建,采用源码安装的方式。

1. Official website download address:

http://www.opensips.org/Resources/Downloads
下载完解压后先不要直接编译

2. After executing the make menuconfig command in the source directory, exit directly, the Makefile.conf file will be generated in the source root directory, and the Makefile.conf file will be modified:

在exclude_modules中删掉db_postgres;
在include_modules中添加db_postgres;
修改安装目录为PREFIX=/usr/local/opensips/

3. Then execute make&&make install
4. Configure opensips There are two files that need to be configured under the /usr/local/opensips/etc/opensips path

1)修改opensipsctlrc文件

Insert picture description here

2) 修改opensips.cfg文件
使用make menuconfig菜单工具生成一个opensips.cfg文件,按照下图操作

Insert picture description hereInsert picture description hereInsert picture description here
Insert picture description here
Insert picture description here

记住自己菜单中生成的 .cfg文件名
退出菜单后cd etc/
mv 生成的.cfg文件 opensips.cfgcp  opensips.cfg  /usr/local/opensips/etc/opensips/opensips.cfg
然后正式进行修改opensips.cfg,如下:

Insert picture description here
5. Create the db_opensips database

 在/usr/local/opensips/sbin路径下执行:./opensipsdbctl create
 错误1:【postgresql】role "root" does not exist
 解决办法:直接将root创建为超级用户,login是指允许登录
	 在postgres下执行:
	 CREATE ROLE root superuser PASSWORD 'password' login;
 错误2:FATA:no pg_hba.conf entry for host "192.168.9.59",user "opensips",database 	"db_opensips",SSL off
 解决办法:修改配置文件/var/lib/postgresql/9.1/main/pg_hba.conf 添加如下信息,
 然后重启postgres服务:systemctl restart postgresql.service:

Insert picture description here
6. Turn on opensips service

在/usr/local/opensips/sbin路径下执行:./opensipsctl start
错误:ERROR: PID file /var/run/opensips.pid does not exist -- OpenSIPS start failed:
使用tail -f /var/log/messages查看错误信息
       1).找到modules存放库文件的路径我的为:/usr/local/opensips/lib64/opensips/modules	
       将/usr/local/opensips/etc/opensips/opensips.cfg 文件中medule path修改如下:

Insert picture description here

2) .CRITICAL:core:yyerror:parse error in config file /usr/local/opensips/etc/opensips/opensips.cfg, line 87, column 13-14: failed to load module db_mysql.so
由于我使用的postgres数据库,因此还需在opensips.cfg文件中进行如下修改:

Insert picture description here

3).ERROR:core:db_check_api: module db_mysql does not export db_use_table function
因为在/usr/local/opensips/etc/opensips/opensipsctlrc文件中设置使用的postgres数据库,
数据库名为db_opensips,密码为leagsoft,因此需要将opensips.cfg文件中所有的
"mysql://opensips:opensipsrw@localhost/opensips")修成:"postgres://opensips:leagsoft@localhost/db_opensips") 

4).opensips服务启动成功

Insert picture description here

7. Use of opensips

./opensipsctl start      #开启opensips服务
./opensipsctl stop       #关闭opensips服务
./opensipsctl restart    #重启opensips服务 
./opensipsctl add username password       #添加用户
./opensipsctl rm username                 #删除用户
./opensipsctl ul show    #查看已注册用户信息
./opensipsctl online	 #查看在线用户名
./opensipsctl help       #查看帮助文档

Guess you like

Origin blog.csdn.net/weixin_44090937/article/details/109297147