Centos 7.x Install and Setup Asterisk 13 (PBX)

來源:互聯網
上載者:User

標籤:

Asterisk (PBX) is an open source communication server released under the GPL license maintained by Gigium and Asterisk community. Asterisk is used for creating communication applications that turns an ordinary computer into a communication server. So, using the Asterisk in your network environment, you can connect your employees from home to the office PBX over broadband connections and can also give them voicemail, integrated with Web and E-mail.

The benefits of using Asterisk are too much, so let’s follow this tutorial to setup your own Asterisk server whether in your home, office or in your organization and enjoy with its great features to fill communication gaps.

Asterisk Prerequisites

As we will be using CentOS 7 for Asterisk setup with minimal installed packages, so make sure that your system is up to data and you have root user privileges on the system for the installation of different required packages.

1) System Update

You can use below command for system update after successful root login.

#yum update

2) Installing Required Packages

Once your system is patched with latest updates, you have to install some packages including development tools and other packages that are necessary for its successful operation. You can easily do this by using the below command that will install its all required packages included all dependencies.

[[email protected] ~]# yum install gcc gcc-c++ php-xml php php-mysql php-pear php-mbstring mariadb-devel mariadb-server mariadb sqlite-devel lynx bison gmime-devel psmisc tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-nameserver sox newt-devel libxml2-devel libtiff-devel audiofile-devel gtk2-devel uuid-devel libtool libuuid-devel subversion kernel-devel kernel-devel-$(uname -r) git subversion kernel-devel php-process crontabs cronie cronie-anacron wget vim

Check the list of packages that are going to be installed on your system and press “Y” to continue, this will take about 125MB of your disk space.

After successful operation you will see the list of installed packages and updates including all its required dependencies.

3) Setup MariaDB

After installation by default we can connect to the database without using any password. So, first we will enable/start mariadb services as shown in below image, so that we can setup its root password.

Once the MariaDB services are fine , run the below command to setup its root password and remove anonymous user, test database and disallow remote user login.

[[email protected] ~]# mysql_secure_installation

4) Installing libjansson

Jansson is a C library for encoding, decoding and manipulating JSON data. Let‘s download, unpack and compile it using the below command.

# wget http://www.digip.org/jansson/releases/jansson-2.7.tar.gz

To extract this package use below command.

# tar -zxvf jansson-2.7.tar.gz

Then change directory and configure the package as shown.

5) Make Jansson

Now to compile the configured package we are required to use below ‘make‘ and ‘make install‘ command within the same directory to compile fully functional Jansson library.

[[email protected] Jansson-2.7]#make clean
[[email protected] Jansson-2.7]#make && make install
[[email protected] Jansson-2.7]#ldconfig

Installing Asterisk 13.5.0

Here we go with most important download that is Asterisk. Let‘s download its current latest package from their official web linkAsterisk Download Page. We will be using ‘wget‘ command to download its package, so change your current directory and run the command as shown below.

Using below commands unpack its package, change directory and then run its configuration command .

[[email protected] ~]# tar -zxvf asterisk-13.5.0.tar.gz
[[email protected] ~]# cd asterisk-13.5.0
[[email protected] asterisk-13.5.0]# ./configure --libdir=/usr/lib64

Upon successful completion of asterisk installation you will find its logo as shown below.

Asterisk Modules Setup

Now in the next few steps we will configure Asterisk for its necessary modules.

1) Asterisk Main menu Selection

In order to setup your menu items, let‘s run the below command and then choose the appropriate options.

[[email protected] asterisk-13.5.0]# make menuselect

Once you run this command, a new window will be opened where you can will see that for the most part , all the necessary modules are already included . You can add something or remove, when you select a module there is a brief description of its purpose. In the Add-ons to enable mp3 support module select ‘format_mp3‘ as shown below.

Then move to the next Core Sound Packages and select the formats of Audio packets as shown in the image.

