首先安装前,你已经对kamailio的基本用法了解。可根据情况选择安装方式,本次安装基于Ubuntu18.04系统安装,对于16.04及一下会遇到版本问题,请自己查阅文档解决

安装第三方库

sudo apt-get install gcc flex bison libmysqlclient-dev make libcurl4-openssl-dev libxml2-dev libpcre3-dev libncurses5-dev libreadline6  libreadline-dev  e2fsprogs-dev  uuid-dev  libuuid-dev

确保数据库安装成功

第一种

可直接通过sudo apt-get install kamailio安装

配置

修改/etc/kamailio/kamctlrc,配置mysql
kamdbctl create创建mysql数据库

指定log

修改/etc/rsyslog.d/50-default.conf
#*.*;auth,authpriv.none -/var/log/syslog #注释掉这一行
*.*;auth,authpriv.none,local0.none -/var/log/syslog #新加行
if $syslogfacility-text=='local0' then -/var/log/kamailio.log #新加行
重启 systemctl restart rsyslog

 修改/etc/kamailio/kamailio.cfg 配置路由

启动kamactl start

第二种下载源码安装

下载源码包

http://www.kamailio.org/pub/kamailio/latest/src/

 解压

tar  xvf   kamailio-*_src.tar.gz

cd kamailio-*

执行下面指令生成modules.list文件

make  FLAVOUR=kamailio  cfg

 进入modules.list找到"exclude_modules",将等号后面的db_mysql删除(这里可以根据自己的需要调整编译的模块)。然后执行如下指令编译

执行指令安装

make all

sudo make install

执行过程中如果报错根据提示慢慢解决

启动文件在 /etc/local/sbin下
配置文件在 /usr/local/etc/kmailio下

配置

打开/usr/local/etc/kamailio/kamailio.cfg,添加下面几行(添加在最顶端即可):

#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB
#!define WITH_NAT
#!define WITH_DEBUG

修改 /usr/local/etc/kamailio/kamctlrc  

掉SIP_DOMAIN前的注释,并且修改成自己的服务器地址192.168.1.111(根据自己服务器的实际情况来写),我的是SIP_DOMAIN=192.168.1.111。然后去掉DBENGINE=MYSQL前的注释语句,选定mysql数据库,其他的按照如下内容来修改: 

