2 ==================================================
4 Kamailio SIP Server Installation Notes
6 http://www.kamailio.org
8 ==================================================
10 Welcome! This is an amazingly flexible, robust and secure SIP server
11 built on years of experience in several Open Source projects. It's a merge
12 of the SIP Express Router (SER) and the Kamailio (OpenSER) products produced
13 by a joint development team.
15 This memo gives you hints on how to set up the Kamailio quickly.
17 You can find a similar tutorial and many more on project's web site:
18 - http://www.kamailio.org/w/documentation/
19 - http://www.kamailio.org/wiki/
25 1. Supported Architectures And Requirements
26 2. How-To Build Kamailio From The Source Code Distribution
27 2.1 Kamailio Fast Track Installation
28 2.2 Details Installing From Source Code
30 3. Quick-Start Installation Guide
34 D) Kamailio With Persistent Data Storage
38 1. Supported Architectures And Requirements
39 -------------------------------------------
41 Supported operating systems:
42 - Linux (Debian, Ubuntu, Fedora, RedHat, CentOS, OpenSUSE, Gentoo, a.s.o.)
43 - FreeBSD, NetBSD, OpenBSD, Dragonfly BSD
47 Note that some modules have dependencies on the Linux operating system.
48 This is clearly noted in the README files.
51 - Windows+Cygwin (core + static modules only, no IPv6, no
52 TCP, no dynamic modules)
54 Supported architectures
55 - i386, x86_64 (amd64), armv4l, sparc64, powerpc, powerpc64
57 Experimental architectures:
58 - mips1, mips2, sparc32, alpha
60 (for other architectures the Makefiles might need to be edited)
62 There are various configuration options defined in the Makefile.
67 gcc >= 2.9x; 3.[12] recommended (it will work with older version
68 but it might require some options tweaking for best performance)
70 - bison or yacc (Berkley Yacc)
72 - GNU make (on Linux this is the standard "make", on *BSD and Solaris it is
73 called "gmake") version >= 3.80 (recommended 3.81).
74 - sed and tr (used in the makefiles)
75 - GNU tar ("gtar" on Solaris) and gzip if you want "make tar" to work
76 - GNU install, BSD install or Solaris install if you want "make
77 install", "make bin", "make sunpkg" to work
78 - libmysqlclient & libz (zlib) if you want MySQL support (the db_mysql module)
79 - libxml2 if you want to compile the cpl-c (CPL support) or pa (presence)
81 - freeradius or libradiusclient-ng (> 5.0) if you need RADIUS support (the auth_radius,
82 group_radius, uri_radius and avp_radius modules)
83 - libpq if you need PostgreSQL support (the db_postgres module)
84 - libexpat if you want the jabber gateway support (the jabber module) or the
86 - libxml2 if you want to use the cpl-c (Call Processing Language) or
87 the presence modules (presence and pua*)
88 - libradius-ng -libs and devel headers- if you want to use functionalities
89 with radius support - authentication, accounting, group support, etc
90 - unixodbc - libs and devel headers - if you want UNIXODBC support as
92 - libperl - libs and devel headers - if you want the perl connector to support
93 perl scripting from your config file (perl module)
94 - libsnmp9 - libs and devel headers - if you want SNMP client functionality
95 (SNMP AgentX subagent) for Kamailio
96 - libldap libs and devel headers v2.1 or greater - if you want LDAP support
97 - libpcre libs and devel headers - if you want to compile the lcr and dialplan
99 - libsctp devel headers - if you want to compile the SCTP transport in the core
100 - libssl devel headers (openssl project) - if you want to compile the TLS module
101 - libunistring - for the WebSocket module
102 - python and devel headers for the Python module
103 - jdk and gcj for Java module
104 - the jansson library for the jansson module used for JSON document handling
106 Some modules have other requirements on third-party libraries. This is documented
107 in the README for the specific module.
111 FreeBSD/OpenBSD/NetBSD: make sure gmake, bison or yacc & flex are installed.
115 If you want to compile all the modules, you will need the following packages:
116 - mysql-client-* (any version, install one of the mysql*-client ports) for
118 - postgresql-libpqxx-2.4.2_1 (/usr/ports/databases/postgresql-libpqxx) for
120 - expat-1.95.8 (/usr/ports/textproc/expat2) for libexpat
121 - libxml2-2.6.18 (/usr/ports/textproc/libxml2) for libxml2
122 - radiusclient-0.4.7 (/usr/ports/net/radiusclient) for libradiusclient-ng
123 NOTE: you'll need to add radiusclient_ng=4 to the gmake command line if you
124 use the 0.4.* version.
126 Compile example (all the modules and SIP server core in a tar.gz):
127 gmake bin radiusclient_ng=4 include_modules="mysql jabber cpl-c auth_radius group_radius uri_radius postgres pa"
131 - mysql-client-4.0.23 (/usr/ports/databases/mysql) for libmysqlclient
132 - expat-1.95.6 (/usr/ports/textproc/expat) for libexpat
133 - libxml-2.6.16p0 (/usr/ports/textproc/libxml) for libxml2
134 - radiusclient-ng-0.5.1 from
135 http://download.berlios.de/radiusclient-ng/radiusclient-ng-0.5.1.tar.gz
136 (you need to download and install it, since there is no "official"
137 openbsd port for it) for libradiusclient-ng
139 Compile example (all the modules and SIP server core in a tar.gz):
140 gmake bin include_modules="mysql jabber cpl-c auth_radius group_radius uri_radius pa"
144 - mysql-client-4.1.12 (/usr/pkgsrc/databases/mysql4-client) for libmysqlclient
145 - expat-1.95.8nb2 (/usr/pkgsrc/textproc/expat) for libexpat
146 - libxml2-2.6.19 (/usr/pkgsrc/textproc/libxml2) for libxml2
147 - radiusclient-ng-0.5.1 (see OpenBSD)
149 Compile example (all the modules and SIP server in a tar.gz):
150 gmake bin include_modules="mysql jabber cpl-c auth_radius group_radius uri_radius pa"
154 As above; you can use Solaris's yacc instead of bison. You might also
155 need gtar and ginstall. If you don't have ginstall you can use Solaris
156 install, just make sure it's in the PATH (it's usually in /usr/sbin) and
157 add INSTALL=install either to the environment or to the make command line
158 (e.g.: gmake INSTALL=install all).
160 Compile example (all the modules and SIP server in a tar.gz):
161 gmake bin INSTALL=install include_modules="mysql jabber cpl-c auth_radius group_radius uri_radius postgres pa"
165 Kamailio is part of the official Debian distribution. You can download binary modules
166 directly using normal packet management.
168 Needed packages for compiling all the modules:
170 - libmysqlclient-dev for libmysqlclient
171 - libpq-dev for libpq
172 - libexpat1-dev for libexpat
173 - libxml2-dev for libxml2
174 - libradiusclient-ng-dev for libradiusclient
175 - other libraries are needed for some other modules,
176 see README of the module you want to use
177 Kamailio have APT deb repositories that allow you to
178 install the binaries easily - see the web site for more details:
179 - http://kamailio.org
182 Cygwin (alpha state, partial support)
183 --------------------------------------
184 make sure make, bison, flex, minires and minires-devel (needed for the
185 resolver functions) are installed.
187 Only building Kamailio's core and some static modules is supported for now.
188 Stuff known not to work:
189 - IPv6 (cygwin doesn't support it yet)
190 - TCP (the tcp code heavily depends on file descriptor passing
191 between processes, which is not yet supported by cygwin)
192 - dynamic modules (non statically linked -- not supported because
193 backlinking doesn't work in windows by design)
196 Compile example (all the modules and Kamailio in a tar.gz):
197 make bin include_modules="mysql jabber cpl-c auth_radius group_radius uri_radius postgres pa"
200 2. Howto Build Kamailio From Source Code Distribution
201 -------------------------------------------------------
203 (NOTE: if make doesn't work try gmake instead)
205 2.1 Kamailio Fast Track Installation
206 ....................................
209 If you are familiar with Unix/Linux build tools aready and you installed
210 the required dependencies, then you can just follow this section, otherwise
213 To get Kamailio installed, in the folder with source code run:
219 If you want to install with additional modules, for example with mysql and
222 make include_modules="db_mysql tls" cfg
226 2.2 Details - Installing From Source Code
227 .......................................
231 Kamailio is split in four main parts: The core, the modules, the
232 utilities, and the various scripts/examples. When you build, you can decide to build
233 only the core, the modules, both, or all.
235 * Compile Kamailio core only:
238 Compile modules except some explicitly excepted (see below)
239 make modules - all modules in the modules/ directory
240 make modules-all or make every-module - all the modules
245 * Explicitly excepted modules:
246 By default make all will not build modules that require external libraries or
247 that are considered to be "experimental". For example, modules that have external
248 dependencies are: db_mysql, jabber, cpl-c, auth_radius, group_radius, uri_radius,
249 avp_radius, db_postgres, db_berkeley, carrierroute, ...
251 Including groups of modules:
252 Instead of compiling the default modules only, you can specify groups of
253 modules to include, according to their status:
254 - standard - Modules in this group are considered a standard part of Kamailio
255 (due to widespread usage) but they have no dependencies (note that some of
256 these interplay with external systems. However, they don't have compile
257 or link dependencies).
259 - db - Modules in this group use databases and need a database driver to run.
260 Included are drivers for the text mode db (dbtext) and for dumping
261 large amount of data to files (db_flatstore). See also the mysql or
264 - standard_dep - Modules in this group are considered a standard part of Kamailio
265 (due to widespread usage) but they have dependencies that must be satisfied
267 NOTE! All presence modules (dialog, pa, presence_b2b, rls, xcap) have been
268 included in this group due to interdependencies
270 - stable - Modules in this group satisfy specific or niche applications,
271 and are considered stable for production use. They may or may not have dependencies
273 - experimental - Modules in this group are either not complete, untested, or
274 without enough reports of usage to allow the module into the stable group.
275 They may or may not have dependencies.
277 There is another set of groups mainly used by Kamailio, where modules
278 are grouped based on Debian packaging rules. For example:
279 - kstandard - Kamailio standard modules
281 - kpresence - Kamailio SIMPLE presence server modules
283 * To compile core with standard modules:
284 make group_include="standard" all
286 * To compile all modules (provided you have all the required libraries installed) use:
287 make group_include="standard standard-dep stable experimental" all
289 There are also in addition some "convenience" groups:
291 mysql - Include all the db modules dependent and the MySQL db driver
292 postgres - Include all the db modules and the PostgreSQL db driver
293 radius - Include all modules on radiusclient
294 presence - Include all the presence modules
296 Ex. to make a standard installation with MySQL, use:
297 make group_include="standard mysql" all
299 In addition to group_include (or instead), you can use
300 include_modules="modA modB"
301 to specify exactly the modules you want to include, ex.
302 make include_modules="mymodule" modules
304 You can also explicitly skip modules using skip_modules. Let's say you want all
305 the standard and standard-dep modules except domain:
306 make group_include="standard standard-dep" skip_modules="domain" all
308 NOTE!!! As this mechanism is very powerful, you may be uncertain which
309 modules that will be included. Just replace all (or modules) with print-modules
310 and you will see which modules will be included and excluded, ex:
312 will show which modules are excluded by default.
314 If you want to install or to build a binary package (a tar.gz with
315 Kamailio core and the modules), substitute "all" in the above command with
319 * More compile examples:
321 - compile with profiling
323 - compile debug mode version
325 - compile debug version with profiling
326 make mode=debug PROFILE=-pg all
327 - compile only the print module
328 make modules=modules/print modules
329 - compile by default only the print module, in debuging mode and with
331 make cfg modules=modules/print mode=debug PROFILE=-pg
333 - change & save the modules list without rebuilding the whole config
334 (so that already compiled modules won't be re-compiled by
335 make all/make modules):
336 make modules-cfg include_modules="mysql postgress"
337 - change only the compile/build options, without changing the modules list:
338 make cfg-defs CPU=ultrasparc PROFILE=-pg
339 - compile by default all the usual modules + mysql and postgres, optimized
340 for pentium-m and for space (saves both the build options and the module
342 make cfg include_modules="mysql postgres" CPU=pentium-m CC_EXTRA_OPTS=-Os
344 - compile all the "default" modules except textops and vm
345 make skip_modules="textops vm" modules
346 - save the above option in the make config, so that all make commands
347 will use it by default:
348 make cfg skip_modules="textops vm"
349 - compile all default modules and include uri_radius (not compiled by default):
350 make include_modules="uri_radius" modules
351 - compile all the modules from the modules subdirectory (even the one excluded
353 make exclude_modules="" modules
354 - compile all the modules from the modules subdirectory excluding vm:
355 make exclude_modules=vm modules
357 make exclude_modules="" skip_modules=vm modules
358 - compile with the "tm" module statically linked and with profiling
359 make static_modules=tm PROFILE=-pg all
360 - compile with gcc-3.2 instead of gcc
368 Make Local Build Config:
369 ------------------------
371 * make cfg or make config - force config and module list regeneration
374 make cfg include_modules=mysql mode=debug
376 All future make invocations will include the mysql module and will build in debug mode
378 Note: If config.mak doesn't exist (e.g. initial checkout or after a make
379 proper) or if Makefile.defs was changed, the config will be re-generated
380 automatically by the first make command. For example:
381 make cfg include_modules=db_mysql; make all
383 rm config.mak modules.lst; make include_modules=db_mysql.
385 * make cfg-defs (force config regeneration, but don't touch the module list)
388 make cfg-defs CPU=ultrasparc CC_EXTRA_OPTS=-Os PROFILE=-pg
393 saves the module list, without regenerating the build config
395 make modules-list include_modules="tls" skip_modules="print"
400 * make clean - clean the base and modules too
401 * make proper - clean also the dependencies and the config, but not the module list
402 * make distclean - the same as proper
403 * make maintainer-clean - clean everything, including make's config, saved
404 module list, auto generated files, tags, *.dbg a.s.o
405 * make clean-all - clean all the modules in modules/*
406 * make proper-all - like make proper but for all the modules in modules/*
410 * make clean-cfg - cleans the compile config
411 * make clean-modules-cfg - cleans the modules list
415 * make local-clean - cleans only the core, no libs, utils or modules
416 * make clean-modules - like make clean, but cleans only the modules
417 * make clean-libs - like make clean, but cleans only the libs
418 * make clean-utils - like make clean, but cleans only the utils
424 optional: make cfg <various cfg. options that should be saved>
425 * make proper-modules - like make proper, but only for modules
426 * make proper-libs - like make proper, but only for libs
427 * make proper-utils - like make proper, but only for utils
429 or gmake on non-Linux systems
431 or make modules exclude_modules="CVS print" etc.
438 Create a tar.gz with the sources (in ../):
441 Create a tar.gz with the binary distribution (in ../):
444 Create a gzipped solaris package (in ../):
447 Create debian packages (in ../):
456 Regenerate the README for all the "default" modules (include_modules,
457 skip_modules a.s.o can be used to alter the module list).
460 Generates a manpage for all the modules that support it (.xml file in the
464 Generates README file for modules/foo.
465 make modules=modules/foo modules-readme
470 make prefix=/usr/local install
472 Note: If you use prefix parameter in make install then you also need
473 to use this parameter in previous make commands, i.e. make, make modules,
474 or make all. If you fail to do this then Kamailio will look for the default
475 configuration file in a wrong directory, because the directory of the
476 default configuration file is hardcoded into Kamailio during compile time.
477 When you use a different prefix parameter when installing then the
478 directory hard coded in Kamailio and the directory in which the file will be
479 installed by make install will not match. (You can specify exact location
480 of the configuration file using -f parameter of Kamailio).
482 For example, if you do the following:
484 make prefix=/ install
486 Then the installation will put the default configuration file into
487 /etc/kamailio/kamailio.cfg (because prefix is /),
488 but Kamailio will look for the file in /usr/local/etc/kamailio/kamailio.cfg
489 (because there was no prefix parameter make all and /usr/local is the default value of prefix).
491 The workaround is trivial, use the same parameters in all make commands:
493 make prefix=/ install
494 or save the desired prefix in the make config (e.g.: make cfg prefix=/).
496 That applies to other make parameters as well (for example parameters
497 "modules" or "excluded_modules").
500 3. Quick-Start Installation Guide
501 ---------------------------------
505 This guide gives you instructions on how to set up the Kamailio
506 on your box quickly. In case the default configuration does not fly, please
507 check the documentation at the Kamailio web site
508 http://www.kamailio.org to learn how to configure Kamailio for your site.
510 If the documentation does not resolve your problem you may try contacting
511 our user forum by E-mail at sr-users@lists.sip-router.org -- that is the
512 mailing list of the Kamailio community. To participate in the mailing list,
513 please subscribe at the following web address:
515 https://lists.sip-router.org/cgi-bin/mailman/listinfo
519 Note well the default "quick-start" configuration is very simple in order
520 to be easily installable. It provides minimum features. Particularly,
521 authentication is by default disabled, which means anyone can register using
522 any name with the server. (This is on purpose to avoid installation
523 dependencies on a database, which is needed for storing user credentials.)
527 The following step-by step guide gives you instructions how to install the
528 SQL-free distribution of Kamailio. If you need persistence and
529 authentication, then you have to install additional database support --
530 proceed to section D) after you are finished with C).
532 1) Download an RPM or Debian package from the links on the wiki
534 https://www.kamailio.org/wiki/
536 If you don't use an rpm or debian based distribution, try our tar.gz'ed
538 https://www.kamailio.org/pub/kamailio/latest/src/
540 If you use Solaris 8 you can try our solaris package.
541 If you use Gentoo Linux you do not have to download a package.
543 2) Install the package
545 rpm -i <package_name>
547 dpkg -i <package_name>
550 (or if use only stable packets:
551 ACCEPT_KEYWORDS="~x86" emerge kamailio )
553 cd /; tar zxvf <package_name>_os_arch.tar.gz
554 (it will install in /usr/local/, and the configuration file in
555 /usr/local/etc/kamailio/kamailio.cfg)
557 gunzip <package_name>.gz ; pkgadd -d <package_name>
564 /etc/init.d/kamailio start
566 Kamailio is started automatically after the install
567 (in case something fails you can start it with '/etc/init.d/kamailio start')
570 the tar.gz does not include an init.d script, you'll have to create one of
571 your own or adapt one from the source distribution (pkg/debian/init.d,
572 pkg/kamailio/rpm/kamailio.init, pkg/kamailio/deb/debian/kamailio.init, a.s.o.)
573 You can start Kamailio directly with
574 /usr/local/sbin/kamailio.
576 4) Optionally, watch server's health using the kamctl utility
578 - to do so, first set the environment variable SIP_DOMAIN to your domain
579 name, e.g., in Bourne shell, call
580 export SIP_DOMAIN="myserver.foobar.com"
581 - if you are using other than 'localhost' mysql server for maintaining
582 subscriber database, change the variable 'SQL_HOST' to the proper
583 host name in the kamctl script
584 - run the kamctl utility
585 /usr/sbin/kamctl moni
587 /usr/local/sbin/kamctl moni (if you installed Kamailio from a
588 tar.gz or solaris package)
590 5) Connect SIP phones
592 Register with the server using your favorite SIP User Agent (phone).
594 In most cases, you need to set the following options:
596 Proxy server: host name of your server
597 Domain: the sip domain your server is configured to handle
598 User name: the account name for your device
599 Auth user: the ID used for authentication
600 Secret/Password: The configured authentication password
602 D) Kamailio With Persistent Data Storage
603 ------------------------------------------
605 The default configuration is very simple and features many simplifications.
606 In particular, it does not authenticate users and loses User Location database
607 on reboot. To provide persistence, keep user credentials and remember users'
608 locations across reboots, Kamailio can be configured to use a database, like MySQL.
610 Before you proceed, you need to make sure MySQL is installed on your box. Your
611 MySQL server must be configured to deal with a large number of
612 connection. To increase it, set the following line in [mysqld] section
613 of your my.ini configuration file:
615 set-variable = max_connections=500
617 1) Download the package containing mysql support for Kamailio from the links
619 https://www.kamailio.org/wiki/
621 (rpm and deb provided, most of the binary tar.gz distributions and the
622 solaris package include it; if it is not present you'll have to rebuild
624 For gentoo please include 'mysql' to your USE variable in /etc/make.conf
625 or give it as variable to the emerge command.
627 2) install the package
628 rpm -i <package_name>
630 dpkg -i <package_name>
633 (if do not want to put 'mysql' into your USE variable you can type:
634 USE="mysql" emerge kamailio)
636 3) create MySQL tables for Kamailio
637 - if you have a previously installed Kamailio on your system, use
638 /usr/local/sbin/kamdbctl reinstall
639 to convert your Kamailio database into new structures
640 - otherwise, if this is your very first installation, use
641 /usr/local/sbin/kamdbctl create
642 to create Kamailio database structures
643 (you will be prompted for password of MySql "root" user)
645 4) configure Kamailio to use SQL
646 uncomment all lines in configuration file kamailio.cfg which are related to authentication:
647 - loadmodule "db_mysql.so"
648 - loadmodule "auth.so"
649 - loadmodule "auth_db.so"
650 - modparam("usrloc", "db_mode", 2)
651 - modparam("auth", "calculate_ha1", yes)
652 - modparam("auth_db", "password_column", "password")
653 - if (!www_authorize("example.com", "subscriber")) {
654 www_challenge("example.com", "0");
658 5) be sure to replace realm, the first parameter in www_* actions,
659 with name of your server; some broken UAC implementations don't
660 authenticate otherwise; the authentication command in your
661 configuration script should look then like this:
662 if (!www_authorize("myserver.foobar.com", "subscriber")) {
663 www_challenge("myserver.foobar.com", "0");
667 6) restart the server
669 /etc/init.d/kamailio restart
671 7) you can now start managing the server using the kamctl utility;
672 you need to first set the environment variable SIP_DOMAIN to your
673 local SIP realm, e.g.,
674 export SIP_DOMAIN="myserver.example.com"
676 a) watch the server status using 'kamctl moni'
677 b) try to login with your SIP client as user 'admin' with password 'heslo'
678 c) try adding new users using
679 'kamctl add <username> <password>'
685 Q: SIP requests are replied by Kamailio with "483 Too Many Hops" or
686 "513 Message Too Large"
688 A: In both cases, the reason is probably an error in request routing script
689 which caused an infinite loop. You can easily verify whether this happens
690 by watching SIP traffic on loopback interface. A typical reason for
691 misrouting is a failure to match local domain correctly. If a server
692 fails to recognize a request for itself, it will try to forward it to
693 current URI in believe it would forward them to a foreign
694 domain. Alas, it forwards the request to itself again. This continues
695 to happen until value of max_forwards header field reaches zero or
696 the request grows too big. Solutions is easy: make sure that domain
697 matching is correctly configured. A quick way to achieve that is to
698 introduce a config option to ser.cfg or kamailio.cfg: alias=domainname,
699 where domainname shall be replaced with name of domain, which you wish to
700 server and which appears in request-URIs.
702 Q: Where to report issues?
704 A: Use bug tracker at: https://github.com/kamailio/kamailio/issues
706 Q: Any F.A.Q. that could be helpful to check before reporting an issue?
708 A: See: https://www.kamailio.org/wiki/tutorials/faq/main