####################################
#安装kamailio准备
#####################################
sudo apt-get install git-core
sudo apt-get install gcc
sudo apt-get install flex
sudo apt-get install bison
sudo apt-get install libmysqlclient-dev
sudo apt-get install make
sudo apt-get install mysql-server mysql-client
#如果想使用更多的模块,下面的库会被用到
sudo apt-get install libssl-dev
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libxml2-dev
sudo apt-get install libpcre3-dev
#########################################
#从Git获得源代码
##########################################
#新建一个名为kamailio-5.1的文件夹
sudo mkdir -p /usr/local/src/kamailio-5.1
cd /usr/local/src/kamailio-5.1
#用下面的命令从Git下载源码
sudo git clone --depth 1 --no-single-branch https://github.com/kamailio/kamailio kamailio
cd kamailio
sudo git checkout -b 5.1 origin/5.1
#注:如果你的git客户端版本不支持--no-single-branch命令行参数,不用这个就行
#########################################
#开始编译
##########################################
#
#产生编译配置文件
#
sudo make cfg
#在include_modules=后面加上db_mysql,include_modules= db_mysql,保存退出
sudo nano -w src/modules.lst #vim src/modules.lst
#
#编译kamailio
#
sudo make all
#
#安装kamailio
#
sudo make install
#查看环境变量中是否有kamailio的安装路径/usr/local/sbin
echo $PATH
#如果没有就用bash脚本打开/root/.bash_profile,在末尾添加
PATH=$PATH:/usr/local/sbin
export PATH
#
#建立MySQL数据库
#
# 将kamctlrc中的DBENGINE变量设置成MYSQL,即DBENGINE=MYSQL
sudo nano -w /usr/local/etc/kamailio/kamctlrc
其他的设置参考http://blog.csdn.net/laughing_cui/article/details/50614048
如下:其中219.216.72.72是我的IP地址
# 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=219.216.72.72
## 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=
#建立MySQL数据库
/usr/local/sbin/kamdbctl create
###可能会有一系列的警告,说密码在命令行不安全,不用管。安装mysql各种东西,一直按y同意安装即可。
#
#编辑配置文件
#
sudo nano -w /usr/local/etc/kamailio/kamailio.cfg
########在开头加入下面三行
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB
#
#使用kamailio
#打开kamailio
##先进入root模式,否则kamailio进入会失败
sudo su
/usr/local/sbin/kamctl start
##
##添加用户kamctl add username1 password1
kamctl add 10000 123456
kamctl add 10001 123456
##关闭kamailio服务器
/usr/local/sbin/kamctl stop
#
#init.d脚本可以方便的开启/关闭kamailio,相关可以参照官网的指示https://kamailio.org/docs/tutorials/5.1.x/kamailio-install-guide-git/
#
测试的话,打开kamailio并添加两个用户后,在同一个局域网下,找两个机器,安装X-Lite,我用的是5.1.0_89322版本,进行SIP用户注册,就可以打电话了,网上有很多教程的。
#####################################2018/07/23更新######################################
kamailio连接其他主机mysql
修改 kamctlrc
vim /usr/local/etc/kamailio/kamctlrc
修改数据库的用户名以及密码
(按mysql的密码强度等级设置,出现密码强度不符合规范问题的话,参考:
https://blog.csdn.net/u014236541/article/details/78244601
https://blog.csdn.net/maxsky/article/details/51171474
https://www.cnblogs.com/ivictor/p/5142809.html
)
修改kamailio配置文件
vim /usr/local/etc/kamailio/kamailio.cfg