Then select all the packages from the "Music On Hold Packages" and then form the "Extra Sound Packages choose the 4 that includes a first module containing EN and the choose the "Save and Exit" button to proceed for the next step.

2) Loading mp3 Libraries

Now run the following command to download the mp3 decoder library into the source tree.

[[email protected] asterisk-13.5.0]# contrib/scripts/get_mp3_source.sh

3) Modules Installation

Now we will proceed with installation of selected modules using the ‘make command‘.

So, Asterisk has been successfully built, now run the command as shown in the image to install asterisk.

[[email protected] asterisk-13.5.0]# make install

In response to the above command you will be greeted with below put at the end of nstallation.

+---- 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: +
+ +
+ make samples +
+ +
+----------------- 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 +
+-------------------------------------------+

Here we will run the below commands to install sample configuration files as indicated above.

[[email protected] asterisk-13.5.0]# make samples
[[email protected] asterisk-13.5.0]# make config

Setup Asterisk User

You can create a separate user and give him the right to work with Asterisk in order to start its services with its own user and group. To do so let‘s run the below command.

[[email protected] asterisk-13.5.0]# useradd -m asterisk
[[email protected] asterisk-13.5.0]# chown asterisk.asterisk /var/run/asterisk
[[email protected] asterisk-13.5.0]# chown -R asterisk.asterisk /etc/asterisk
[[email protected] asterisk-13.5.0]# chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk
[[email protected] asterisk-13.5.0]# chown -R asterisk.asterisk /usr/lib64/asterisk
[[email protected] asterisk-13.5.0]# systemctl restart asterisk
[[email protected] asterisk-13.5.0]# systemctl status asterisk

Setup Firewall Rules

Now begin to set up security. By default on CentOS 7 instead of iptables uses the FirewallD.
Using below two command you can start and enable the firewalld services.

[[email protected] ~]# systemctl start firewalld
[[email protected] ~]# systemctl enable firewalld

Now allow access to the ports that are being used in asterisk PBX by adding the following rules

[[email protected] ~]# firewall-cmd --zone=public --add-port=5060/udp --permanent
success
[[email protected] ~]# firewall-cmd --zone=public --add-port=5060/tcp --permanent
success
[[email protected] ~]# firewall-cmd --zone=public --add-port=5061/udp --permanent
success
[[email protected] ~]# firewall-cmd --zone=public --add-port=5061/tcp --permanent
success
[[email protected] ~]# firewall-cmd --zone=public --add-port=4569/udp --permanent
success
[[email protected] ~]# firewall-cmd --zone=public --add-port=5038/tcp --permanent
success
[[email protected] ~]# firewall-cmd --zone=public --add-port=10000-20000/udp --permanent
success

To load new firewall rules, use the below command.

[[email protected] ~]# firewall-cmd --reload

To confirm that all rules had been added , you can by using the command as shown in the image.

Setup Asterisk Database

Let‘s connect to the MySQL MariaDB and create new user and database then provide it all privileges using the following commands.

[[email protected] ~]# mysql -u root -p
Enter password:******
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

MariaDB [(none)]> create user ‘asterisk‘@‘localhost‘ identified by ‘******‘;
MariaDB [(none)]> create database asterisk;
MariaDB [(none)]> create database cdrdb;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON asterisk.* TO [email protected] IDENTIFIED BY ‘******‘;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cdrdb.* TO [email protected] IDENTIFIED BY ‘******‘;
MariaDB [(none)]> flush privileges;
MariaDB [(none)]>

Launching Asterisk

Launch Asterisk for the first time after its setup on Centos 7 using below command.

[[email protected] ~]# asterisk -r

Conclusion

Asterisk 13.5.0 (PBX) has been successfully installed on CentOS 7 with its required modules. If you find any mistakes in the article or inconsistencies we would be grateful if you write to us about it in the comments.

Centos 7.x Install and Setup Asterisk 13 (PBX)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.