Updated: 2017/08/20 – Fixed a few typos, changed apt-get instructions to apt, re-did the recommendations section, and removed Google Voice prerequisite section (since it’s been broken a lot lately, it will be a new separate post when I get it to work).
These instructions are a modification of my earlier FreePBX instructions. I ended up not liking FreePBX installed mostly because it makes Asterisk configuration non-standard, and for module compatibility, makes it produce a lot of errors. These errors could be ignored, but my OCD won’t let me personally ignore them. The huge advantage to FreePBX however is the GUI, which makes configuring things a lot easier. The downside to that though is that troubleshooting is a lot harder. Basically it boils down to forcing myself to learn Asterisk the correct way, through the various configuration files.
This assumes you are starting from a clean empty box and you are installing Ubuntu fresh from CD/USB. This is strongly recommended so that there are no other issues. The instructions install a very basic Asterisk install, but gets it ready for databases and other additions.
Note: These instructions are meant to be followed top down. Skipping non-optional sections will have dire consequences.
Run as root
I recommend following the instructions below “as root”, otherwise you will have to put sudo in front of each command.
Keep the sources you download. If you have to make a change, such as add a DAHDI card or update Asterisk, you can recompile/reinstall Asterisk easily from source after making low level changes. Same if you need to change DAHDI itself at that level. The sources don’t take that much room anyway. Keep in mind though, when re-compiling don’t run the commands that generate example configuration files that will overwrite yours.
BACK UP YOUR CONFIGS!
Always back up your configuration files, and off machine. There are a LOT of options out there for Linux to back up file/machines to other machines. It’s worth it to spend some time making always up to date backups that are off your machine so you don’t lose the configs you spent hours and hours on when the drive dies or something else happens to the machine. I speak from personal experience here where I lost my extensions.conf that I spent several full days on to get just right because I was too lazy to make backups. I said “oh I will get around to it”. Don’t “get around to it”, do it NOW. My favorite is a short shell script that tarballs the /etc directory and scp every day, or week depending.
Install Ubuntu Server
You can install 14.04 or 16.04. However, as of this update of the article the mysql driver for CDR reports is broken in 16.04.
During the installation process, select the OpenSSH server option during Software Selection. The rest of the needed packages will be installed later. Otherwise, run the setup as normal.
Setting up the new installation:
At this point, I strongly recommend setting up a static IP address for your Asterisk, but this is optional:
See: Ubuntu 14.04+: Changing to Static IP (Opens in new tab)
Make sure DNS works (and you can resolve names outside of your network):
If not, then troubleshoot your network connectivity before continuing.
Update using apt, upgrade the system, and install dependencies then reboot (Make sure to scroll over to get the whole command):
apt update; apt dist-upgrade -y; apt install -y build-essential git-core pkg-config subversion libjansson-dev sqlite autoconf automake libtool libxml2-dev libncurses5-dev unixodbc unixodbc-dev libasound2-dev libogg-dev libvorbis-dev libneon27-dev libsrtp0-dev libspandsp-dev uuid uuid-dev sqlite3 libsqlite3-dev libgnutls-dev libtool-bin python-dev texinfo; reboot
Optional Asterisk Prerequisites
DAHDI (if you have/will have physical hardware):
cd /usr/src wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz tar xvfz dahdi-linux-complete-current.tar.gz cd dahdi-linux-complete-* make all && make install && make config cd tools make install-config dahdi_genconf modules
Note: You will see a bunch of messages like “Can’t read private key”. These can be ignored and are non-critical.
Reboot and re-run “sudo -i”.
LIBPRI (if you have/will have physical E1/T1/J1/ISDN cards):
cd /usr/src wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz tar xvfz libpri-1.4-current.tar.gz cd libpri-* make && make install
pjproject (if you need PJSIP, which you probably don’t):
cd /usr/src git clone https://github.com/asterisk/pjproject.git cd pjproject ./configure --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr make dep && make && make install
Compile and install Asterisk:
cd /usr/src wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz tar xvfz asterisk-13-current.tar.gz cd asterisk-* ./configure ./contrib/scripts/get_mp3_source.sh #If you want mp3 support make menuselect
You will be prompted at the point to pick which modules to build. Most of them will be enabled, but if you want to have MP3 support, you need to manually turn on ‘format_mp3’ on the first page. Also, select app_meetme if the MeetMe conference bridge is desired. I also recommend selecting a package from “Extras Sound Packages” for some more cool sounds to play with.
Selecting ‘Save & Exit’ to continue.
make && make install && make config && make samples ldconfig
Optional: Install Asterisk-Extra-Sounds:
Note that this installs the (8khz) ‘wav’ sound files. If you’re planning on running G722 (High Definition ‘Wideband’) audio, you also want to download the 722 codec pack, which is the second part. If you’re not planning on using Wideband, you can skip that part.
cd /var/lib/asterisk/sounds wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz tar xvfz asterisk-extra-sounds-en-wav-current.tar.gz rm -f asterisk-extra-sounds-en-wav-current.tar.gz # Wideband Audio download (Optional) wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz tar xfz asterisk-extra-sounds-en-g722-current.tar.gz rm -f asterisk-extra-sounds-en-g722-current.tar.gz
Start Asterisk and enjoy!
Check out the console:
Console with a lot of feedback (very useful for troubleshooting):
Note: If you don’t plan on connecting Asterisk up to LDAP (or don’t know what LDAP is), you can unload that module now and remove some non-critical startup errors:
In /etc/asterisl/modules.conf, add the following to the bottom:
noload => res_config_ldap.so
This module is loaded by default, and can be re-loaded when needed by removing or commenting this line.
Have a physical card? Check my article to configure DAHDI next: Setting Up DAHDI
I also recommend checking out my article on securing Asterisk: Securing Asterisk 13