Kamailio v5.1 - Install Guide
Guide to install Kamailio SIP Server v5.1 (stable) from Git repository.
For more about Kamailio Project visit: kamailio.org.
This is a step by step tutorial about how to install and maintain Kamailio SIP server v5.1.x using the sources downloaded from GIT repository.
This document focuses on Kamailio v5.1.x with MySQL support, using a Debian stable system.
To be able to follow the guidelines from this document you need
The following packages are required before proceeding to the next steps.
- git client: apt-get install git-core - it is recommended to have a recent version, if your Linux distro has an old version, you can download newer one from git-scm.com
- gcc and g++ compilers: apt-get install gcc g++
- flex - apt-get install flex
- bison - apt-get install bison
- libmysqlclient-dev - apt-get install libmysqlclient-dev
- make - apt-get install make
- if you want to enable more modules, some of them require extra libraries:
- libssl - apt-get install libssl-dev
- libcurl - apt-get install libcurl4-openssl-dev
- libxml2 - apt-get install libxml2-dev
- libpcre3 - apt-get install libpcre3-dev
Important Note: starting with version
4.3.0, Kamailio uses the directory
/var/run/kamailio/ for creating FIFO and UnixSocket RPC control files. You may have
to complete the section related to installation of
init.d script for creating
/var/run/kamailio even if you plan to start Kamailio manually from command line.
The alternative is to set different paths via parameters of jsonrpcs
and ctl modules.
Note: g++ compiler is needed for couple of modules that link to C++ libraries, such as app_sqlang, phonenum or ndb_cassandra.
Getting Sources From GIT
First of all, you have to create a directory on the file system where the sources will be stored.
mkdir -p /usr/local/src/kamailio-5.1
Download the sources from GIT using the following commands.
git clone --depth 1 --no-single-branch https://github.com/kamailio/kamailio kamailio
git checkout -b 5.1 origin/5.1
Note: if your git client version does not support --no-single-branch command line parameter, then just remove it.
The first step is to generate build config files.
Next step is to enable the MySQL module. Edit modules.lst file:
nano -w src/modules.lst
Add db_mysql to the variable include_modules.
Save the modules.lst and exit.
NOTE: this is one mechanism to enable modules which are not compiled by default, such as lcr, dialplan, presence -- add the modules to include_modules variable inside the modules.lst file, like:
include_modules= db_mysql dialplan
Alternative is to set
include_modules variable with the list of extra modules
to be included for compilation when building
make include_modules="db_mysql dialplan" cfg
NOTE: If you want to install everything in one directory (so you can delete
all installed files at once), say
/usr/local/kamailio-5.1l, then set
variable to the install path in
make cfg ... command:
make PREFIX="/usr/local/kamailio-5.1" include_modules="db_mysql dialplan" cfg
More hints about
Makefile system at:
Once you added the mysql module to the list of enabled modules, you can compile Kamailio:
You can get full compile flags output using:
make Q=0 all
When the compilation is ready, install Kamailio with the following command:
What And Where Was Installed
The binaries and executable scripts were installed in:
- kamailio - Kamailio SIP server
- kamdbctl - script to create and manage the Databases
- kamctl - script to manage and control Kamailio SIP server
- kamcmd - CLI - command line tool to interface with Kamailio SIP server
To be able to use the binaries from command line, make sure that
/usr/local/sbin is set in
PATH environment variable. You can check that with
echo $PATH. If not and you are using
at the end add:
Kamailio modules are installed in:
Note: On 64 bit systems,
/usr/local/lib64 may be used.
The documentation and readme files are installed in:
The man pages are installed in:
The configuration file was installed in:
NOTE:: In case you set the PREFIX variable in
make cfg ... command, then
replace /usr/local in all paths above with the value of
PREFIX in order to
locate the files installed.
Create MySQL Database
To create the
MySQL database, you have to use the database setup script.
First edit kamctlrc file to set the database server type:
nano -w /usr/local/etc/kamailio/kamctlrc
DBENGINE variable and set it to
You can change other values in kamctlrc file, at least it is recommended to change the default passwords for the users to be created to connect to database.
Once you are done updating kamctlrc file, run the script to create the database used by Kamailio:
You can call this script without any parameter to get some help for the usage.
You will be asked for the domain name Kamailio is going to serve (e.g.,
mysipserver.com) and the password of the
root MySQL user. The script will
create a database named
kamailio containing the tables required by Kamailio.
You can change the default settings in the kamctlrc file mentioned above.
The script will add two users in
kamailio - (with default password
kamailiorw) - user which has full access rights to
kamailioro - (with default password
kamailioro) - user which has read-only access rights to
IMPORTANT: do change the passwords for these two users to something different that the default values that come with sources.
Edit Configuration File
To fit your requirements for the VoIP platform, you have to edit the configuration file.
Follow the instruction in the comments to enable usage of MySQL. Basically you have to add several lines at the top of config file, like:
If you changed the password for the
kamailio user of MySQL, you have to update
the value for
You can browse kamailio.cfg online on GIT repository.
The init.d Script
The init.d script can be used to start/stop the
Kamailio server in a nicer way.
A sample of init.d script for
Kamailio is provided at:
Just copy the init file to
/etc/init.d/kamailio. Then change the permissions:
chmod 755 /etc/init.d/kamailio
then edit the file updating the
You need also setup a configuration file in the
This file can be found at:
You need to rename the file to
kamailio after you've copied it. Then edit this
file and set
RUN_KAMAILIO=yes. Edit the other options at your convenience.
Create the directory for pid file:
mkdir -p /var/run/kamailio
Default setting is to run Kamailio as user
kamailio and group
For that you need to create the user:
adduser --quiet --system --group --disabled-password \
--shell /bin/false --gecos "Kamailio" \
--home /var/run/kamailio kamailio
# set ownership to /var/run/kamailio
chown kamailio:kamailio /var/run/kamailio
Then you can start/stop Kamailio using the following commands:
Ready To Rock
Now everything is in place. You can start the VoIP service, creating new accounts and setting the phones.
A new account can be added using
kamctl tool via:
# kamctl add username password email
Or try without the email:
kamctl add test testpasswd firstname.lastname@example.org
If you are asked for
SIP_DOMAIN environment variable do one of the following
- run in terminal:
- or edit
The maintenance process is very simple right now. You have to be user
execute following commands:
git pull origin
Now you have the latest Kamailio devel running on your system.
When To Update
Notification about GIT commits are sent to the mailing list: email@example.com. Each commit notification contains the reference to the branch where the commit has been done. If the commit message contains the lines:
then an update has been made to Kamailio devel version and it will be available to the public GIT in no time.
Questions about how to use Kamailio and the content of kamailio.cfg can be addressed via email to:
More documentation resources can be found at:
Anyone is welcome to contribute to this document. It is recommended to make a pull request via:
This version of the document is in GIT branch
Errors and other issues can be reported via the tracker at: