Asterisk is a free and open source PBX to manage your calls automatically (perfect for a small business).
In this tutorial, I’ll show you how to install it on Raspberry Pi.
Asterisk can be installed on Raspberry Pi OS with the package manager (or “sudo apt install asterisk”), but the latest version is only available with the source archive from Asterisk.org.
The official website gives you the full documentation for everything, but in this post I will give you the short version, specifically for Raspberry Pi.
If you are looking for quick progress on Raspberry Pi, you can check out my e-book here. It’s a 30-day challenge, where you learn one new thing every day until you become a Raspberry Pi expert. The first third of the book teaches you the basics, but the following chapters include projects you can try on your own.
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!
- A Raspberry Pi: if possible a Raspberry Pi 4. The compilation is a very long process on an older model, and more power can be useful depending on what you’ll do with it.
- Raspberry Pi OS: if you don’t have it yet on a SD card. The lite version is fine, as there is no graphical interface for Asterisk. (download here).
- A basic SD card: if needed, you don’t need something expensive, Asterisk doesn’t require so much space. SanDisk basic model has excellent results for a cheap price (link here)
Here are the required steps to install Asterisk on a Raspberry Pi :
- Install and update Raspberry Pi OS.
- Download the Asterisk tarball from the official website.
- Extract the files and compile the source code.
- Install Asterisk with the default configuration files.
I’ll explain each step in the next sections.
Raspberry Pi OS installation
If you use a new SD card for Asterisk, you firstly need to install Raspberry Pi OS on it. As I already told you, the Lite version is perfect.
If you need a step-by-step tutorial on how to do this, you can check this one.
Once done, don’t forget to enable SSH and update your system before going further:
sudo apt update
sudo apt upgrade
As I will give you many commands to install and configure Asterisk, it’s better to copy and paste them from your computer directly.
Note: Asterisk is available in the Raspberry Pi OS repository (sudo apt install asterisk), but it’s an older version.
It’s OK for a quick try, but I don’t recommend it in production.
All Asterisk downloads are available on this page.
The first link is for FreePBX, it’s a built-in Asterisk system with an interface to manage Asterisk, but there is no image for Raspberry Pi.
Then you have an offer for Switchvox, and finally the source code just under (Asterisk Communications Framework).
You can download a tarball or use git to download the latest version.
I’ll 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 prefer:
- Install git:
sudo apt install git
- The documentation recommends to build Asterisk from /usr/local/src, so we will do this:
- Then download the git repository files:
sudo git clone https://gerrit.asterisk.org/asterisk asterisk
If you wonder what are DAHDI and LIBPRI on the official documentation, they are not required on Raspberry Pi.
DAHDI is an interface to manage interface cards (includes many drivers), but you probably don’t need it on Raspberry Pi.
LIBPRI is also not required, as it’s for ISDN interfaces.
As most of us will use asterisk as an IPBX with SIP and Internet, we don’t need them.
A bit lost in the Linux command line? Check this article first, which will give you the most important commands to remember and a free cheat sheet you can download to have them all at your fingertips.
As for most software built from source, the first step is to check that you have all the Asterisk requirements installed
- Go to the asterisk folder:
- Install the prerequisites:
sudo apt install libedit-dev sqlite3 libsqlite3-dev libjansson-dev libxml2-dev uuid-dev
- Run the configure script, to check that you have all the requirements installed:
If there is any error, there is probably a package missing on your system.
Use “apt search” to find the corresponding package and install it (feel free to leave a comment below if you find a package missing in my previous command on Raspberry Pi OS).
- Then, you need to choose the features you want to use with menuselect:
sudo make menuselect
- A window like this shows up:
Verify in each submenu that everything you need is checked.
Press SPACE to select/unselect any option. Some of them are not unavailable if the corresponding package is not installed.
If you don’t really know what you need, you can leave the default configuration.
Press ESC and S once done to save and exit.
- You can now run make to compile Asterisk:
It may take more or less time depending on your Raspberry Pi model and the features you chose (15-20min on a Raspberry Pi 4 with the default configuration).
- You can now use the following command to install all the files:
sudo make install
That’s it, then you have a few commands that are not mandatory but recommended if you are new on Asterisk:
- Installing sample files:
sudo make samplesThe goal here is to start with a default configuration.
It will create all the files in the Asterisk folder for you (with many comments in it), so you don’t start from scratch.
- Installing initialization scripts:
sudo make configI recommend doing this, it will add an initscript, to automatically start Asterisk on boot.
It’s also useful to start or stop the server if needed.
- Rotate log files:
sudo make install-logrotateAs we are on Raspberry Pi (so small disk space in general), it’s probably a good idea to do this.
It will install a script that manages the log rotation.
At this step, the installation is done, and you can continue with the configuration part.
Just in case you need it (probably), here are the commands you can use if you installed the initialization script:
- Start Asterisk:
sudo /etc/init.d/asterisk start
- Stop Asterisk:
sudo /etc/init.d/asterisk stop
- Check the status:
sudo /etc/init.d/asterisk status
I recommend checking the status before going further (and start the service if needed).
If it doesn’t work at this point with the default configuration, it’ll probably not work after your changes 🙂
If you don’t have the initialization script, you can start asterisk with:
sudo asterisk -gcv
Asterisk stops when you close your window or SSH connection (you can use a screen to keep it running in background).
The asterisk configuration is located in /etc/asterisk.
There are many files (119 in my test), so it’s difficult to explain in a few lines, but I will give you the more important later.
Just a quick note here, if you want to use or upload sounds in your configuration, they are located under /var/lib/asterisk/sounds.
By default, you’ll get only sounds in English, but many languages are available in menuselect if you need another one.
Main configuration files
As I told you, you don’t need all the configuration files, so I give you here the more important ones and what they are:
- sip.conf: In this file you need to configure your SIP accounts. SIP is a protocol to manage calls over the Internet. You need to find a provider (some are available for free like LinPhone), and see with them how to configure it on Asterisk.
- users.conf: It’s the same thing for each user (=phone or softphone). If you use a softphone on your computer, you need to define the SIP account in this file (number and password at least). Check the file sample for an example.
Asterisk is compatible with any SIP phone, I have used a lot of this brand in the past with great results if you are looking for one (Amazon).
- extensions.conf: It’s the Asterisk’s brain. In this file, you manage what should happen when you receive or make a call. You can do a really short configuration that just make your phone ring when someone calls. Or do something more complicated, with opening hours, welcome message or several phones. It’s probably the most complicated file to understand when you start.
Basically, you don’t need to edit another file if you want a basic configuration.
I will not explain in details all the configuration here (let me know if you are interested, I can do a specific tutorial about this).
But you’ll find some help on this website:
And you’ll also find much help on other websites and forums, Asterisk is a really well-known product, with lots of users over the world.
Grab your free PDF file with all the commands you need to know on Raspberry Pi!
That’s it, you now know how to install Asterisk on a Raspberry Pi.
It seems to work correctly on a Raspberry Pi 4, so it could be a good idea at home or in a small business.
I’m using it for years at work, with 70 people answering calls for our customer service. Not on a Raspberry Pi, but the load average stays very low, even with that number of simultaneous calls.
You can do everything you want with it, and once you understand how it works, it’s powerful and not so complicated, but the learning curve may take some time.
Let me know if you want more details about Asterisk, I really like this topic and will be pleased to do other tutorials on it (even if the configuration part is not really specific to the Raspberry Pi).
If you have any comment, suggestion or just want to chat with us about this tutorial,
you can post your messages in the community on Patreon. See you there!
Raspberry Pi Resources
Not sure where to start?
Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.
Watch the Raspberry Pi Bootcamp course now
Master your Raspberry Pi in 30 days
Don’t want the basic stuff only? If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiples projects with step-by-step guides.
Download the e-book
If you just want to hang out with me and show your support, you can also join the Patreon community. I share behind-the-scenes content there and give you early access to my content. You’ll also get a shoutout when you join.
More details here
Need help to build something with Python?
Create, understand and improve any Python script for your Raspberry Pi.
Learn the essentials, step-by-step, without losing time understanding useless concepts.
Get the e-book now
You can also find all my recommendations for tools and hardware on this page.