How to install Kamailio 5 from sources on Debian 10

Kamailio is an open-source SIP server, previously known as OpenSER. It is able to handle thousands of call setups per second and as such can be used to build high-grade applications for VoIP and real-time communications. Kamailio can be used as a SIP registrar, proxy/redirect server, SIP security firewall and support presence, RADIUS accounting and authorization. It supports various storage backends like SQL/NoSQL and many more.

Kamailio was released all the way back in 2002 under the name of OpenSER. Today, Kamailio is used by large scale internet service providers to provide public telephony services.


We will be installing Kamailio 5.4, from the sources, which is the latest release at the time of writing. For this tutorial Debian 10 will be used as the host operating system. The following is the brief overview of the steps we will be performing to install Kamailio

  1. Pre-requisite steps
  2. Downloading the source
  3. Configuring and compiling
  4. Database Configuration
  5. Miscellaneous

Step 1: Pre-Requisite

First, Let us make sure that our packages and OS is up-to-date.

apt update && apt upgrade

Next we will install the dependencies which are required to be fulfilled for the proper functioning of Kamailio and it’s modules

apt install git gcc g++ flex bison libmariadb-dev libmariadb-dev-compat make autoconf pkg-config libssl-dev libcurl4-openssl-dev libxml2-dev libpcre3-dev

Next up, we will install and configure MariaDB server to use it as a database back-end for our Kamailio server.

apt install mariadb-server
systemctl enable mariadb
systemctl start mariadb

Step 2: Downloading the Source

Let’s begin with downloading the latest Kamailio release i.e 5.4 on our Host from their official GitHub repository. It is possible that a newer version is released when you are installing. You can look at their official website for the latest version and change the branch accordingly.

cd /usr/src && git clone -b 5.4

Switch to the kamailio directory and we will be good to go.

cd kamailio

Step 3: Configuring and Compiling

Now since all the dependencies of Kamailio server and it’s modules has been installed, we can now configure it . First step is to generate build configs. Since we also require to compile the module for MySQL database, we will add the following argument as well. If you want to enable the support of other modules like radius, cgrates etc, you have to install the dependencies first for those modules and then add those in make command.

make include_modules="db_mysql tls" cfg

Now we will compile and install Kamailio 5 on Debian 10 alongside the modules selected.

make all
make install

After the successful compilation and installation of kamailio on debian 10. All the binaries and executable scripts can be found in /usr/local/sbin directory.

Step 4: Database Configuration

In step 1, we installed MariaDB with other dependencies. Now we will use the provided database setup script to create kamailio database along with it’s tables. First edit the kamctlrc file and set the DBENGINE to MySQL. Also, don’t forget to change the default password for users in the same file.

nano /usr/local/etc/kamailio/kamctlrc

Once we are done with updating the kamctlrc file, we can execute the script to create the required database. For the purpose of this tutorial we used utf32 as the character set for our database.

/usr/local/sbin/kamdbctl create

The script will also create two users –

  • kamailio – A user to manage the kamailio database. The default password is kamailiorw
  • kamailioro – A user with permissions to only read the kamailio database. The default password is kamailioro.

Step 5: Miscellaneous

To run Kamailio, we are provided with two methods. Init.d script and systemd. For this tutorial we will use the systemd method. To enable it we will run the following make command, make sure you are inside /usr/src/kamailio directory before executing this command.

make install-systemd-debian

First we will run the daemon reload command to reload all the units.

systemctl daemon-reload

Now we can simply use the following commands to run/stop/enable the Kamailio service.

systemctl start kamailio
systemctl stop kamailio
systemctl enable kamailio

Now we can check the using the netstat utility if our Kamailio is listening on port 5060.

As you can see in the above image, Kamailio is listening on port 5060. With this we have Kamailio 5 up and running on Debian 10

Thanks for reading, if you face any issue during the installation you can use the comments section below and consider subscribing to our newsletter.

3 Replies to “How to install Kamailio 5 from sources on Debian 10”

  1. Hello. I installed Kamailio via repository in Debian 10. Then I added the following lines to the beginning of the “kamailio.cfg” file:

    #!define WITH_MYSQL
    #!define WITH_AUTH
    #!define WITH_USRLOCDB

    After the above settings, I edited the values inside the photo in the “kamctl” file.

    Then I typed “kamdbctl create” command. Database and other items were created successfully without any errors.

    But when I type “systemctl restart kamailio” command, I get a journalctl error. After I run the journalctl -xe command, it displays the following errors.

    Where is the problem?

  2. Nice guide. I have followed both Asterisk and Kamailio guides and i got two systems with working versions of Asterosk and Kamailio. I would like to integrate them. So all users will register to Kamailio and if they need supplementary services it will move to Asterisk. Could you guide us how to make it please?

Leave a Reply

Your email address will not be published. Required fields are marked *