kamailio:install:3.3.x-from-git-centos5x

Install And Maintain Kamailio (OpenSER) v3.3.x From GIT on CentOS 5.x

Main author:
   Elena-Ramona Modroiu <ramona (at) asipto.com>

This is a step by step tutorial about how to install and maintain Kamailio (OpenSER) using the sources from GIT on CentOS 5.x.

Using the GIT, you get access to the latest code very quickly.

This document focuses on Kamailio (OpenSER) v3.3.x with MySQL support, using CentOS 5.5 system - should work more or less in the same way with CentOS 5.3 or 5.4 as well as CentOS 6.

Kamailio 3.3.0 was released on June 18, 2012:

Note that over the time, minor releases (that include bug fixes only) such as v3.3.1, v3.1.2 a.s.o. will be out – this tutorial will be valid for them.

Prerequisites

GIT

You need at least git verson 1.5.x and might not be available on your CentOS installation, if it is too old. In case git is not available on your yum repository, then install Fedora repository for enterprise release.

On CentOS i386, do:

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm

On CentOS x86_64, do:

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm

Then install using yum:

yum install git

An alternative is to install rpmforge repository, see more at:

Of course, yet another option, you can also install it from sources, download it from:

Then compile and make install.

Dependencies

  • gcc
  • make
  • flex
  • bison
  • mysql-server
  • mysql-client
  • mysql-devel

Download sources

Create the directory on the file system where to store the sources.

  mkdir -p /usr/local/src/kamailio-3.3
  cd /usr/local/src/kamailio-3.3

Download the sources from GIT using the following commands.

  git clone --depth 1 git://git.sip-router.org/sip-router kamailio
  cd kamailio
  git checkout -b 3.3 origin/3.3

Installation

Generate the config for Makefile system and include MySQL connector module for installation:

make FLAVOUR=kamailio include_modules="db_mysql" cfg
You have to keep FLAVOUR=kamailio every time you generate the makefile config in order to build kamailio.

If you want other modules which are not enabled by default to be compiled, add them in include_modules, separated by whitespace.

Compile and install:

make all
make install

Installation details

The binaries and executable scripts were installed in:

  /usr/local/sbin

These are:

  • kamailio - Kamailio (OpenSER) server
  • kamdbctl - script to create and manage the Databases
  • kamctl - script to manage and control Kamailio (OpenSER) server
  • sercmd - CLI - command line tool to interface with Kamailio (OpenSER) 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 'bash', open '/root/.bash_profile' and at the end add:

  PATH=$PATH:/usr/local/sbin
  export PATH

Kamailio (OpenSER) modules are installed in:

  /usr/local/lib/kamailio/modules/
  /usr/local/lib/kamailio/modules_k/

The documentation and readme files are installed in:

  /usr/local/share/doc/kamailio/

The man pages are installed in:

  /usr/local/share/man/man5/
  /usr/local/share/man/man8/

The configuration file was installed in:

  /usr/local/etc/kamailio/kamailio.cfg

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

Locate DBENGINE variable and set it to MYSQL:

DBENGINE=MYSQL

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:

  /usr/local/sbin/kamdbctl create

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 'openser' 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 MySQL:

- openser - (with default password 'openserrw') - user which has full access rights to 'openser' database

- openserro - (with default password 'openserro') - user which has read-only access rights to 'openser' database

Do change the passwords for these two users to something different that the default values that come with sources.

Configuration file

To fit your requirements for the VoIP platform, you have to edit the configuration file.

  /usr/local/etc/kamailio/kamailio.cfg

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:

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

If you changed the password for the 'openser' user of MySQL, you have to update the value for 'db_url' parameters.

You can browse kamailio.cfg online on GIT repository.

init.d script

The init.d script can be used to start/stop the Kamailio (OpenSER) server in a nicer way. A sample of init.d script for Kamailio (OpenSER) is provided at:

/usr/local/src/kamailio-3.3/kamailio/pkg/kamailio/rpm/kamailio.init

Just copy the init file into the /etc/init.d/kamailio. Then change the permissions:

  chmod 755 /etc/init.d/kamailio 

and edit the file updating the $KAM value:

  KAM=/usr/local/sbin/kamailio

You need also setup the init.d default configuration file in the /etc/default/ directory. This file can be found at:

  /usr/local/src/kamailio-3.3/kamailio/pkg/kamailio/rpm/kamailio.default

You need to rename the file to 'kamailio' after you've copied it. Then edit this file and check if RUN_KAMAILIO=yes. Edit the other options at your convenience.

  /etc/default/kamailio 

Default setting is to run Kamailio as user “kamailio” and group “kamailio”, so you need to create the user:

/usr/sbin/groupadd -r kamailio
/usr/sbin/useradd -r -g kamailio -s /bin/false -c "Kamailio daemon" -d \
                  /usr/local/lib/kamailio kamailio

Then you can start/stop Kamailio (OpenSER) using the following commands:

  /etc/init.d/kamailio start
  /etc/init.d/kamailio stop

Running

Add SIP users using 'kamctl', prototype:

kamctl add <username> <password> <email>

For example:

kamctl add test testpasswd test@mysipserver.com

If you are asked for SIP_DOMAIN environment variable do one of the following option.

  1.
  export SIP_DOMAIN=mysipserver.com

  2.
  edit '/usr/local/etc/kamailio/kamctlrc' and set:
  SIP_DOMAIN=mysipserver.com

See Also


100%


Copyright 2010-2020 Asipto.com