Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2148075
  • 博文数量: 333
  • 博客积分: 10161
  • 博客等级: 上将
  • 技术积分: 5238
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-19 08:59
文章分类

全部博文(333)

文章存档

2017年(10)

2014年(2)

2013年(57)

2012年(64)

2011年(76)

2010年(84)

2009年(3)

2008年(37)

分类: LINUX

2010-09-21 14:02:44

                       Redhat5.232bit)安装配置opensips

 

一.              安装系统时选包

a)        Servers>Mysql Database>Optional Packages>Default plus

                        i.              mysql-devel-5.0.45-7.el5.i386

                       ii.              php-mysql-5.1.6-23.el5.i386

                     iii.              mod_auth_mysql-3.0.0-3.1.i386

b)        Servers>Web Server>Optional Packages>Default plus

                        i.              mod_nss-1.0.3-6.el5.i386

c)         Servers>Mail Server>Default

二.              安装和配置

1.确认安装环境,否则编译很难通过。

如果按照第一步选包系统已经安装包:

zlib-1.2.3-3.i386

openssl-0.9.8e-7.el5.i686

mysql-server-5.0.45-7.el5.i386

除此之外,还应安装如下rpm套件,可以使用“rpm –qa |grep (套件名)”来查询。

gcc, bison, flex, zlib-devel, openssl-devel

2.编译安装opensips

opensips-1.6.2-notls_src.tar.gztls传输层安全)上传到服务器,然后解压到当前目录

tar xzvf opensips-1.6.2-notls_src.tar.gz

拷贝到/usr/src/目录下面

mv opensips-1.6.2-notls /usr/src/opensips

 

然后切换到/usr/src/opensips目录下面修改配置文件,编译

cd /usr/src/opensips/

vi Makefile 修改Makefile,去掉db_mysql选项

# if not set on the cmd. line or the env, exclude this modules:

exclude_modules?= b2b_logic jabber cpl-c xmpp rls mi_xmlrpc xcap_client \

        db_mysql db_postgres db_unixodbc db_oracle db_berkeley aaa_radius \

        osp perl snmpstats perlvdb carrierroute mmgeoip \

        presence presence_xml presence_mwi presence_dialoginfo \

        pua pua_bla pua_mi pua_usrloc pua_xmpp pua_dialoginfo \

        ldap h350 identity regex memcached db_http json

去掉后:

# if not set on the cmd. line or the env, exclude this modules:

exclude_modules?= b2b_logic jabber cpl-c xmpp rls mi_xmlrpc xcap_client \

        db_postgres db_unixodbc db_oracle db_berkeley aaa_radius \

        osp perl snmpstats perlvdb carrierroute mmgeoip \

        presence presence_xml presence_mwi presence_dialoginfo \

        pua pua_bla pua_mi pua_usrloc pua_xmpp pua_dialoginfo \

        ldap h350 identity regex memcached db_http json

编译opensips

make clean

make all include_modules="mysql"

make prefix=/usr/local install include_module="mysql"

编辑opensipsctlrc 取消mysql注释“#

vi /usr/local/etc/opensips/opensipsctlrc 

# this parameter.

# DBENGINE=MYSQL

启动数据库mysql

[root@sun-test ~]# service mysqld start

Initializing MySQL database:  Installing MySQL system tables...

OK

Filling help tables...

OK

To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'

/usr/bin/mysqladmin -u root -h sun-test password 'new-password'

See the manual for more instructions.

You can start the MySQL daemon with:

cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at

Support MySQL by buying support/licenses at

                                                           [  OK  ]

Starting MySQL:                                            [  OK  ]

mysql数据库的root用户创建密码为baustem

[root@sun-test bin]# mysqladmin -u root password baustem

[root@sun-test bin]#

创建opensips数据库

[root@sun-test bin]# /usr/local/sbin/opensipsdbctl create

MySQL password for root:

INFO: test server charset

INFO: creating database opensips ...

INFO: Core OpenSIPS tables succesfully created.

Install presence related tables? (y/n): y

INFO: creating presence tables into opensips ...

INFO: Presence tables succesfully created.

Install tables for imc cpl siptrace domainpolicy carrierroute userblacklist? (y/n): y

INFO: creating extra tables into opensips ...

