OpenSIPS is an Open Source carrier-grade SIP proxy/server used for SIP signaling and can handle all types of SIP operations. It’s being used by a lot of telco providers, ITSP and carriers because of its reliability and performance.
Depend on the workload whether someone is using a single instance of OpenSIPS or multiple instances along with different modules makes management of this powerful SIP server very hard. With the latest release of opensips-cli we can manage and control different OpenSIPS instances from linux console, but when it comes to provisioning the new SIP accounts, adding a new gateway, creating a new dialplan rule and looking for CDR it’s hard and not a recommended way to do it from console.
So to overcome and enhance the ease of managing OpenSIPS server, we can use OpenSIPS Control Panel. It’s a PHP Web Portal that let us perform wide variety of actions on OpenSIPS server including interacting with modules, sending MI commands to OpenSIPS core, custom CDRs, monitoring and integration with 3rd party tools like Homer.
Being a PHP web app, installation of OpenSIPS control panel is very easy and straightforward. In this tutorial, we gonna be installing OpenSIPS Control Panel 8.3.0 because it’s compatible with OpenSIPS 3.0. So these are the steps which we need to follow, to get our OpenSIPS Control Panel up and running –
- Installing PHP and Apache
- Downloading source code
- Configuring OpenSIPS Control Panel and Apache VirtualHost
- Setup HTTPD and JSON module in OpenSIPS Core
- Enjoy MI Commands 🙂
Step 1: Installing PHP and Apache
So before we start installing our dependencies, we will assume that you have OpenSIPS 3.0 already installed on Debian/Ubuntu and if not then please follow this guide and come back to this blog.
Let’s update all the package lists we have.
Now let’s install apache packages.
apt install apache2 wget git unzip
Once we have apache2 installed let’s check it’s status and enable it to start on system boot.
systemctl enable opensips systemctl status opensips
Before proceed, make we have apache running and we can see it’s default web page.
Now, we will be installing PHP7.4 for OpenSIPS Control Panel.
apt update sudo apt install ca-certificates apt-transport-https wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add - echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update sudo apt install php7.4 sudo apt install php7.4-cli php7.4-common php7.4-curl php7.4-mbstring php7.4-mysql php7.4-xml
Once successfully installed, confirm the php version.
Step 2: Downloading source code
We will download the source code for latest control panel 8.3.0 under /var/www
cd /var/www && wget https://github.com/OpenSIPS/opensips-cp/archive/8.3.0.zip
Once we have the zip file, we will unzip it and will change the name of the opensips-cp directory.
unzip 8.3.0.zip mv opensips-cp-8.3.0 opensips-cp cd opensips-cp
Step 3: Configuring OpenSIPS Control Panel and Apache VirtualHost
Now it’s time to configure OpenSIPS Control Panel where we will import control panel tables in opensips database, will update the db credentials in config file and will set up a separate apache virtual host file.
Go to /var/www/opensips-cp/config and import the mysql schema file into your existing opensips database.
mysql -D opensips -p < db_schema.mysql -u opensipsuser
Now, login into mysql console and make sure table ocp_admin_privileges exists.
While we are in config directory, there are some config files in it which we have to update.
1. db.inc.php # We have to update mysql DB credentials of opensips database here
2. boxes.global.inc.php # This file keeps the configuration of opensips instances. Each opensips instance is referred as a box in OpenSIPS, example box1,box2 and so on.
Next lets move on to the Apache VirtualHost configuration. We will now create a config file for our website under the sites enabled directory.
You can use the following sample virtualhost config to get the control panel up and running
<VirtualHost *:80> ServerName your-domanin-name DocumentRoot /var/www/opensips-cp/web/ <Directory /var/www/opensips-cp/web> Options Indexes FollowSymLinks MultiViews AllowOverride None Options -Indexes Order allow,deny allow from all </Directory> <Directory /var/www/opensips-cp> Options Indexes FollowSymLinks MultiViews AllowOverride None Options -Indexes Order deny,allow deny from all </Directory> <DirectoryMatch "/var/www/opensips-cp/web/tools/.*/.*/(template|custom_actions|lib)/"> Order deny,allow deny from all Options -Indexes </DirectoryMatch> </VirtualHost>
Make sure to disable the default config file for the apache welcome page and enable the new config file.
a2dissite000-default.conf a2ensite your-domain-name.conf
Now reload the apache2 service and we should be good to go.
systemctl restart apache2
Step 4: Setting up HTTPD and JSON module in OpenSIPS Core
To connect OpenSIPS control panel with OpenSIPS we are required to load and enable two modules: httpd.so and mi_http.so. To load these modules we first have to make sure that they are compiled and are present in the modules directory.
If you do not see the above-mentioned modules then you have to recompile OpenSIPs along with these modules.
Now we have to load these modules in to the OpenSIPS core. For this we will have to edit the to the OpenSIPS configuration file
loadmodule "httpd.so" modparam("httpd","port",8080) loadmodule "mi_http.so" modparam("mi_http","root","json")
Here, a process will listen on the port 8080 for the incoming mi commands. You can change it to your liking.
After we restart OpenSIPS we should see a process listening on port 8080
systemctl restart opensips
With the above step, our core is ready. Now we have to tell the control panel to send the commands to the above selected port. For this we have to edit the following config file
Here we edited the line shown below according to the parameters which we passed in the OpenSIPS config file.
If you have monit running as well, you can also configure it in the same file only.
This completes our configuration process. Now we will visit our control panel and make sure that everything is working as it should be.
If you visit the domain name or IP you set up apache on, you will be greeted with opensips login page. Use admin as a username and password should be opensips by default.
Under the System tab you will see all the options which are made available by default in the OpenSIPS control panel. We can enable and disable these options by editing the modules.inc.php file found under the same directory as boxes.global.inc.php file.
Thanks for reading, if you face any issue during the process feel free to use the comments section below and please consider subscribing to our newsletter.