标签:
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.
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.
[root@centos-7 ~]# 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.
[root@centos-7 ~]# 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.
[root@centos-7 Jansson-2.7]#make clean
[root@centos-7 Jansson-2.7]#make && make install
[root@centos-7 Jansson-2.7]#ldconfig
Here we go with most important download that is Asterisk. Let‘s download its current latest package from their official web link Asterisk 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 .
[root@centos-7 ~]# tar -zxvf asterisk-13.5.0.tar.gz
[root@centos-7 ~]# cd asterisk-13.5.0
[root@centos-7 asterisk-13.5.0]# ./configure --libdir=/usr/lib64
Upon successful completion of asterisk installation you will find its logo as shown below.
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.
[root@centos-7 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.
[root@centos-7 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.
[root@centos-7 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.
[root@centos-7 asterisk-13.5.0]# make samples
[root@centos-7 asterisk-13.5.0]# make config
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.
[root@centos-7 asterisk-13.5.0]# useradd -m asterisk
[root@centos-7 asterisk-13.5.0]# chown asterisk.asterisk /var/run/asterisk
[root@centos-7 asterisk-13.5.0]# chown -R asterisk.asterisk /etc/asterisk
[root@centos-7 asterisk-13.5.0]# chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk
[root@centos-7 asterisk-13.5.0]# chown -R asterisk.asterisk /usr/lib64/asterisk
[root@centos-7 asterisk-13.5.0]# systemctl restart asterisk
[root@centos-7 asterisk-13.5.0]# systemctl status asterisk
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.
[root@centos-7 ~]# systemctl start firewalld
[root@centos-7 ~]# systemctl enable firewalld
Now allow access to the ports that are being used in asterisk PBX by adding the following rules
[root@centos-7 ~]# firewall-cmd --zone=public --add-port=5060/udp --permanent
success
[root@centos-7 ~]# firewall-cmd --zone=public --add-port=5060/tcp --permanent
success
[root@centos-7 ~]# firewall-cmd --zone=public --add-port=5061/udp --permanent
success
[root@centos-7 ~]# firewall-cmd --zone=public --add-port=5061/tcp --permanent
success
[root@centos-7 ~]# firewall-cmd --zone=public --add-port=4569/udp --permanent
success
[root@centos-7 ~]# firewall-cmd --zone=public --add-port=5038/tcp --permanent
success
[root@centos-7 ~]# firewall-cmd --zone=public --add-port=10000-20000/udp --permanent
success
To load new firewall rules, use the below command.
[root@centos-7 ~]# firewall-cmd --reload
To confirm that all rules had been added , you can by using the command as shown in the image.
Let‘s connect to the MySQL MariaDB and create new user and database then provide it all privileges using the following commands.
[root@centos-7 ~]# 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 ServerCopyright (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 asterisk@localhost IDENTIFIED BY ‘******‘;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cdrdb.* TO asterisk@localhost IDENTIFIED BY ‘******‘;
MariaDB [(none)]> flush privileges;
MariaDB [(none)]>
Launch Asterisk for the first time after its setup on Centos 7 using below command.
[root@centos-7 ~]# asterisk -r
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)
标签:
原文地址:http://blog.csdn.net/hanzheng260561728/article/details/51295539