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:
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
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
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
#############################################
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$$$$$$ $$
$$$$$$$$$$$$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 +
+-------------------------------------------+
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 -------+
+ +
+ YOU MUST READ THE SECURITY DOCUMENT +
+ +
+ 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" ; \
fi
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.
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.
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.
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
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.conf
file.
[general]
language=fr
Add the global configurations using the following command.
# vim user.conf
Next, add the following content.
[general]
hasvoicemail=yes
hassip=yes
qualify=yes
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.
[template](user_template)
type=friend
host=dynamic
dtmfmode=rfc2833
disallow=all
allow=ulaw
hassip=yes
qualify=yes
hasvoicemail=yes
To create the user Herve with the phone number 1000, add the following content to the user.conf
file.
[1000](user_template)
context=alibaba_calls
fullname=Herve Toto
username=Herve
secret=1234
To create the user John with the phone number 1001, add the following content to the user.conf
file:
[1001](user_template)
context=alibaba_calls
fullname=John Doe
username=John
secret=4321
Now that the SIP server is configured and phones are added, configure SIP phones so that you can make calls.
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.
The Linphone app is available on Google Play. Directly install the app on your phone.
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.
2,599 posts | 762 followers
FollowAlibaba Cloud MVP - March 6, 2020
Alibaba Clouder - November 2, 2020
Alibaba Clouder - September 6, 2019
ApsaraDB - November 13, 2024
Alibaba Cloud Community - February 20, 2024
Alibaba Cloud Indonesia - December 6, 2023
2,599 posts | 762 followers
FollowElastic and secure virtual cloud servers to cater all your cloud hosting needs.
Learn MoreAn encrypted and secure cloud storage service which stores, processes and accesses massive amounts of data from anywhere in the world
Learn MoreConduct large-scale data warehousing with MaxCompute
Learn MoreMore Posts by Alibaba Clouder