1, Getting sources from GIT
mkdir src; cd src
git clone --depth 1 git://git.sip-router.org/sip-router kamailio
cd kamailio
git checkout -b 3.1 origin/3.1
2, Tuning Makefiles
make FLAVOUR=kamailio cfg
Next step is to enable the MySQL module.
nano -w modules.lst
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:
make FLAVOUR=kamailio include_modules="db_mysql dialplan" cfg
If you want to install everything in one directory, say /usr/local/kamailio-3.1, then use:
make PREFIX="/usr/local/kamailio-3.1" FLAVOUR=kamailio include_modules="db_mysql dialplan" cfg
3, Compile Kamailio (OpenSER)
make all
4. Install Kamailio (OpenSER)
make install
5. Create MySQL database
First, in order to create the database you need to specify the wanted db type (DBENGINE=MYSQL) in the
/usr/local/kamailio-3.1/etc/kamailio/kamctlrc
file.
Then, to create the MySQL database, you have to use the database setup script:
/usr/local/kamailio-3.1/sbin/kamdbctl create
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.
6, Edit configuration file
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.
7, 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:
/usr/local/src/kamailio-3.1.0/pkg/kamailio/debian/kamailio.init
/usr/local/src/kamailio-3.1.0/kamailio/pkg/kamailio/deb/debian/kamailio.init
Just copy the init file into the /etc/init.d/kamailio. Then change the permisions:
chmod 755 /etc/init.d/kamailio
then edit the file updating the $DAEMON value:
DAEMON=/usr/local/sbin/kamailio
You need also setup a configuration file in the /etc/default/ directory. This file can be found at:
/usr/local/src/kamailio-3.1.0/pkg/kamailio/debian/kamailio.default
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 “kamailio”. 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 (OpenSER) using the following commands:
/etc/init.d/kamailio start
/etc/init.d/kamailio stop
8, 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.
1.
export SIP_DOMAIN=mysipserver.com
2.
edit '/root/.kamctlrc' and add:
SIP_DOMAIN=mysipserver.com
The maintenance process is very simple right now. You have to be user 'root' and execute following commands:
cd /usr/local/src/kamailio-3.1.0/kamailio
git pull origin
make all
make install
/etc/init.d/kamailio restart
Now you have the latest Kamailio (OpenSER) v3.1.0 running on your system.
mkdir src; cd src
git clone --depth 1 git://git.sip-router.org/sip-router kamailio
cd kamailio
git checkout -b 3.1 origin/3.1
2, Tuning Makefiles
make FLAVOUR=kamailio cfg
Next step is to enable the MySQL module.
nano -w modules.lst
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:
make FLAVOUR=kamailio include_modules="db_mysql dialplan" cfg
If you want to install everything in one directory, say /usr/local/kamailio-3.1, then use:
make PREFIX="/usr/local/kamailio-3.1" FLAVOUR=kamailio include_modules="db_mysql dialplan" cfg
3, Compile Kamailio (OpenSER)
make all
4. Install Kamailio (OpenSER)
make install
5. Create MySQL database
First, in order to create the database you need to specify the wanted db type (DBENGINE=MYSQL) in the
/usr/local/kamailio-3.1/etc/kamailio/kamctlrc
file.
Then, to create the MySQL database, you have to use the database setup script:
/usr/local/kamailio-3.1/sbin/kamdbctl create
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.
6, Edit configuration file
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.
7, 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:
/usr/local/src/kamailio-3.1.0/pkg/kamailio/debian/kamailio.init
/usr/local/src/kamailio-3.1.0/kamailio/pkg/kamailio/deb/debian/kamailio.init
Just copy the init file into the /etc/init.d/kamailio. Then change the permisions:
chmod 755 /etc/init.d/kamailio
then edit the file updating the $DAEMON value:
DAEMON=/usr/local/sbin/kamailio
You need also setup a configuration file in the /etc/default/ directory. This file can be found at:
/usr/local/src/kamailio-3.1.0/pkg/kamailio/debian/kamailio.default
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 “kamailio”. 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 (OpenSER) using the following commands:
/etc/init.d/kamailio start
/etc/init.d/kamailio stop
8, 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.
1.
export SIP_DOMAIN=mysipserver.com
2.
edit '/root/.kamctlrc' and add:
SIP_DOMAIN=mysipserver.com
9, Maintenance
The maintenance process is very simple right now. You have to be user 'root' and execute following commands:
cd /usr/local/src/kamailio-3.1.0/kamailio
git pull origin
make all
make install
/etc/init.d/kamailio restart
Now you have the latest Kamailio (OpenSER) v3.1.0 running on your system.