INFO: Extra tables succesfully created.

[root@sun-test bin]#

设置mysql自启动并查看

[root@sun-test ~]# chkconfig mysqld on

[root@sun-test ~]# chkconfig --list mysqld

mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

设置opensips自启动的启动脚本:

 

把内容复制下来,然后在linux系统服务器中新建文件/etc/init.d/opensips,并把内容粘贴进去保存退出

[root@sun-test ~]# chmod 755 /etc/init.d/opensips

[root@sun-test ~]# chkconfig --add opensips

[root@sun-test ~]# chkconfig --list opensips \\查看添加系统启动服务成功

opensips        0:off   1:off   2:off   3:on    4:on    5:on    6:off

运行opensips命令

[root@sun-test ~]# service opensips stop

Stopping opensips:                                         [  OK  ]

[root@sun-test ~]# service opensips start

Starting opensips:                                         [  OK  ]

[root@sun-test ~]# service opensips status

opensips (pid 17605 17604 17603 17602 17601 17600 17599 17598 17597 17596 17595 17594 17593 17592 17591 17590 17588) is running...

 

配置到此步骤,服务器已经可以完成用户自动注册服务;如果想控制用户的添加等操作,需要进一步修改配置文件/usr/local/etc/opensips/opensips.cfg

下面配置内容前面的#号全部取消:实际配置内容应如下:

/* uncomment next line for MySQL DB support */ 

loadmodule "db_mysql.so" 

···

loadmodule "acc.so" 

/* uncomment next lines for MySQL based authentication support 

NOTE: a DB (like db_mysql) module must be also loaded */ 

loadmodule "auth.so" 

loadmodule "auth_db.so" 

····

/* uncomment the following lines if you want to enable DB persistency 

for location entries */ 

modparam("usrloc", "db_mode", 2) 

···

/* uncomment the following lines if you want to enable the DB based 

authentication */ 

modparam("auth_db", "calculate_ha1", yes) 

modparam("auth_db", "password_column", "password") 

···

#authenticate the REGISTER requests (uncomment to enable auth)

if (!www_authorize("10.10.10.101", "subscriber"))  //根据实际ip地址修改

{ 

    www_challenge("10.10.10.101", "0");    //根据实际ip地址修改

    exit;

}

opensips.cfg配置文件:

配置完后重启opensips服务。

[root@sun-test ~]# service opensips reload                                   

Stopping opensips:                                         [  OK  ]

Starting opensips:                                         [  OK  ]

3.非自动注册模式使用

配置SIP_DOMAIN,添加如下内容到/root/.bash_profile文件:

export SIP_DOMAIN=192.168.0.241     //服务器ip

添加一个测试用户:

[root@sun-test ~]# opensipsctl add 2000 123456

MySQL password for user 'opensips@localhost':         //密码为opensipsrw

new user '2000' added

 

测试注册用户,在pc机器上安装linphone,配置开通的用户和密码,然后拨号,在服务器上可以看到:

  

Pc拨号软件端设置,拨号连接时候需要填写之前注册用户名密码

 

Sipserver服务器上查看:

        [root@sun-test ~]# opensipsctl ul show
        Domain:: location table=512 records=1
        AOR:: 654333
                Contact:: sip:654333@192.168.0.203:5060 Q=
                        Expires:: 3556
                        Callid:: 29964
                        Cseq:: 2
                        User-agent:: Linphone/3.3.2 (eXosip2/3.3.0)
                        State:: CS_SYNC
                        Flags:: 0
                        Cflag:: 0
                        Socket:: udp:192.168.0.241:5060
                        Methods:: 4294967295

阅读(3257) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-12-22 13:12:39

朋友,你试过这样可以行的吗,我按照你的方法试了下,出现下面错误 n 13-14: failed to load module Dec 22 10:54:59 localhost opensips: ERROR:core:main: bad config file (1 errors) Dec 22 10:55:03 localhost sshd(pam_unix)[4723]: session opened for user root by root(uid=0) Dec 22 10:55:22 localhost opensips: ERROR:core:sr_load_module: could not open module : libmysqlclient.so.16: cannot open shared object file: No such file or directory Dec 22 10:55:22 localhost opensips: CRITICAL: