Community Blog How to Create Your Own IP Phone with Asterisk on Alibaba Cloud

How to Create Your Own IP Phone with Asterisk on Alibaba Cloud

This tutorial provides a step-by-step guide on how to create a cloud-based IP phone server using Asterisk on Alibaba Cloud.

By Bineli Manga, Alibaba Cloud Community Blog author.

Asterisk is one of the world's most popular free and open-source framework for building communication applications. In fact, it is the de facto technology for creating a personal SIP server, or personal phone server. And, coupled with the advantages of the cloud computing capabilities and technologies offered by Alibaba Cloud, you can create an IP Phone server that is accessible worldwide. Also, another interesting advantage of doing this is that, by creating your own IP Phone server, you will also lower your phone call bills. So, in this tutorial, we will get you started by providing the steps required to create a cloud-based IP Phone server that you may use for your home or at work.


To create a personal IP Phone server using the steps outlined in this tutorial, you'll need to have the following items first:

  • Linux computer or Cloud-based VM to install custom packages. For this, you can purchase an Alibaba Cloud Elastic Compute Service (ECS) instance to serve as your virtual machine. Using an VM from Alibaba Cloud will ensure that your IP Phone will be accessible worldwide, with excellent service both in and outside of China.
  • Internet access on your computer or Virtual machine
  • An Android phone with internet access to test the server

Install the Required Packages

First, install the necessary packages required to run Asterisk by executing the following commands.

$ apt-get install build-essential
$ apt-get install git-core subversion libjansson-dev sqlite autoconf automake libxml2-dev libncurses5-dev libtool

Download Asterisk

After installing all the packages required by Asterisk to run properly, download asterisk using the following command.

$ cd /usr/src

The above command places you in the /usr/src folder, where you will download and uncompress Asterisk before installing it. Download Asterisk using the following command.

$ wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-15-current.tar.gz

Once the download is complete, extract the content of the downloaded file asterisk-15-current.tar.gz using the following command.

$ tar -zxvf asterisk-15-current.tar.gz

3) Compile Asterisk

Post uncompressing asterisk package, compile it and install it on your system.

To compile it, move to the folder containing the uncompressed sources of asterisk /usr/src/asterisk-15.5.0 as shown below.

$ cd /usr/src/asterisk-15.5.0

Use the install_prereq script to install all the required packages before installing Asterisk.

$ ./contrib/scripts/install_prereq install

The installation process takes some time depending on the number of missing packages, and the resulting response on the terminal will be similar to the one shown below.

## install completed successfully

4) Configure Asterisk

After successful installation of Asterisk, configure Asterisk to meet your needs.

Firstly, run the configure script to check the system for missing libraries and binaries, then prepare the Asterisk source code for the build process.

$ ./configure

After the successful execution of the configure script, the following output reflects on the terminal.

configure: Menuselect build configuration successfully completed

            .$7$7..          .7$$7:.
          .$$:.                 ,$7.7
        .$7.     7$$$$           .$$77
     ..$$.       $$$$$            .$$$7
    ..7$   .?.   $$$$$   .?.       7$$$.
   $.$.   .$$$7. $$$$7 .7$$$.      .$$$.
 .777.   .$$$$$$77$$$77$$$$$7.      $$$,
 $$$~      .7$$$$$$$$$$$$$7.       .$$$.
.$$7          .7$$$$$$$7:          ?$$$.
$$$          ?7$$$$$$$$$$I        .$$$7
$$$       .7$$$$$$$$$$$$$$$$      :$$$.
$$$       $$$$$$7$$$$$$$$$$$$    .$$$.
$$$        $$$   7$$$7  .$$$    .$$$.
$$$$             $$$$7         .$$$.
7$$$7            7$$$$        7$$$
 $$$$$                        $$$
  $$$$7.                       $$  (TM)
   $$$$$$$.           .7$$$$$$  $$

configure: Package configured for:
configure: OS type  : linux-gnu
configure: Host CPU : x86_64
configure: build-cpu:vendor:os: x86_64 : pc : linux-gnu :
configure: host-cpu:vendor:os: x86_64 : pc : linux-gnu :

Now that the configuration is complete, continue compiling Asterisk using the $ make command.

Depending on the system resources, the build process may take several minutes and once it is completed the following message which implies successful completion prints on the console.

+--------- Asterisk Build Complete ---------+
+ Asterisk has successfully been built, and +
+ can be installed by running:              +
+                                           +
+                make install               +

Install Asterisk

The next step is to run the $ make install command to install Asterisk and all compiled Asterisk modules.

Upon successful Asterisk installation, the following message reflects on the screen.

 +---- Asterisk Installation Complete -------+
 +                                           +
 +                                           +
 + Asterisk has successfully been installed. +
 + If you would like to install the sample   +
 + configuration files (overwriting any      +
 + existing config files), run:              +
 +                                           +
 + For generic reference documentation:      +
 +    make samples                           +
 +                                           +
 + For a sample basic PBX:                   +
 +    make basic-pbx                         +
 +                                           +
 +                                           +
 +-----------------  or ---------------------+
 +                                           +
 + You can go ahead and install the asterisk +
 + program documentation now or later run:   +
 +                                           +
 +               make progdocs               +
 +                                           +
 + **Note** This requires that you have      +
 + doxygen installed on your local system    +

Run the make samples command to install the Asterisk sample configuration files as shown below.

$ make samples

Install the initialization script to manage Asterisk service using the systemctl command.

$ make config

The preceding command shows no output.

Next, install the log rotation script using the following command.

$ make install-logrotate

Executing the above command produces the following output indicating that the log rotation configuration has been created.

if [ ! -d "/etc/asterisk/../logrotate.d" ]; then \
        /usr/bin/install -c -d "/etc/asterisk/../logrotate.d" ; \
sed 's#__LOGDIR__#/var/log/asterisk#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#/usr/sbin#g' > contrib/scripts/asterisk.logrotate.tmp
/usr/bin/install -c -m 0644 contrib/scripts/asterisk.logrotate.tmp "/etc/asterisk/../logrotate.d/asterisk"
rm -f contrib/scripts/asterisk.logrotate.

Start Asterisk

Now that you have Asterisk installed on your Debian 9 VPS, start the Asterisk service by running the following command.

# systemctl start asterisk

Use the systemctl status command to check whether the Asterisk service is started.

# systemctl status asterisk

In case the service is running, the following message will appear.

asterisk.service - LSB: Asterisk PBX
   Loaded: loaded (/etc/init.d/asterisk; generated; vendor preset: enabled)
   Active: active (running) since Thu 2018-08-09 01:26:50 CDT; 29s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 4996 ExecStart=/etc/init.d/asterisk start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/asterisk.service
           └─5008 /usr/sbin/asterisk

Finally, enable the Asterisk service to start the system boot using the following command.

# systemctl enable asterisk

Now, the Asterisk installation on your Debian 9 based server is complete.

Configure the SIP Server

Now we will want to set further configurations to add IP phones on the network. Note that this has to be done before making any phone call.

The SIP Configuration files

Asterisk is located in the folder: /etc/asterisk. Now, let's modify the following files to add SIP users:

  • sip.conf
  • users.conf
  • extensions.conf

Make a backup of these files prior to any modification.

# cd /etc/asterisk
# cp sip.conf sip.conf.backup
# cp users.conf users.conf.backup
# cp extensions.conf extensions.conf.backup

7.2 Set the Global Configuration

Begin with emptying the sip.conf file by executing the following command.

# echo " sip.conf

Then, add the global configurations using the command below.

# vim sip.conf

Now, add the following content in the sip.conffile.


7.3 Create Users

Add the global configurations using the following command.

# vim user.conf

Next, add the following content.

  • Create a Template User

The template user is a default user configuration that all users have. This allows making global changes to all the users in one place.

To add this Template user, just add the following content to the user.conf file.

  • Create User 1000 - Herve

To create the user Herve with the phone number 1000, add the following content to the user.conf file.

fullname=Herve Toto
  • Create User 1001 - John

To create the user John with the phone number 1001, add the following content to the user.conf file:

fullname=John Doe

Now that the SIP server is configured and phones are added, configure SIP phones so that you can make calls.

Configure the SIP Phones to Make Calls Via IP Phone

Once the Asterisk IP Phone server is completely installed, configure the IP Phone to use the server while making phone calls. Follow the instructions below to install the SIP phones.

For this tutorial, we are going to use Linphone as the SIP client, to use our SIP server.

Install the SIP Phone App on Phone

The Linphone app is available on Google Play. Directly install the app on your phone.

Configure Linphone

Setup the account Linphone account by clicking on 'I already have a SIP account'.

Next, set the following credentials as already set up in the user.conf file.

User Name: Herve
User Identifier: herve
Password: 1234
Domain Name: (Here you have to put the public IP address of your Alibaba Cloud Virtual Machine)

Now, click on TLS as the transport protocol. Finally, just click on the Connexion button to complete the setup.


After finishing the steps outlined in this tutorial, you will have created your own SIP server and can deploy it over the internet on Alibaba Cloud. And, by completing this tutorial, you are also now well-versed to launch an IP phone server of your own and cut your phone call prices.

0 0 0
Share on

Alibaba Clouder

2,600 posts | 753 followers

You may also like