海南省住房和城乡建设厅官网网站,wordpress后台管理界面地址,wordpress 如何 删除授权,做网站需要注意些什么文章目录1. OpenSIPS 源码下载2. 工具准备3. 编译安装4. opensips-cli 工具安装5. 启动 OpenSIPS 实例1. OpenSIPS 源码下载
使用以下命令即可下载 OpenSIPS 的源码#xff0c;笔者下载的是比较稳定的 3.1 版本#xff0c;读者有兴趣也可前往 官方传送门 sudo git clone htt…
文章目录1. OpenSIPS 源码下载2. 工具准备3. 编译安装4. opensips-cli 工具安装5. 启动 OpenSIPS 实例1. OpenSIPS 源码下载
使用以下命令即可下载 OpenSIPS 的源码笔者下载的是比较稳定的 3.1 版本读者有兴趣也可前往 官方传送门 sudo git clone https://github.com/OpenSIPS/opensips.git -b 3.1 opensips-3.1 2. 工具准备
在本地机器上编译 OpenSIPS 源码可能会有许多工具缺失根据笔者的经验可以先执行以下命令下载相关工具。如果在编译过程中出现类似 make : flex: Command not found 这种报错一般是本地缺少对应的软件或者依赖直接按照提示使用 yum 命令下载相应工具即可如本例可使用 yum install -y flex 命令 sudo yum install -y mysql-devel libmicrohttpd-devel bison flex 3. 编译安装 进入 OpenSIPS 源码根目录执行 sudo make menuconfig 命令则如下进入编译时配置界面该界面使用右箭头进入下一级左箭头返回上一级空格选中 笔者进入菜单 Configure Compile Options -- Configure Excluded Modules 空格勾选 db_mysql 和 httpd然后返回 Configure Compile Options -- Save Changes 回车保存配置。最后返回上一级菜单回车选中 Compile And Install OpenSIPS 开始编译安装 OpenSIPS 编译完成后会回到菜单界面回车选中 Exit Save All Changes 即可完成安装。由于笔者指定了 mysql 作为 OpenSIPS 的数据库则需要使用 opensips-cli 工具初始化数据库后才能启动 OpenSIPS 实例
4. opensips-cli 工具安装 该工具需要匹配 OpenSIPS 版本读者可前往 官方传送门 选择相应的参数最终确定一个命令并终端执行。笔者是 CentOS 7 系统的 3.1 版本 OpenSIPS故执行以下命令即可 sudo yum install https://yum.opensips.org/3.1/releases/el/7/x86_64/opensips-yum-releases-3.1-6.el7.noarch.rpm 以上命令执行完成执行下面的命令安装 opensips-cli 工具 sudo yum install -y opensips-cli 安装完成后执行命令 vim ~/.opensips-cli.cfg 在当前用户目录下本地新增一个 opensips-cli 配置文件读者可复制以下内容但需要自行配置关键的数据库连接串信息 [default]
log_level: WARNING
prompt_name: opensips-cli
prompt_intro: Welcome to OpenSIPS Command Line Interface!
prompt_emptyline_repeat_cmd: False
history_file: ~/.opensips-cli.history
history_file_size: 1000
output_type: pretty-print
fifo_file: /tmp/opensips_fifo
communication_type: http#database_modules: acc clusterer dialog dialplan dispatcher domain rtpproxy usrloc
database_modules: ALL
# 管理员账号连接串自行修改
database_admin_url: mysql://root:123456localhost:3306
# 普通账户连接串自行修改
database_url: mysql://root:123456localhost:3306
database_name: opensips
# 修改成 opensips 源码路径下的scripts
database_schema_path: /home/root/opensips-3.1/scripts以上步骤执行完执行命令 opensips-cli -x database create 创建 OpenSIPS 依赖的数据库表 OpenSIPS 实例启动后可以通过执行 opensips-cli -i default 连接到 OpenSIPS在命令界面查看 OpenSIPS 实例信息读者如有兴趣可前往 官方传送门 了解支持的命令
5. 启动 OpenSIPS 实例 经过以上步骤OpenSIPS 依赖的数据库表已经建好接下来使用命令 vim ~/opensips.cfg 在当前用户目录创建 OpenSIPS 配置文件读者可以复制以下内容自行修改数据库连接及监听 IP 端口等内容 ####### Global Parameters #########log_level4log_stderrornolog_facilityLOG_LOCAL0/* uncomment the following lines to enable debugging */#debug_modeyes/* uncomment the next line to enable the auto temporary blacklisting of
not available destinations (default disabled) */#disable_dns_blacklistno/* uncomment the next line to enable IPv6 lookup after IPv4 dns
lookup failures (default disabled) */#dns_try_ipv6yes/* comment the next line to enable the auto discovery of local aliases
based on reverse DNS on IPs */auto_aliasesnomhomedyes#alias35.187.154.207listenudp:127.0.0.1:8060 # CUSTOMIZE MEsocketws:127.0.0.1:8090 # CUSTOMIZE ME####### Modules Section #########set module pathmpath/usr/local//lib64/opensips/modules/#### udp protocol moduleloadmodule proto_udp.soloadmodule proto_ws.somodparam(proto_ws, ws_port, 8090)#### SIGNALING moduleloadmodule signaling.so#### StateLess moduleloadmodule sl.so#### Transaction Moduleloadmodule tm.somodparam(tm, fr_timeout, 5)modparam(tm, fr_inv_timeout, 30)modparam(tm, restart_fr_on_each_reply, 0)modparam(tm, onreply_avp_mode, 1)#### Record Route Moduleloadmodule rr.so/* do not append from tag to the RR (no need for this script) */#modparam(rr, append_fromtag, 0)modparam(rr, enable_double_rr, 1)#### MAX ForWarD moduleloadmodule maxfwd.so#### SIP MSG OPerationS moduleloadmodule sipmsgops.so#### MYSQL moduleloadmodule db_mysql.so#### drouting moduleloadmodule drouting.somodparam(drouting, db_url,mysql://root:123456localhost:3306/opensips)modparam(drouting, default_group, 1)loadmodule httpd.somodparam(httpd, port, 8888)loadmodule mi_fifo.soloadmodule mi_http.soloadmodule acc.somodparam(acc, early_media, 0)modparam(acc, report_cancels, 0)modparam(acc, detect_direction, 0)modparam(acc, db_url,mysql://root:123456localhost:3306/opensips) # CUSTOMIZE ME#### USeR LOCation moduleloadmodule usrloc.somodparam(usrloc, nat_bflag, NAT)modparam(usrloc, db_mode, 2)modparam(usrloc, db_url,mysql://root:123456localhost:3306/opensips) # CUSTOMIZE ME#### REGISTRAR moduleloadmodule registrar.so#### AUTHentication modulesloadmodule auth.soloadmodule auth_db.somodparam(auth_db, calculate_ha1, 1)modparam(auth_db|uri, db_url,mysql://root:123456localhost:3306/opensips) # CUSTOMIZE MEmodparam(auth_db, load_credentials, )#### Nathelper protocolloadmodule nathelper.somodparam(registrar|nathelper, received_avp, $avp(rcv))#### DIALOG moduleloadmodule dialog.somodparam(dialog, dlg_match_mode, 1)modparam(dialog, default_timeout, 21600) # 6 hours timeoutmodparam(dialog, db_mode, 1)modparam(dialog, db_url,mysql://root:123456localhost:3306/opensips) # CUSTOMIZE ME# main request routing logicroute{if (!mf_process_maxfwd_header(10)) {send_reply(483,Too Many Hops);exit;}# 有 totag 意味着dialog已经建立if (has_totag()) {# handle hop-by-hop ACK (no routing required)if ( is_method(ACK) t_check_trans() ) {t_relay();exit;}# sequential request within a dialog should# take the path determined by record-routingif ( !loose_route() ) {# we do record-routing for all our traffic, so we should not# receive any sequential requests without Route hdr.send_reply(404,Not here);exit;}#loose_route();if (is_method(BYE)) {# do accounting even if the transaction faileddo_accounting(db,failed);}# 这里lookup是为了转成注册到opensips 的ua对应r-urilookup(location);# route it out to whatever destination was set by loose_route()# in $du (destination URI).route(relay);exit;}# handle cancel and re-transmissionsif ( is_method(CANCEL) ) {if ( t_check_trans() )t_relay();exit;}# absorb retransmissions, but do not create transactiont_check_trans();if ( !(is_method(REGISTER) ) ) {if (!is_from_gw(1)) {# authenticate if from local subscriber# authenticate all initial non-REGISTER request that pretend to be# generated by local subscriber (domain from FROM URI is local)if (!proxy_authorize(, subscriber)) {proxy_challenge();exit;}consume_credentials();# caller authenticated}}# preloaded route checkingif (loose_route()) {xlog(L_ERR,Attempt to route with preloaded Routes [$fu/$tu/$ru/$ci]);if (!is_method(ACK))send_reply(403,Preload Route denied);exit;}# record routingif (!is_method(REGISTER|MESSAGE))record_route();# account only INVITEsif (is_method(INVITE)) {# create dialog with timeoutif ( !create_dialog(B) ) {send_reply(500,Internal Server Error);exit;}# 通过动态路由找到合适的duif (!do_routing()) {if (!lookup(location)) {send_reply(404,Not Found);exit;}}#$du sip:0.0.0.0:8060;do_accounting(db);}if (is_method(REGISTER)) {# authenticate the REGISTER requestsif (!www_authorize(, subscriber)) {www_challenge();exit;}fix_nated_register();setbflag(NAT);if (!save(location))sl_reply_error();exit;}# requests for my domainif (is_method(PUBLISH|SUBSCRIBE)) {send_reply(503, Service Unavailable);exit;}if ($rUNULL) {# request with no Username in RURIsend_reply(484,Address Incomplete);exit;}do_accounting(db,missed);route(relay);}route[relay] {# for INVITEs enable some additional helper routesif (is_method(INVITE)) {rtpproxy_offer();t_on_branch(per_branch_ops);t_on_reply(handle_nat);t_on_failure(missed_call);}if (!t_relay()) {send_reply(500,Internal Error);}exit;}branch_route[per_branch_ops] {xlog(new branch at $ru\n);}onreply_route[handle_nat] {rtpproxy_answer();fix_nated_contact();xlog(test);}failure_route[missed_call] {if (t_was_cancelled()) {exit;}}配置脚本准备好后执行 opensips -f ~/opensips.cfg -D 命令启动OpenSIPS 实例该命令中 -f 用于指定启动配置文件-D 用于指定前台启动模式