# cat /usr/local/etc/Kamailio/kamctlrc
# $Id$
# The Kamailio configuration file for the control tools.
# Here you can set variables used in the kamctl and kamdbctl setup
# scripts. Per default all variables here are commented out, the control tools
# will use their internal default values.
## your SIP domain
SIP_DOMAIN=192.168.1.111
## chrooted directory
# $CHROOT_DIR="/path/to/chrooted/directory"
## database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, or DBTEXT, by default none is loaded
# If you want to setup a database with kamdbctl, you must at least specify
# this parameter.
DBENGINE=MYSQL
## database host
DBHOST=localhost
## database name (for ORACLE this is TNS name)
DBNAME=kamailio
# database path used by dbtext or db_berkeley
# DB_PATH="/usr/local/etc/kamailio/dbtext"
## database read/write user
DBRWUSER=kamailio
## password for database read/write user
DBRWPW="kamailiorw" ## database read only user
# DBROUSER=kamailioro
DBROUSER=kamailioro
## password for database read only user
DBROPW=kamailioro
## database super user (for ORACLE this is 'scheme-creator' user)
DBROOTUSER="root"
# user name column
USERCOL="username"
# SQL definitions
# If you change this definitions here, then you must change them
# in db/schema/entities.xml too.
# FIXME
# FOREVER="2020-05-28 21:32:15"
# DEFAULT_ALIASES_EXPIRES=$FOREVER
# DEFAULT_Q="1.0"
# DEFAULT_CALLID="Default-Call-ID"
# DEFAULT_CSEQ="13"
# DEFAULT_LOCATION_EXPIRES=$FOREVER
# Program to calculate a message-digest fingerprint
# MD5="md5sum"
# awk tool
# AWK="awk"
# If you use a system with a grep and egrep that is not 100% gnu grep compatible,
# e.g. solaris, install the gnu grep (ggrep) and specify this below.
#
# grep tool
# GREP="grep"
# egrep tool
# EGREP="egrep"
# sed tool
# SED="sed"
# tail tool
# LAST_LINE="tail -n 1"
# expr tool
# EXPR="expr"
# Describe what additional tables to install. Valid values for the variables
# below are yes/no/ask. With ask (default) it will interactively ask the user
# for an answer, while yes/no allow for automated, unassisted installs.
#
# If to install tables for the modules in the EXTRA_MODULES variable.
# INSTALL_EXTRA_TABLES=ask
# If to install presence related tables. # INSTALL_PRESENCE_TABLES=ask
# Define what module tables should be installed.
# If you use the postgres database and want to change the installed tables, then you
# must also adjust the STANDARD_TABLES or EXTRA_TABLES variable accordingly in the
# kamdbctl.base script.
# kamailio standard modules
# STANDARD_MODULES="standard acc lcr domain group permissions registrar usrloc msilo
# alias_db uri_db speeddial avpops auth_db pdt dialog dispatcher
# dialplan"
# Kamailio extra modules
# EXTRA_MODULES="imc cpl siptrace domainpolicy carrierroute userblacklist htable purple"
## type of aliases used: DB - database aliases; UL - usrloc aliases
## - default: none
# ALIASES_TYPE="DB"
## control engine: FIFO or UNIXSOCK
## - default FIFO
# CTLENGINE="FIFO"
## path to FIFO file
# OSER_FIFO="FIFO"
## check ACL names; default on (1); off (0)
# VERIFY_ACL=1
## ACL names - if VERIFY_ACL is set, only the ACL names from below list
## are accepted
# ACL_GROUPS="local ld int voicemail free-pstn"
## verbose - debug purposes - default '0'
VERBOSE=1
## do (1) or don't (0) store plaintext passwords
## in the subscriber table - default '1'
# STORE_PLAINTEXT_PW=0
## OPENSER START Options
## PID file path - default is: /var/run/Kamailio.pid
# PID_FILE=/var/run/kamailio/kamailio.pid
PID_FILE=/var/run/kamailio/kamailio.pid
## Extra start options - default is: not set
# example: start kamailio with 64MB share memory: STARTOPTIONS="-m 64"
# STARTOPTIONS=

生成kamailio的mysql数据库

# /usr/local/sbin/kamdbctl  create

启动kamilio服务 

# /usr/local/sbin/kamctl  start

可能会出现“ERROR:PID file /var/run/kamailio/kamaillio.pid does not exist---Kamailio  start failed"

这种种错误出现的原因是/var/run/路径下没有kamailio目录,手动创建一个即可,但不要生成kamailio.pid文件。

然后再开启服务试一下能否成功,如果还是不行,请按顺序检查如下内容:

(1)kamdbctlrc这个配置文件中的DBHOST处是否是127.0.0.1或者localhost,如果不是请将其修改成127.0.0.1或者localhost试试。

(2)执行“kamailio  -c”来检测配置文件是否有错误,如果有报错,请根据具体报错信息解决问题。如果出现“config file ok,exiting......”,说明配置文件没有问题了。

(3)执行“kamailio  -dddd”,看是否有ERROR输出,若有,请依据错误提示进行修改。

注册sip账号

#kamctl  add  user1  123456
#kamctl add user2 123456  

测试kamailio服务

  

