How to install Asterisk on Raspberry Pi

Asterisk is a free, open source PBX that automatically manages your calls (perfect for a small business). In this tutorial, TipsMake.com will show you how to install Asterisk on a Raspberry Pi.

Things to prepare

  1. - A Raspberry Pi (if possible should be a Raspberry Pi 4): The compilation process is a very long process on older models and having more power can be helpful, depending on what you do with. Pi.
  2. - Raspberry Pi OS : Download Raspberry Pi OS, if you do not already have this operating system on SD card. The lite version is a good choice, as there is no need for Asterisk's graphical interface.
  3. - Basic SD card : You don't need an expensive SD card. Asterisk does not require a lot of space. Basic, cheap SanDisk models also give great results.

Install Asterisk

Install Raspbian

If you use a new SD card for Asterisk, you first need to install Raspberry Pi OS on it. As noted, the Lite version is the perfect choice.

Once done, don't forget to enable SSH and update the system before continuing:

sudo apt update sudo apt upgrade

Because the article will provide you with many commands to install and configure Asterisk, it is better to copy and paste them directly from your computer.

Download Asterisk

Note : Asterisk is available in the Raspberry Pi OS (sudo apt install asterisk)repository, but it is an older version. This version is fine for quick trial, but the article does not recommend for serious work.

All Asterisk downloads are available on this page here.

The first link is for FreePBX, which is an integrated Asterisk system with an interface for managing Asterisk, but there is no image for the Raspberry Pi.

Then there's Switchvox, and finally the source code right below (Asterisk Communications Framework).

You can download a tarball or use Git to download the latest version.

The article will show you how to do this with Git, this way it will always be the latest version, but you can download the archive if you like:

- Install git:

sudo apt install git

The document recommends Asterisk build from / usr / local / src , so the article will do this:

cd /usr/local/src

- Then download the git archive file:

sudo git clone https://gerrit.asterisk.org/asterisk asterisk

If you wonder what DAHDI and LIBPRI are on the official documentation, they are not required on the Raspberry Pi.

+ DAHDI is an interface for managing interface cards (including many drivers), but you probably don't need it on the Raspberry Pi.

+ LIBPRI is not required, because it is for the ISDN interface.

Since most people will use Asterisk as an IPBX with SIP and the Internet, you don't need them.

Install Asterisk

For most software that is built from source, the first step is to check that you have installed all the Asterisk requirements.

- Go to the Asterisk folder:

cd /usr/local/src/asterisk

- Install prerequisites:

sudo apt install libedit-dev sqlite3 libsqlite3-dev libjansson-dev libxml2-dev uuid-dev

- Run the configuration script, to check that you have installed all the requirements:

sudo ./configure

- If there are any errors, there may be a missing package on your system.

Use apt search to find the corresponding package and install it.

- Then you need to select the features you want to use with menu select :

sudo make menuselect

A window like this pops up:

How to install Asterisk on Raspberry Pi Picture 1How to install Asterisk on Raspberry Pi Picture 1 Select the features you want to use with menuelect

- Confirm in each submenu that everything you need is included.

- Click SPACEto select or deselect any option. Some of these options are not available if the corresponding package is not installed.

How to install Asterisk on Raspberry Pi Picture 2How to install Asterisk on Raspberry Pi Picture 2 Press SPACE to select or deselect any option

If you don't really know what you need, you can leave the default configuration.

- Click ESCand Safter completion to save and exit.

- Now you can run make to compile Asterisk:

sudo make

It may take more or less depending on the Raspberry Pi model and the features you have chosen (15 - 20 minutes on the Raspberry Pi 4 with default configuration)

Now you can use the following command to install all files:

sudo make install

Then you have a few optional but recommended commands, if you're new to Asterisk:

- Install the sample file:

sudo make samples

The goal here is to start with a default configuration. It will create all the files in the Asterisk folder for you (there are many comments in it), so you should not start from the beginning.

- Install initialization scripts:

sudo make config

The article recommends that you do this, it will add an initscript, to automatically start Asterisk on boot. It is also helpful to start or stop the server if needed.

- Rotate (handle the old log file according to the previous rule, and create a new log file) log file:

sudo make install-logrotate

As you are on a Raspberry Pi (with small disk space), it might be a good idea to do this. A script that manages the log file rotation will be installed.

At this stage, the installation is complete and you can continue with the configuration.

Service Asterisk

Just in case you need them, here are the commands you can use, if you have already installed the initialization script:

- Start Asterisk:

sudo /etc/init.d/asterisk start

- Stop Asterisk:

sudo /etc/init.d/asterisk stop

- Check status:

sudo /etc/init.d/asterisk status

The article recommends that you check the status before going further (and start the service if needed).

If everything does not work at this time with the default configuration, it may not work after you make changes.

If you don't have an initialization script, you can start Asterisk with:

sudo asterisk -gcv

Asterisk stops when you close a window or an SSH connection (you can keep it running in the background).

Configure Asterisk

Location of files

The Asterisk configuration is located in / etc / asterisk.

There are lots of files (119 in this test), so it's difficult to explain in a few lines, but the article will give you more important things later.

Just a quick note here that if you want to use or upload audio in your configuration, they are located in / var / lib / asterisk / sounds.

By default, you will only receive audio files in English, but many languages ​​are also available in menuselect if you need another option.

The main configuration file

As mentioned, you don't need all the configuration files, so the article provides you with important files here:

- sip.conf : In this file, you need to configure your SIP account. SIP is a protocol for managing calls over the Internet. You need to find a provider and see how to configure on Asterisk.

- users.conf: If you use a softphone (software program to make phone calls over the Internet by computer) on your computer, you need to identify the SIP account in this file (at least the number and password password).

- extend.conf: This is the 'brain' of Asterisk. In this file, you manage what happens when you receive or make a call. You can make a really short profile, only causing your phone to ring when someone calls. Or do something more complicated, with opening hours, welcome messages or a phone number. This is probably the most complex file to understand when starting out.

Basically, you don't need to edit another file if you want a basic configuration.

4.8 ★ | 4 Vote