以下为在centos 下的安装和配置步骤:
1、安装需要的安装包:
如果你安装mysql 5.1或以上的版本,需要安装mysql-devel 5.0 相关的lib库。或者安装编译mysql5.0;
mysql 的编译安装步骤略。
2、安装opensips:
安装之前编辑Makefile中的exclude_modules后面的字段,去掉db-mysql 关键字。使opensips 支持mysql数据库;
#make all
#make install
3.配置opensips 数据库相关选项。
#vi /usr/local/etc/opensips/opensipsctlrc
DBENGINE=MYSQL
DBHOST=localhost
DBNAME=opensips
DB_PATH="/usr/local/etc/opensips/dbtext"
DBRWUSER=root
DBRWPW="abc"
DBROUSER=root
DBROPW="abc"
DBROOTUSER="root"
USERCOL="username"
4、创建数据库:
# /usr/sbin/opensipsdbctl create
input 选项:
root 密码;
数据库语言;
Install presence related tables? (y/n): y
是否创建相关表,
INFO: creating database opensips ...
INFO: Core OpenSIPS tables succesfully created.
Install tables for imc cpl siptrace domainpolicy carrierroute userblacklist? (y/n): y
INFO: creating extra tables into opensips .
5、启动opensips
# /usr/local/sbin/opensipsctl start
INFO: Starting OpenSIPS :
INFO: started (pid: 17110)
6、停止opensips
# /usr/local/sbin/opensipsctl stop
安装和启动部分配置完成。
目录机构如下:
配置文件位置:/usr/local/etc/opensips/
mysql 数据库表创建sql语句:/usr/local/share/opensips/mysql/
安装模块目录:/usr/local/lib/opensips/modules/
opensips 控制台模板:/usr/local/lib/opensips/opensipsctl/
程序运行路径:/usr/local/sbin/
下面配置opensips 使其支持数据库验证功能:
#cd /usr/local/etc/opensips/
# vi opensips.cfg
log_stderror=yes
disable_tcp=yes
port=5060
####### Modules Section ########
loadmodule "db_mysql.so"
loadmodule "auth.so"
loadmodule "auth_db.so"
# ----- usrloc params -----
#modparam("usrloc", "db_mode", 0)
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url",
"mysql://root:abc@localhost/opensips")
# ----- auth_db params -----
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "db_url",
"mysql://root:abc@localhost/opensips")
modparam("auth_db", "load_credentials", "")
通过关键字:www_authorize 找到以下段:
if (!www_authorize("", "subscriber"))
{
www_challenge("", "0");
exit;
}
配置mysql 连接信息:
cd /usr/local/etc/opensips
vi opensipsctlrc
## your SIP domain
SIP_DOMAIN=opensips.org
其他选项则为mysql 的用户名和密码的配置信息,略;
配置完成后,可以通过以下命令检查是否正常:
opensips -c
May 16 10:38:35 [20334] WARNING:core:fix_socket_list: could not rev. resolve 10.201.197.150
Listening on
udp: 127.0.0.1 [127.0.0.1]:5060
udp: 10.201.107.150 [10.201.197.150]:5060
Aliases:
udp: localhost:5060
udp: localhost.localdomain:5060
udp: opensips:5060
May 16 10:38:35 [20334] NOTICE:core:main: config file ok, exiting...
通过以下命令来显示opensips 的运行信息:
opensipsctl moni
终止可以按CTRL+C
用软电话注册账号:
opensipctl add <username>@opensips_address <password>
#opensipctl add 1001@10.201.197.150 1234
#opensipctl add 1002@10.201.197.150 1234
以下为通过help 命令显示的相关帮助:
# opensipsctl --help
/usr/local/sbin/opensipsctl $Revision: 4448 $
Existing commands:
-- command 'start|stop|restart'
restart ............................ restart OpenSIPS
start .............................. start OpenSIPS
stop ............................... stop OpenSIPS
-- command 'acl' - manage access control lists (acl)
acl show [<username>] .............. show user membership
acl grant <username> <group> ....... grant user membership (*)
acl revoke <username> [<group>] .... grant user membership(s) (*)
-- command 'lcr' - manage least cost routes (lcr)
* IP addresses must be entered in dotted quad format e.g. 1.2.3.4 *
* <uri_scheme> and <transport> must be entered in integer or text,*
* e.g. transport '2' is identical to transport 'tcp'. *
* scheme: 1=sip, 2=sips; transport: 1=udp, 2=tcp, 3=tls *
* Examples: lcr addgw level3 1.2.3.4 5080 sip tcp 1 *
* lcr addroute +1 '' 1 1 *
lcr show .....................................................................
............. show routes, gateways and groups
lcr reload ...................................................................
............. reload lcr gateways
lcr addgw <gw_name> <ip> <port> <scheme> <transport> <grp_id> <flags> <tag> <strip>
............... add a gateway with flags, tag and strip ............
................(flags, tag, and strip are optional arguments) .....
lcr rmgw <gw_name> ..........................................................
............... delete a gateway
lcr addroute <prefix> <from> <grp_id> <prio> .................................
.............. add a route ( use '' to match anything in <from> )
lcr rmroute <prefix> <from> <grp_id> <prio> .................................
.............. delete a route
-- command 'cr' - manage carrierroute tables
cr show ....................................................... show tables
cr reload ..................................................... reload tables
cr dump ....................................................... show in memory tables
cr addrt <routing_tree_id> <routing_tree> ..................... add a tree
cr rmrt <routing_tree> ....................................... rm a tree
cr addcarrier <carrier> <scan_prefix> <domain> <rewrite_host> ................
<prob> <strip> <rewrite_prefix> <rewrite_suffix> ...............
<flags> <mask> <comment> .........................add a carrier
(prob, strip, rewrite_prefix, rewrite_suffix,...................
flags, mask and comment are optional arguments) ...............
cr rmcarrier <carrier> <scan_prefix> <domain> ................ rm a carrier
-- command 'rpid' - manage Remote-Party-ID (RPID)
rpid add <username> <rpid> ......... add rpid for a user (*)
rpid rm <username> ................. set rpid to NULL for a user (*)
rpid show <username> ............... show rpid of a user
-- command 'add|passwd|rm' - manage subscribers
add <username> <password> .......... add a new subscriber (*)
passwd <username> <passwd> ......... change user's password (*)
rm <username> ...................... delete a user (*)
-- command 'add|dump|reload|rm|show' - manage address
address show ...................... show db content
address dump ...................... show cache content
address reload .................... reload db table into cache
address add <grp> <ip> <mask> <port> <proto> [<context_info>] [<pattern>]
....................... add a new entry
....................... (from_pattern and tag are optional arguments)
address rm <grp> <ip> <mask> <port> ............... remove all entries
....................... for the given grp ip mask port
-- command 'dispatcher' - manage dispatcher
* Examples: dispatcher addgw 1 sip:1.2.3.1:5050 1 'outbound gateway'
* dispatcher addgw 2 sip:1.2.3.4:5050 3 ''
* dispatcher rmgw 4
dispatcher show ..................... show dispatcher gateways
dispatcher reload ................... reload dispatcher gateways
dispatcher dump ..................... show in memory dispatcher gateways
dispatcher addgw <setid> <destination> <flags> <description>
.......................... add gateway
dispatcher rmgw <id> ................ delete gateway
-- command 'db' - database operations
db exec <query> ..................... execute SQL query
db roexec <roquery> ................. execute read-only SQL query
db run <id> ......................... execute SQL query from $id variable
db rorun <id> ....................... execute read-only SQL query from
$id variable
db show <table> ..................... display table content
-- command 'speeddial' - manage speed dials (short numbers)
speeddial show <speeddial-id> ....... show speeddial details
speeddial list <sip-id> ............. list speeddial for uri
speeddial add <sip-id> <sd-id> <new-uri> [<desc>] ...
........................... add a speedial (*)
speeddial rm <sip-id> <sd-id> ....... remove a speeddial (*)
speeddial help ...................... help message
- <speeddial-id>, <sd-id> must be an AoR (username@domain)
- <sip-id> must be an AoR (username@domain)
- <new-uri> must be a SIP AoR (sip:username@domain)
- <desc> a description for speeddial
-- command 'avp' - manage AVPs
avp list [-T table] [-u <sip-id|uuid>]
[-a attribute] [-v value] [-t type] ... list AVPs
avp add [-T table] <sip-id|uuid>
<attribute> <type> <value> ............ add AVP (*)
avp rm [-T table] [-u <sip-id|uuid>]
[-a attribute] [-v value] [-t type] ... remove AVP (*)
avp help .................................. help message
- -T - table name
- -u - SIP id or unique id
- -a - AVP name
- -v - AVP value
- -t - AVP name and type (0 (str:str), 1 (str:int),
2 (int:str), 3 (int:int))
- <sip-id> must be an AoR (username@domain)
- <uuid> must be a string but not AoR
-- command 'alias_db' - manage database aliases
alias_db show <alias> .............. show alias details
alias_db list <sip-id> ............. list aliases for uri
alias_db add <alias> <sip-id> ...... add an alias (*)
alias_db rm <alias> ................ remove an alias (*)
alias_db help ...................... help message
- <alias> must be an AoR (username@domain)"
- <sip-id> must be an AoR (username@domain)"
-- command 'domain' - manage local domains
domain reload ....................... reload domains from disk
domain show ......................... show current domains in memory
domain showdb ....................... show domains in the database
domain add <domain> ................. add the domain to the database
domain rm <domain> .................. delete the domain from the database
-- command 'cisco_restart' - restart CISCO phone (NOTIFY)
cisco_restart <uri> ................ restart phone configured for <uri>
-- command 'online' - dump online users from memory
online ............................. display online users
-- command 'monitor' - show internal status
monitor ............................ show server's internal status
-- command 'ping' - ping a SIP URI (OPTIONS)
ping <uri> ......................... ping <uri> with SIP OPTIONS
-- command 'ul|alias' - manage user location or aliases
ul show [<username>]................ show in-RAM online users
ul show --brief..................... show in-RAM online users in short format
ul rm <username> [<contact URI>].... delete user's usrloc entries
ul add <username> <uri> ............ introduce a permanent usrloc entry
ul add <username> <uri> <expires> .. introduce a temporary usrloc entry
-- command 'fifo'
fifo ............................... send raw FIFO command
以下为豆丁网站的相关文档:
http://www.docin.com/app/docsearch?&keyword=opensips&old_format=