By Hitesh Jethva, Alibaba Cloud Community Blog author.
Kamailio is a free and open source SIP Server that is capable to handle thousands of call setups per second. It is written in C and runs on a Linux/Unix based operating system. Kamailio can also serve up to 300,000 active subscribers with just a 4GB Ram System.
In this tutorial, we will learn how to set up a Kamailio SIP server on an Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 18.04 instance with Sysdig.
Create a new ECS instance and connect to your instance as the root user.
Once you are logged into your Ubuntu 18.04 instance, run the following command to update your base system with the latest available packages.
apt-get update -y
Before starting, you will need to install Apache web server, MariaDB server, PHP and other required libraries to your server. You can install all of them with the following command:
apt-get install apache2 mariadb-server php php-mysql php-gd php-curl php-xml libapache2-mod-php php-pear unzip wget git make -y
Once the installation has been completed, open php.ini file with the following command:
nano /etc/php/7.2/apache2/php.ini
Make the following changes:
memory_limit = 512M
upload_max_filesize = 150M
max_execution_time = 360
date.timezone = Asia/Kolkata
Save and close the file. Then, start Apache and MariaDB service and enable them to start on boot time with the following command:
systemctl start apache2
systemctl start mariadb
systemctl enable apache2
systemctl enable mariadb
Once you have done, you can proceed to the next step.
By default, Kamailio is not available in the Ubuntu-18.04 default repository. So, you will need to add kamailio repository to your server.
First, download and add the GPG key with the following command:
wget -O- http://deb.kamailio.org/kamailiodebkey.gpg | apt-key add -
Add the Kamailio repository by editing the following file:
nano /etc/apt/sources.list
Add the following lines:
deb http://deb.kamailio.org/kamailio52 bionic main
deb-src http://deb.kamailio.org/kamailio52 bionic main
Save and close the file, when you are finished.
Update the repository and install Kamailio with the following command:
apt-get update -y
apt-get install kamailio kamailio-mysql-modules kamailio-websocket-modules -y
Once the Kamailio has been installed, you can check the version of Kamailio with the following command:
kamailio -V
The default configuration file of Kamailio is located at /etc/kamailio/kamctlrc. Open the /etc/kamailio/kamctlrc file with the following command:
nano /etc/kamailio/kamctlrc
Make the following changes:
##If you have a working DNS server on your network, you can use domain name in place of IP address.
SIP_DOMAIN=192.168.0.103
DBENGINE=MYSQL
Save and close the file, when you are finished.
You will need to create a database, user and tables needed by Kamailio. You can do this with the following command:
kamdbctl create
Answer all the questions as shown below:
Enter character set name: Latin1
INFO: creating database kamailio ...
INFO: granting privileges to database kamailio ...
INFO: creating standard tables into kamailio ...
INFO: Core Kamailio tables succesfully created.
Install presence related tables? (y/n): y
INFO: creating presence tables into kamailio ...
INFO: Presence tables succesfully created.
Install tables for imc cpl siptrace domainpolicy carrierroute
drouting userblacklist htable purple uac pipelimit mtree sca mohqueue
rtpproxy rtpengine? (y/n): y
INFO: creating extra tables into kamailio ...
INFO: Extra tables succesfully created.
Install tables for uid_auth_db uid_avp_db uid_domain uid_gflags
uid_uri_db? (y/n): y
INFO: creating uid tables into kamailio ...
INFO: UID tables succesfully created.
Next, open the /etc/kamailio/kamailio.cfg file and enable some features:
nano /etc/kamailio/kamailio.cfg
Add the following lines below #!KAMAILIO.
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB
#!define WITH_ACCDB
Save and close the file. Then, restart the Kamailio service to apply the changes:
systemctl restart kamailio
You can now check the status of Kamailio with the following command:
systemctl status kamailio
Kamailio is now installed and configured successfully. Next, you will need to install Siremis to your server. Siremis is a web-based interface for Kamailio SIP Server. It can be used to provision user profiles, routing rules, view accounting, registered phones and communicate with SIP server. It also provides system and database administration tools for Kamailio SIP Server.
Before starting, you will need to install XML_RPC package for XMLRPC command panel. You can install it with the following command:
pear install XML_RPC2
Next, change the directory to Apache web root with the following command:
cd /var/www/
Next, download the latest version of Siremis for the Git repository with the following command:
git clone https://github.com/asipto/siremis
Once the download has been completed, change the directory to Siremis and generate .htaccess and Siremis configuration files by running the following command:
make prepare24
Next, give proper permissions to the Siremis directory with the following command:
make chown
You should see the following output:
changing owner to www-data:www-data ...
chown -R www-data:www-data .
Next, create an Apache virtual host configuration file for Siremis with the following command:
nano /etc/apache2/sites-available/siremis.conf
Add the following lines:
<VirtualHost *:80>
ServerName 192.168.0.103
ServerAdmin admin@example.com
DocumentRoot /var/www/siremis
Alias /siremis "/var/www/siremis/siremis"
<Directory "/var/www/siremis/siremis">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
<FilesMatch "\.xml$">
Require all denied
</FilesMatch>
<FilesMatch "\.inc$">
Require all denied
</FilesMatch>
</Directory>
</VirtualHost>
Save and close the file, when you are finished. Then, enable Siremis virtual host file and disable Apache default virtual host file with the following command:
a2ensite siremis
a2dissite 000-default
Enable Apache rewrite module with the following command:
a2enmod rewrite
Finally, restart Apache web service with the following command:
systemctl restart apache2
You can now check the status of Apache service with the following command:
systemctl status apache2
Next, you will need to create a siremis database user and grant full access to siremis database.
To do so, log in to MariaDB shell with the following command:
mysql -u root -p
Enter your root password, when prompt. Then, grant all privileges to siremis database with the following command:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON siremis.* TO siremis@localhost IDENTIFIED BY 'password';
Next, flush the privileges and exit from the MariaDB shell with the following command:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Siremis is now installed and configured. It's time to access Siremis web interface.
Open your web browser and type the URL http://192.168.0.103/siremis . You will be redirected to the Siremis welcome page:
Now, click on the Setup Now! button. You should see the following page:
Make sure all the necessary components are installed. Then, click Next. You should see the following page:
Enter all the required details and click Next. You should see the following page:
Click Next to start the installation. Once the installation has been completed successfully, you should see the following page:
Click on the Launch Siremis button. You will be redirected to the Siremis login page as shown below:
Now, provide Siremis admin username / password as admin / admin. Then, click on the Login button. You should see the Siremis default dashboard in the following page:
Congratulations! You have successfully installed Kamailio and Siremis to your Ubuntu 18.04 server. You can now easily manage your Kamailio SIP server using Siremis web interface.
How to Install Ganglia Monitoring Server on ECS Ubuntu 18.04
38 posts | 4 followers
FollowHiteshjethva - March 2, 2020
Hiteshjethva - December 12, 2019
Hiteshjethva - March 2, 2020
francisndungu - December 10, 2019
Hiteshjethva - March 2, 2020
Hiteshjethva - January 8, 2020
38 posts | 4 followers
FollowAlibaba Cloud (in partnership with Whale Cloud) helps telcos build an all-in-one telecommunication and digital lifestyle platform based on DingTalk.
Learn MoreElastic and secure virtual cloud servers to cater all your cloud hosting needs.
Learn MoreAn elastic and horizontally scalable high-performance computing service providing the same computing performance as traditional physical servers including physical isolation.
Learn MoreBuild superapps and corresponding ecosystems on a full-stack platform
Learn MoreMore Posts by Hiteshjethva
5253987278767746 April 19, 2020 at 6:49 am
excuse me, I want to ask about how to create a client in Kamailio on Ubuntu 18.04?