– Kamailio SIP Server –

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
install:kamailio-devel-from-git [2011/09/05 10:55]
85.178.70.62 [Install And Maintain Kamailio (OpenSER) Devel From GIT]
install:kamailio-devel-from-git [2011/09/05 10:56] (current)
85.178.70.62 [Notes on Kamailio vs SER]
Line 1: Line 1:
 +======= Install And Maintain Kamailio (OpenSER) Devel From GIT =======
  
 +<​code>​
 +Main author:
 +   ​Daniel-Constantin Mierla <miconda (at) gmail.com>​
 +</​code>​
 +
 +This is a step by step tutorial about how to install and maintain Kamailio (OpenSER) using the sources from GIT - the choice for those willing to write code for Kamailio or to try the new features to be released in the future with the next major stable version.
 +
 +This document focuses on Kamailio (OpenSER) devel (at this time upcoming v3.2.0) with MySQL support, using a Debian unstable system.
 +
 +
 +==== Notes on Kamailio vs SER ====
 +
 +Since version 3.0.0, Kamailio and SER are built from same source code, meaning that they are more or less same application.
 +
 +The difference is in few compile time options that are enabled in Kamailio. These are:
 +  * enable Kamailio-style statistics framework - if you don't know what they are, then you don't need them anyhow
 +  * enable application server extensions in TM module needed only by seas module - unless you use seas module, these extensions make no difference to you
 +
 +You can build as well SER with these extensions by editing the Makefiles. Also, all modules work with Kamailio-style statistics framework disabled.
 +
 +===== 1. Prerequisites =====
 +
 +To be able to follow the guidelines from this document you need **root** access.
 +
 +The following packages are required before proceeding to the next steps.
 +
 +  * __git__ client: apt-get install git-core - it is recommended to have the latest version, which might not be part of the distribution yet, but you can get it from: http://​git-scm.com/​
 +  * __gcc__ compiler: apt-get install gcc
 +  * __flex__ - apt-get install flex
 +  * __bison__ - apt-get install bison
 +  * __libmysqlclient15-dev__ - apt-get install libmysqlclient15-dev
 +  * __make__ - apt-get install make
 +  * if you want to enable more modules, some of them require extra libraries:
 +    * __libcurl__ - apt-get install libcurl4-openssl-dev
 +    * __libxml2__ - apt-get install libxml2-dev
 +    * __libpcre3__ - apt-get install libpcre3-dev
 +
 +===== 2. Getting sources from GIT =====
 +
 +First of all, you have to create a directory on the file system where the sources will be stored. ​
 +
 +<​code>​
 +  mkdir -p /​usr/​local/​src/​kamailio-devel
 +  cd /​usr/​local/​src/​kamailio-devel
 +</​code>​
 +
 +Download the sources from GIT using the following commands.
 +
 +<​code>​
 +  git clone --depth 1 git://​git.sip-router.org/​sip-router kamailio
 +  cd kamailio
 +</​code>​
 +
 +
 +===== 3.Tuning Makefiles =====
 +
 +The **most important and first step** is to set build flavour to **kamailio**.
 +
 +<​code>​
 +  make FLAVOUR=kamailio cfg
 +</​code>​
 +
 +If you forget to set the flavour to kamailio, the default build is SER (note that SER flavour does not enable by default Kamailio'​s statistics support and application server extensions in tm module needed only by **seas** module, otherwise is the same application,​ just using a different name).
 +
 +Next step is to enable the MySQL module.
 +
 +<​code>​
 +  nano -w modules.lst
 +</​code>​
 +
 +Remove **db_mysql** from the variable **exclude_modules**.
 +
 +Save the **modules.lst** and exit.
 +
 +NOTE: this is the mechanism to enable modules which are not compiled by default, such as lcr, dialplan, presence -- remove the module from **exclude_modules** variable inside the **modules.lst** file.
 +
 +Alternative is to use '​include_modules'​ variable to specify what extra modules to be included for compilation:​
 +
 +<​code>​
 +make FLAVOUR=kamailio ​ include_modules="​db_mysql dialplan"​ cfg
 +</​code>​
 +
 +If you want to install everything in one directory (so you can delete all installed files at once), say /​usr/​local/​kamailio-devel,​ then use:
 +
 +<​code>​
 +make PREFIX="/​usr/​local/​kamailio-devel"​ FLAVOUR=kamailio ​ include_modules="​db_mysql dialplan"​ cfg
 +</​code>​
 +
 +
 +More hints about Makefile system at: 
 +  * http://​sip-router.org/​wiki/​tutorials/​makefile-system
 +
 +===== 4. Compile Kamailio (OpenSER) =====
 +
 +Once the mysql module was removed from excluded modules list, you can compile Kamailio (OpenSER).
 +
 +<​code>​
 +  make all
 +</​code>​
 +
 +You can get full compile flags output using:
 +
 +<​code>​
 +  make Q=0 all
 +</​code>​
 +
 +===== 5. Install Kamailio (OpenSER) =====
 +
 +When the compilation is ready, install Kamailio (OpenSER) with the following command:
 +
 +<​code>​
 +  make install
 +</​code>​
 +
 +===== 6. What and where was installed =====
 +
 +The binaries and executable scripts were installed in:
 +
 +<​code>​
 +  /​usr/​local/​sbin
 +</​code>​
 +
 +
 +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:
 +
 +<​code>​
 +  PATH=$PATH:/​usr/​local/​sbin
 +  export PATH
 +</​code>​
 +
 +Kamailio (OpenSER) modules are installed in:
 +
 +<​code>​
 +  /​usr/​local/​lib/​kamailio/​modules/​
 +  /​usr/​local/​lib/​kamailio/​modules_k/​
 +</​code>​
 +
 +The documentation and readme files are installed in:
 +
 +<​code>​
 +  /​usr/​local/​share/​doc/​kamailio/​
 +</​code>​
 +
 +The man pages are installed in:
 +
 +<​code>​
 +  /​usr/​local/​share/​man/​man5/​
 +  /​usr/​local/​share/​man/​man8/​
 +</​code>​
 +
 +The configuration file was installed in:
 +
 +<​code>​
 +  /​usr/​local/​etc/​kamailio/​kamailio.cfg
 +</​code>​
 +
 +===== 7. Create MySQL database =====
 +
 +To create the MySQL database, you have to use the database setup script:
 +
 +<​code>​
 +  /​usr/​local/​sbin/​kamdbctl create
 +</​code>​
 +
 +In order to create the database you need to specify the wanted db type (DBENGINE=MYSQL) in the 
 +
 +<​code>​
 +  /​usr/​local/​etc/​kamailio/​kamctlrc
 +</​code>​
 +
 +file. Call this script without any parameter to get some help for the usage. You will be asked for the domain name Kamailio (OpenSER) 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 (OpenSER). You can change the default settings in the kamctlrc file mentioned above.
 +
 +The script will add two users in MySQL:
 +
 +- **openser** - having the password '​openserrw',​ user which has full access rights to '​openser'​ database
 +
 +- **openserro** - having the password '​openserro',​ user which has read-only access rights to '​openser'​ database
 +
 +**__Do change the passwords for these two users immediately after the database is created.__**
 +
 +===== 8. Edit configuration file =====
 +
 +To fit your requirements for the VoIP platform, you have to edit the configuration file.
 +
 +<​code>​
 +  /​usr/​local/​etc/​kamailio/​kamailio.cfg
 +</​code>​
 +
 +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:
 +
 +<​code>​
 +#!define WITH_MYSQL
 +#!define WITH_AUTH
 +#!define WITH_USRLOCDB
 +</​code>​
 +
 +If you changed the password for the '​openser'​ user of MySQL, you have to update the value for '​db_url'​ parameters.
 +
 +You can browse [[http://​git.sip-router.org/​cgi-bin/​gitweb.cgi?​p=sip-router;​a=blob;​f=etc/​kamailio.cfg|kamailio.cfg]] online on GIT repository.
 +
 +===== 9. The 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:
 +
 +<​code>​
 +  /​usr/​local/​src/​kamailio-devel/​pkg/​kamailio/​debian/​kamailio.init
 +</​code>​
 +
 +<​code>​
 +/​usr/​local/​src/​kamailio-devel/​kamailio/​pkg/​kamailio/​deb/​debian/​kamailio.init
 +</​code>​
 +
 +Just copy the init file into the /​etc/​init.d/​kamailio. Then change the permisions:
 +
 +<​code>​
 +  chmod 755 /​etc/​init.d/​kamailio ​
 +</​code>​
 +
 +then edit the file updating the $DAEMON value:
 +<​code>​
 +  DAEMON=/​usr/​local/​sbin/​kamailio
 +</​code>​
 +
 +You need also setup a configuration file in the /​etc/​default/​ directory. This file can be found at:
 +
 +<​code>​
 +  /​usr/​local/​src/​kamailio-devel/​pkg/​kamailio/​debian/​kamailio.default
 +</​code>​
 +
 +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:
 +
 +<​code>​
 +mkdir -p /​var/​run/​kamailio
 +</​code>​
 +
 +Default setting is to run Kamailio as user "​kamailio"​ and group "​kamailio"​. For that you need to create the user:
 +
 +<​code>​
 +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
 +</​code>​
 +
 +Then you can start/stop Kamailio (OpenSER) using the following commands:
 +
 +<​code>​
 +  /​etc/​init.d/​kamailio start
 +  /​etc/​init.d/​kamailio stop
 +</​code>​
 +
 +===== 10. 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 test@mysipserver.com
 +
 +If you are asked for SIP_DOMAIN environment variable do one of the following option.
 +
 +<​code>​
 +  1.
 +  export SIP_DOMAIN=mysipserver.com
 +
 +  2.
 +  edit '/​root/​.kamctlrc'​ and add:
 +  SIP_DOMAIN=mysipserver.com
 +</​code>​
 +
 +===== 11. Maintenance =====
 +
 +The maintenance process is very simple right now. You have to be user '​root'​ and execute following commands:
 +
 +<​code>​
 +  cd /​usr/​local/​src/​kamailio-devel/​kamailio
 +  git pull origin
 +  make all
 +  make install
 +  /​etc/​init.d/​kamailio restart
 +</​code>​
 +
 +Now you have the latest Kamailio (OpenSER) devel running on your system.
 +
 +
 +===== 12. Time for maintenance service =====
 +
 +Notification about GIT commits are sent to the mailing list: **sr-dev@lists.sip-router.org**. Each commit notification contains the reference to the branch where the commit has been done. If the commit message contains the lines:
 +
 +<​code>​
 +Module: sip-router
 +Branch: master
 +</​code>​
 +
 +then an update has been made to Kamailio (OpenSER) devel version and it will be available to the public GIT in no time.
 +
 +===== Installation Stuff =====
 +
 +{{indexmenu>​install|js}}