{"id":12936,"date":"2019-03-29T03:27:35","date_gmt":"2019-03-29T03:27:35","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12936"},"modified":"2019-03-29T03:27:35","modified_gmt":"2019-03-29T03:27:35","slug":"how-to-install-asterisk-on-centos-7","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/29\/how-to-install-asterisk-on-centos-7\/","title":{"rendered":"How to Install Asterisk on CentOS 7"},"content":{"rendered":"<p><strong>Asterisk<\/strong>\u00a0is an open source framework used for building communication applications. You can use it to turn a local computer or server to communication server. It is used to power IP PBX systems, VoIP gateways, conference servers and other solutions. It\u2019s used by all kind of organizations worldwide and finally, but not last it is free and open source.<\/p>\n<p>In this tutorial, we are going to show you how to install\u00a0<strong>Asterisk<\/strong>\u00a0on\u00a0<strong>CentOS 7<\/strong>\u00a0(instructions also works on\u00a0<strong>RHEL 7<\/strong>), but before we start, we will need to make some preparations so\u00a0<strong>Asterisk<\/strong>\u00a0can run smoothly after the installation.<\/p>\n<h3>Step 1: Disable SELinux on CentOS 7<\/h3>\n<p>To do this, first SSH to your system and using your favorite command line text editor, open\u00a0<strong>\/etc\/selinux\/config<\/strong>and disable\u00a0<strong>SELINUX<\/strong>.<\/p>\n<pre># vim \/etc\/selinux\/config\r\n<\/pre>\n<p>SELinux line should look like this:<\/p>\n<pre>SELINUX=disabled<\/pre>\n<p>Now reboot your system. Once it comes back SSH again to that system.<\/p>\n<h3>Step 2: Install Required Packages<\/h3>\n<p><strong>Asterisk<\/strong>\u00a0has quite a few requirements that need to be installed. You can use the following\u00a0<a href=\"https:\/\/www.tecmint.com\/20-linux-yum-yellowdog-updater-modified-commands-for-package-mangement\/\" target=\"_blank\" rel=\"noopener\">yum command<\/a>\u00a0to install required packages as shown.<\/p>\n<pre># yum install -y epel-release dmidecode gcc-c++ ncurses-devel libxml2-devel make wget openssl-devel newt-devel kernel-devel sqlite-devel libuuid-devel gtk2-devel jansson-devel binutils-devel\r\n<\/pre>\n<p>Before we continue further, create a new user through which we will use\u00a0<strong>asterisk<\/strong>.<\/p>\n<pre># adduser asterisk -c \"Asterisk User\"\r\n# su asterisk\r\n<\/pre>\n<p>Next, install\u00a0<strong>PJSIP<\/strong>, is a free open source multimedia communication library that implements standard based protocols such as SIP,SDP,RTP,STUN,TURN and ICE. It is the\u00a0<strong>Asterisk SIP<\/strong>\u00a0channel driver that should improve the clarity of the calls.<\/p>\n<p>To get the latest version, first let\u2019s create a temporary directory where we will build the package from source.<\/p>\n<pre>$ mkdir ~\/build &amp;&amp; cd ~\/build\r\n<\/pre>\n<p>Now go the\u00a0<a href=\"https:\/\/www.pjsip.org\/download.htm\" target=\"_blank\" rel=\"nofollow noopener\">PJSIP download page<\/a>\u00a0and grab the package or use the following\u00a0<a href=\"https:\/\/www.tecmint.com\/10-wget-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">wget command<\/a>\u00a0to download the package directly in terminal.<\/p>\n<p>Note that by the writing of this article the latest version is\u00a0<strong>2.8<\/strong>, this may change in future, thus make sure to use the latest version:<\/p>\n<pre>$ wget https:\/\/www.pjsip.org\/release\/2.8\/pjproject-2.8.tar.bz2<\/pre>\n<p>Once the download is complete, extract the file and change to that directory.<\/p>\n<pre>$ tar xvjf pjproject-2.8.tar.bz2\r\n$ cd pjproject-2.8\r\n<\/pre>\n<p>The next step is to prepare the package to be compiled. You can use the following command:<\/p>\n<pre>$ .\/configure CFLAGS=\"-DNDEBUG -DPJ_HAS_IPV6=1\" --prefix=\/usr --libdir=\/usr\/lib64 --enable-shared --disable-video --disable-sound --disable-opencore-amr\r\n<\/pre>\n<p>You should not see any errors or warnings. Ensure that all dependencies are met:<\/p>\n<pre>$ make dep\r\n<\/pre>\n<p>And now we can complete the install and link libraries with:<\/p>\n<pre>$ make &amp;&amp; sudo make install &amp;&amp; sudo ldconfig\r\n<\/pre>\n<p>Finally ensure that all libraries are installed and present:<\/p>\n<pre>$ ldconfig -p | grep pj\r\n<\/pre>\n<p>You should get the following output:<\/p>\n<pre>        libpjsua2.so.2 (libc6,x86-64) =&gt; \/lib64\/libpjsua2.so.2\r\n        libpjsua2.so (libc6,x86-64) =&gt; \/lib64\/libpjsua2.so\r\n        libpjsua.so.2 (libc6,x86-64) =&gt; \/lib64\/libpjsua.so.2\r\n        libpjsua.so (libc6,x86-64) =&gt; \/lib64\/libpjsua.so\r\n        libpjsip.so.2 (libc6,x86-64) =&gt; \/lib64\/libpjsip.so.2\r\n        libpjsip.so (libc6,x86-64) =&gt; \/lib64\/libpjsip.so\r\n        libpjsip-ua.so.2 (libc6,x86-64) =&gt; \/lib64\/libpjsip-ua.so.2\r\n        libpjsip-ua.so (libc6,x86-64) =&gt; \/lib64\/libpjsip-ua.so\r\n        libpjsip-simple.so.2 (libc6,x86-64) =&gt; \/lib64\/libpjsip-simple.so.2\r\n        libpjsip-simple.so (libc6,x86-64) =&gt; \/lib64\/libpjsip-simple.so\r\n        libpjnath.so.2 (libc6,x86-64) =&gt; \/lib64\/libpjnath.so.2\r\n        libpjnath.so (libc6,x86-64) =&gt; \/lib64\/libpjnath.so\r\n        libpjmedia.so.2 (libc6,x86-64) =&gt; \/lib64\/libpjmedia.so.2\r\n        libpjmedia.so (libc6,x86-64) =&gt; \/lib64\/libpjmedia.so\r\n        libpjmedia-videodev.so.2 (libc6,x86-64) =&gt; \/lib64\/libpjmedia-videodev.so.2\r\n        libpjmedia-videodev.so (libc6,x86-64) =&gt; \/lib64\/libpjmedia-videodev.so\r\n        libpjmedia-codec.so.2 (libc6,x86-64) =&gt; \/lib64\/libpjmedia-codec.so.2\r\n        libpjmedia-codec.so (libc6,x86-64) =&gt; \/lib64\/libpjmedia-codec.so\r\n        libpjmedia-audiodev.so.2 (libc6,x86-64) =&gt; \/lib64\/libpjmedia-audiodev.so.2\r\n        libpjmedia-audiodev.so (libc6,x86-64) =&gt; \/lib64\/libpjmedia-audiodev.so\r\n        libpjlib-util.so.2 (libc6,x86-64) =&gt; \/lib64\/libpjlib-util.so.2\r\n        libpjlib-util.so (libc6,x86-64) =&gt; \/lib64\/libpjlib-util.so\r\n        libpj.so.2 (libc6,x86-64) =&gt; \/lib64\/libpj.so.2\r\n        libpj.so (libc6,x86-64) =&gt; \/lib64\/libpj.so\r\n<\/pre>\n<h3>Step 3: Install Asterisk in CentOS 7<\/h3>\n<p>We are now ready to initiate the installation of Asterisk. Navigate back to our\u00a0<strong>~\/build<\/strong>\u00a0directory:<\/p>\n<pre>$ cd ~\/build\r\n<\/pre>\n<p>Go to\u00a0<a href=\"https:\/\/www.asterisk.org\/downloads\" target=\"_blank\" rel=\"noopener\">Asterisk download page<\/a>\u00a0and grab the the latest version or you can use the following\u00a0<a href=\"https:\/\/www.tecmint.com\/wget-download-file-to-specific-directory\/\" target=\"_blank\" rel=\"noopener\">wget command<\/a>\u00a0to download the file in terminal.<\/p>\n<pre>$ wget http:\/\/downloads.asterisk.org\/pub\/telephony\/asterisk\/asterisk-16-current.tar.gz\r\n<\/pre>\n<p>By the writing of this tutorial, the latest Asterisk version is\u00a0<strong>16<\/strong>. Make sure that you are downloading the latest version of Asterisk, when you are following the steps.<\/p>\n<p>Now extract the archive and navigate to the newly created directory:<\/p>\n<pre>$ tar -zxvf asterisk-16-current.tar.gz\r\n$ cd asterisk-16.0.0\r\n<\/pre>\n<p>This is the time to mention, that if you wish to enable mp3 support to play music while client is on hold, you will need to install few more dependencies. These steps are optional:<\/p>\n<pre># yum install svn\r\n# .\/contrib\/scripts\/get_mp3_source.sh\r\n<\/pre>\n<p>After the second step, you should get output similar to these:<\/p>\n<pre>A    addons\/mp3\r\nA    addons\/mp3\/MPGLIB_README\r\nA    addons\/mp3\/common.c\r\nA    addons\/mp3\/huffman.h\r\nA    addons\/mp3\/tabinit.c\r\nA    addons\/mp3\/Makefile\r\nA    addons\/mp3\/README\r\nA    addons\/mp3\/decode_i386.c\r\nA    addons\/mp3\/dct64_i386.c\r\nA    addons\/mp3\/MPGLIB_TODO\r\nA    addons\/mp3\/mpg123.h\r\nA    addons\/mp3\/layer3.c\r\nA    addons\/mp3\/mpglib.h\r\nA    addons\/mp3\/decode_ntom.c\r\nA    addons\/mp3\/interface.c\r\n<\/pre>\n<div class=\"google-auto-placed ap_container\">\n<p>Start by running the configure script to prepare the package for compiling:<\/p>\n<pre>$ sudo contrib\/scripts\/install_prereq install\r\n$ .\/configure --libdir=\/usr\/lib64 --with-jansson-bundled\r\n$ make menuselect\r\n<\/pre>\n<p>If you get any missing dependencies install them. In my case, I got the following error:<\/p>\n<pre>configure: error: patch is required to configure bundled pjproject\r\n<\/pre>\n<p>To go around this simply run:<\/p>\n<pre># yum install patch \r\n<\/pre>\n<p>And re-run the configure script. Now lets start the build process:<\/p>\n<pre>$ make menuselect\r\n<\/pre>\n<p>After few seconds, you should get a list of features to enable:<\/p>\n<div id=\"attachment_30875\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/04\/Asterisk-Modules.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30875\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/04\/Asterisk-Modules.png\" sizes=\"auto, (max-width: 1670px) 100vw, 1670px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/04\/Asterisk-Modules.png 1670w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/04\/Asterisk-Modules-768x623.png 768w\" alt=\"Asterisk Modules\" width=\"1670\" height=\"1355\" aria-describedby=\"caption-attachment-30875\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-30875\" class=\"wp-caption-text\">Asterisk Modules<\/p>\n<\/div>\n<p>If you attempt to use music on hold feature, you will need to enable the \u201c<strong>format_mp3<\/strong>\u201d feature from \u201c<strong>Add-ons<\/strong>\u201d section. Save your list and run the following command:<\/p>\n<pre>make &amp;&amp; sudo make install\r\n<\/pre>\n<p>To install the sample configuration files, use the command below:<\/p>\n<pre>sudo make samples\r\n<\/pre>\n<p>To start Asterisk on boot, use:<\/p>\n<pre>sudo make config\r\n<\/pre>\n<p>As root user update the ownership of the following directories and files:<\/p>\n<pre># chown asterisk. \/var\/run\/asterisk\r\n# chown asterisk. -R \/etc\/asterisk\r\n# chown asterisk. -R \/var\/{lib,log,spool}\/asterisk\r\n<\/pre>\n<p>Finally let\u2019s test our installation with:<\/p>\n<pre>$ sudo service asterisk start\r\n$ sudo asterisk -rvv\r\n<\/pre>\n<p>You should see output similar to this one:<\/p>\n<pre>Asterisk 16.0.0, Copyright (C) 1999 - 2018, Digium, Inc. and others.\r\nCreated by Mark Spencer &lt;markster@digium.com&gt;\r\nAsterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.\r\nThis is free software, with components licensed under the GNU General Public\r\nLicense version 2 and other licenses; you are welcome to redistribute it under\r\ncertain conditions. Type 'core show license' for details.\r\n=========================================================================\r\nConnected to Asterisk 16.0.0 currently running on asterisk (pid = 3985)\r\nasterisk*CLI&gt;\r\n<\/pre>\n<p>If you want to see a list of available commands type:<\/p>\n<pre>asterisk*CLI&gt; core show help\r\n<\/pre>\n<p>To exit the Asterisk prompt, simply type:<\/p>\n<pre>asterisk*CLI&gt; exit\r\n<\/pre>\n<p>Asterisk will still be running in the background.<\/p>\n<h5>Conclusion<\/h5>\n<p>Now you have a running\u00a0<strong>Asterisk<\/strong>\u00a0server and you can start connecting phones and extensions and adjust your configuration per your needs. For more details how to achieve this, it is recommended to use the\u00a0<a href=\"https:\/\/wiki.asterisk.org\/wiki\/display\/AST\/Basic+PBX+Functionality\" target=\"_blank\" rel=\"nofollow noopener\">Asterisk Wiki page<\/a>. If you have any questions or comments, please let us know in the comment section below.<\/p>\n<p><a style=\"font-size: 1rem;\" href=\"https:\/\/www.tecmint.com\/install-asterisk-on-centos-7\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Asterisk\u00a0is an open source framework used for building communication applications. You can use it to turn a local computer or server to communication server. It is used to power IP PBX systems, VoIP gateways, conference servers and other solutions. It\u2019s used by all kind of organizations worldwide and finally, but not last it is free &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/29\/how-to-install-asterisk-on-centos-7\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Install Asterisk on CentOS 7&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12936","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12936"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12936\/revisions"}],"predecessor-version":[{"id":12937,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12936\/revisions\/12937"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}