How to Install Asterisk 13 and PJSIP on CentOS 6With the release of a certified branch of Asterisk 13, the Asterisk training team decided now is the time to provide a brief set of “install from source” instructions. What follows is my three step program to install Asterisk 13. If you are experienced with earlier versions of Asterisk there are some changes to consider, namely the new SIP channel driver powered by the PJSIP SIP stack. The new channel driver is called PJSIP and has been the topic of a few wiki articles and conference presentations already. The original SIP channel driver has been moved to extended support and will not compile by default in Certified Asterisk 13. If you’re still unclear about the impact of the new channel driver, I encourage you to dig into resources linked from this post.
Things to consider
- These instructions have been tested on a freshly installed CentOS 6.6 x86_64 virtual server.
- These instructions must be modified to work with the 32-bit version of CentOS.
- I will point out alternate steps for the 32-bit version of CentOS where appropriate.
- Because the focus of this post is the new SIP channel driver I have not included instructions for DAHDI and LibPRI. Instructions for this process can be found here.
- For the purposes of this installation we recommend changing SELinux configuration from the default of “enforcing” to “permissive”. Permissive mode will not enforce security policy but will log actions which can be helpful when you need to re-enable SELinux. There are many ways to manipulate SELinux settings that are outside the scope of this article. A typical method is to use a text editor to modify the ‘SELINUX=’ line in /etc/selinux/config by changing “enforcing” to “permissive”. After you update and disable SELinux, you may need to reboot and relabel the file system. Click here for more information about SELinux.
- I would also greatly discourage using any part of these instructions on a production server until you have vetted them through your own laboratory setup. If you wish to live dangerously I wish you luck.
Step 1 – Setup the environmentThe first step is to install the dependencies required to build the PJSIP libraries and Asterisk 13. Using the CentOS yum package manager we’ll update all currently installed packages to their latest version and then install some of the most common dependencies for Asterisk and PJSIP.
# yum updateThe kernel-devel package we install next could be slightly ahead of the kernel actually in use on your system. This is why we did a yum update first. If the kernel has been updated, be sure to reboot before moving forward. More information about the kernel-devel packages available for CentOS can be found here. The following command will install several packages that are needed to compile and install PJSIP and Asterisk.
# 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
NOTE:If you encounter an issue resolving the dependencies check out the fantastic install_prereq tool shipped with the Asterisk tarball. Located in the contrib/scripts directory of the Asterisk source directory that will be unpacked in step 3.
Step 2 – Install pjprojectNext you will download and install the pjproject sip library directly from pjsip.org. But first we’ll change directories to work in the /usr/src directory.
# cd /usr/src # wgetThis will create the # tar -jxvf pjproject-2.3.tar.bz2
pjproject-2.3directory. Change to this directory and run the following set of commands to build and install the pjproject sip library.
# cd pjproject-2.3 # ./configure CFLAGS="-DNDEBUG -DPJ_HAS_IPV6=1" --prefix=/usr --libdir=/usr/lib64 --enable-shared --disable-video --disable-sound --disable-opencore-amrThis command must be modified when using a 32-bit operating system. Just remove the
--libdir=/usr/lib64option from the command. The other options may be different depending on how you want to use Asterisk. More information about these options can be found on the Asterisk wiki or by running the command
./configure --help. The next four commands will build, install and link the pjsip libraries.
# make dep # make # make install # ldconfigAnd finally this next command will verify the pjsip libraries have been dynamically linked.
# ldconfig -p | grep pjYour output should look something like this:
Step 3 – Install Asterisk 13Now we’ll download and install the latest Certified-Asterisk 13.1 branch from source. First we’ll change directory up one level to
# cd ..Then we’ll use the wget command to download the tarball from downloads.asterisk.org.
# wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gzNext the tar command will unpack the Asterisk source code into a new directory named
asterisk-13. Then we’ll go to the new directory.
# tar -zxvf asterisk* # cd asterisk-*
Install the dependencies
/usr/src/asterisk-*/contrib/scripts ./install_prereq install
The next set of commands will build and install Asterisk. Remember to skip the
--libdir=/usr/lib64option for 32-bit versions of CentOS. In that case just run the command
# ./configure --libdir=/usr/lib64Next you will run the make menuselect command. This step will verify if the pjsip channel driver dependencies have been successfully installed.
# make menuselectUse the arrow keys to navigate to “Resource Modules” in the left column, about halfway down the list. Press the right arrow key and then scroll down until you see the list of modules beginning with “res_pjsip_”. If these modules have “XXX” to the left of their name then the dependencies have not been met. You’ll need to go back to the /usr/src/pjproject directory, run the “make distclean” command and start over carefully looking for any error messages and proceed from there. If you see [*] instead of XXX then the res_pjsip module’s dependencies have been met and you can proceed to the next steps. Your menuselect screen should look like this:
After exiting the menuselect screen the next set of commands will build and install Asterisk along with a set of sample configuration files.
NOTE IF YOU ARE RUNNING IN A VIRTUAL MACHINE OR VPS DISABLE THE OPTION BUILD NATIVE LOCATED ON COPILER FLAGS
# make && make install # make samplesIf you want Asterisk to start at boot time use the following command to setup the Asterisk service.
# make config
Run ldconfig command to resolve symb link issue.
ldconfigAnd finally, run the command “service asterisk start” to immediately begin the Asterisk service without the need to reboot first. Now you’re ready to begin configuring the PJSIP channel driver on your freshly installed instance of Asterisk 13. If you run into an issue with these instructions feel free to leave a comment on this post, check the official Asterisk forums or reach out to the Asterisk community for help.
Special thanks to the Asterisk Development team for pointing out some helpful improvements to these instructions.