How to Install Asterisk on CentOS 7

How to install asterisk on centos 7

In this tutorial we will show you how to install Asterisk on a CentOS 7 VPS. Asterisk is an open source software implementation of a telephone private branch exchange (PBX) and includes many features such as: voice mail, conference calling, call recorder, automatic call distribution, interactive voice response, realtime monitoring and debugging console etc.

Let’s start the installation. Make sure your server OS is fully up-to-date:

yum clean all
yum update

Install all required packages and dependencies on your Asterisk VPS:

yum groupinstall core base "Development Tools"
yum install lynx bison php-mbstring php-pear php-gd php-xml libsepol-devel libtiff-devel openssl-devel subversion e2fsprogs-devel keyutils-libs-devel krb5-devel libogg libogg-devel libtool libtool-ltdl-devel kernel-headers kernel-devel tftp-server ncurses-devel sendmail sendmail-cf sox newt-devel libtiff-devel subversion doxygen texinfo mysql-connector-odbc unixODBC-devel sox gnutls-devel ncurses-devel net-snmp-devel neon-devel uuid-devel libuuid-devel audiofile-devel gtk2-devel speex-devel gsm-devel sqlite-devel perl-DateManip spandsp-devel freetds-devel iksemel-devel corosynclib-devel lua-devel radiusclient-ng-devel libxslt-devel portaudio-devel libical-devel gmime-devel bluez-libs-devel jack-audio-connection-kit-devel libedit-devel jansson-devel libsrtp-devel

Install pjproject

cd /opt 
git clone git:// pjproject 
cd pjproject/ 
./configure --libdir=/usr/lib64 --prefix=/usr --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr
make dep 
make install 

Install SRTP

cd /opt  
tar zxvf srtp-1.4.4.tgz
cd srtp 
./configure CFLAGS=-fPIC --prefix=/usr  
make runtest
make install

Install jansson

cd /opt 
tar zvxf jansson-2.7.tar.gz 
cd jansson-2.7
autoreconf -i
./configure --prefix=/usr/ --libdir=/usr/lib64
make install 

Install Lame

cd /opt 
tar zxvf lame-3.99.5.tar.gz 
cd lame-3.99.5
make install

Install Asterisk

Add a new user named ‘asterisk’:

adduser asterisk -M -c "Asterisk User"
cd /opt
tar zxvf asterisk-13-current.tar.gz
cd asterisk-13*
contrib/scripts/install_prereq install ./configure --libdir=/usr/lib64 contrib/scripts/ make menuselect

Choose which modules to build, select ‘Save & Exit’ and continue with the installation:

make install 
make config 
chkconfig asterisk off

Set permissions of certain files and directories related to Asterisk:

chown asterisk. /var/run/asterisk
chown asterisk. -R /etc/asterisk
chown asterisk. -R /var/{lib,log,spool}/asterisk
chown asterisk. -R /usr/lib64/asterisk
chown asterisk. -R /var/www/

Edit the PHP configuration file and set the upload_max_size value to 128 MB or higher.

vi /etc/php.ini
upload_max_filesize = 128M

Edit the main Apache configuration file (/etc/httpd/conf/httpd.conf) and change user and group from ‘apache’ to ‘asterisk’. Also, change ‘AllowOverride None’ directive to ‘AllowOverride All’.
Restart the Apache web server for the changes to take effect:

systemctl restart httpd.service

Log in to the MariaDB server using the ‘root’ user login credentials and create new user and two databases:

mysql -u root -p
MariaDB [(none)]> CREATE DATABASE asterisk;
MariaDB [(none)]> CREATE DATABASE asteriskcdrdb;
MariaDB [(none)]> CREATE USER 'asterisk'@'localhost' IDENTIFIED BY 'Y0uR-PASSW0RD';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON asterisk.* TO 'asterisk'@'localhost';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO 'asterisk'@'localhost';
MariaDB [(none)]> quit;

Do not forget to replace ‘Y0uR-PASSW0RD’ with a strong password.


Enable log file rotation:

vi /etc/logrotate.d/asterisk

add the following lines:

/var/log/asterisk/full {
        rotate 5
        create 0640 asterisk asterisk
        /usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null || true

That is it. The Asterisk and installation is complete.

Of course you don’t have to install Asterisk on CentOS 7 yourself if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install Asterisk on CentOS7 for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

How to install Nagios3 and Check_MK on an Ubuntu 12.04 LTS VPS
How to install Gallery3 on an Ubuntu 14.04 LTS VPS
How to secure your LEMP stack

    Great article. Thank you

  • Fahad Snafee

    Thanks for this! followed everything that’s written here and it works 100%

  • Bagus Kholilul

    I’ve followed all steps but i can’t found the sip.conf and extensions. Conf, so where i can create users

  • admin


    Author Reply

    You can find the configuration files in the /etc/asterisk directory.

  • Bagus K

    Bagus KBagus K

    Author Reply

    yes i see, but still not found the sip and extension.conf, i’ve installed the asterisk

    • admin


      Author Reply

      Please check in the /opt/asterisk-13.17.0/configs/samples/ directory.

  • Bagus K

    Bagus KBagus K

    Author Reply

    ok thank you i’ve reinstall and i’ve notice srtp warning shutdown, now i found the sip.conf, so where i must to configure the registration user , in config/samples or in /etc/asterisk ? because i’ve create user and dialplan on etc/asterisk/ sip.conf and extensions.conf my softphone can’t registration
    thank you

    • admin


      Author Reply

      You should edit the configuration files in the /etc/asterisk directory and then restart Asterisk for the changes to take effect.

Free Migration to RoseHosting. Award Winning Linux VPS Hosting with Fully Managed Support. Coupon RHBLOG50 for 50% offOrder Now