Ubuntu 安装 kamailio的更多相关文章

  1. Mac OS、Ubuntu 安装及使用 Consul

    Consul 概念(摘录): Consul 是 HashiCorp 公司推出的开源工具,用于实现分布式系统的服务发现与配置.与其他分布式服务注册与发现的方案,比如 Airbnb 的 SmartStac ...

  2. ubuntu安装mysql

    好记性不如烂笔头,记录一下,ubuntu安装mysql的指令. 安装MySQL: sudo apt-get install mysql-server sudo apt-get install mysq ...

  3. ubuntu安装vim时提示 没有可用的软件包 vim,但是它被其它的软件包引用了 解决办法

    ubuntu安装vim时提示 没有可用的软件包 vim-gtk3,但是它被其它的软件包引用了 解决办法 本人在ubuntu系统安装vim  输入 sudo apt-get install vim 提示 ...

  4. docker 1.8+之后ubuntu安装指定版本docker-engine

    这边记录ubuntu安装过程,首先是官网文档 If you haven’t already done so, log into your Ubuntu instance. Open a termina ...

  5. debian/ubuntu安装桌面环境

    apt-get install xorg apt-get install gnome 然后startx ubuntu 安装Gnome桌面 1.安装全部桌面环境,其实Ubuntu系列桌面实际上有几种桌面 ...

  6. 一个ubuntu phper的自我修养(ubuntu安装)

    ubuntu安装篇 一.ubuntu下载 到ubuntu官网下载适合自己电脑配置的系统版本,此处不做展开. 二.制作USB启动盘 在windows下制作USB启动盘,工具是universal usb ...

  7. ubuntu 安装JAVA jdk的两种方法:

    ubuntu 安装jdk 的两种方式: 1:通过ppa(源) 方式安装. 2:通过官网下载安装包安装. 这里推荐第1种,因为可以通过 apt-get upgrade 方式方便获得jdk的升级 使用pp ...

  8. [其他]Ubuntu安装genymotion后unable to load VirtualBox engine

    问题: Ubuntu安装genymotion后unable to load VirtualBox engine 解决办法: 如果没有安装VirtualBox,要先安装VirtualBox. 安装Vir ...

  9. Ubuntu安装出现左上角光标一直闪解决方式

    Ubuntu安装出现左上角光标一直闪解决方式: 01下载ubunu http://cn.ubuntu.com/download/ 02.软碟通 http://pan.baidu.com/s/1qY8O ...

随机推荐

  1. PHP获取客户端的IP、地理信息、浏览器、本地真实IP

    <?php header("Content-type:text/html;charset=utf-8"); // 作用获取客户端的ip.地理信息.浏览器.本地真实IP cla ...

  2. HTML 按钮换肤

    .button2{ background-image: url(images/input-bg.jpg); width: 83px; height: 31px; border: none 0px; f ...

  3. Java NIO简单介绍(二)

    上一篇<NIO简单介绍(一)>中讲解了NIO中本地IO相关的内容,这篇重点介绍的NIO的非阻塞式网络通信 一.阻塞与非阻塞 传统的 IO 流都是阻塞式的.也就是说,当一个线程调用 read ...

  4. 安装xamp之后,appach、mysql等问题的总结

    问题一:无法启动的问题 如果他们无法启动,大多数情况是端口号被占用. 首先就是查看端口号:点击“netstart“按钮查看端口号的使用详情 如果被占用就点击"config”按钮,进行端口号的 ...

  5. ubuntu15.10下code::blocks设置运行窗口为gnome命令行

    code::blocks编译运行C++程序(F9)默认出现的运行串口在有鼠标的情况下进行粘贴还是很方便的,只要按下鼠标滑轮,位与剪切板中的数据就能粘贴到运行串口中. 但是对于用笔记本而且没有鼠标地童鞋 ...

  6. zookeeper事件监听

    原来有两张表,一张是公司的,一张的产品的,项目中用来查询,不需要增删改.现在增删改交给另一项目去维护,由他们变更时同步数据到zk,我们去取.很明显,这里需要一个监听器,每次他项目发起数据变更时,我方必 ...

  7. RK3288 dts和dtsi介绍

    Device Tree 是一种描述硬件的数据结构,它起源于 OpenFirmware(OF).在 Linux2.6 中,ARM 架构的板机硬件细节过多地被硬编码在 arch/arm/plat-xxx ...

  8. Editplus配置Java、Python、C/C++ (基于VS2010) 编译环境

    1. 为什么要配置EditPlus使其能够编译运行Java.Python.C/C++等程序? EditPlus是一款轻量级(大约2M)的文本编辑器,实际开发中,只需要关联相应的编译工具就可以化身为一个 ...

  9. 关于vim搜索/替换功能的两条配置

    之前是直接照着这篇的配置的强大的vim配置文件 自己也只是对vim新建文件修改文件的哪个函数SetTitle()做了点修改,毕竟用vim只写C/C++和python.shell. 没想到今天在用vim ...

  10. scanf在竞赛中的技巧总结ing

    前言 当输入流是一个字符串,我们需要在其中提取我们所需要的数值时,我们可以在读入阶段就完成数据的筛选工作. 使用方法 scanf("%ns", str); 表示读取长度为n的字符串 ...