Asterisk, as PBX software, is an extremely popular voice call management tool in companies around the world. Thanks to its flexibility and advanced features, Asterisk has become a popular choice for organizations looking for telecommunications solutions. Asterisk 20 release introduces a number of new features and improvements that can increase the performance and flexibility of your phone system.
In this post, we will discuss the process of installing Asterisk 20 on Amazon Linux 2023 using the capabilities of the AWS cloud. This guide will help you step by step to install and configure Asterisk 20 on your Amazon Lightsail instance, although on EC2 it will be very similar.
We’ll walk you through downloading, compiling, and running this version of Asterisk on Amazon Linux 2023, providing comprehensive and easy-to-understand instructions to help you install this software successfully.
You can install Asterisk on one of the popular free Linux distributions, such as Amazon Linux 2023 described here. If you prefer a different Linux distribution, you can also see our articles about installing Asterisk on Alma Linux, Rocky, Debian, Ubuntu, CentOS 7, CentOS Stream 8.Click go to one of these links to see how to install on other Linux systems.
Table of Contents
1) Installing Amazon Linux 2023
We will install Amazon Linux 2023 in the cloud, directly on the Amazon Lightsail virtualization environment. I assume you have your account there and your SSH key imported. We choose the platform for installation: Linux/Unix
and the ready image of Amazon Linux 2023 (Operating System (OS) only)
.
We will connect to the new instance using the imported SSH key. First, we will select the parameters of the virtual machine. I suggest staying with the standard options, i.e. Dual-stack
(providing us with communication over both IPv4 and IPv6) and $10 per month
for the first three months for free (it will give us a machine with 2GB of memory, 2 processors and 60GB of disk with a transfer of up to 3 TB)
Then enter an instance name that you recognize and click Create instance
For a moment, your tile with the new instance will be gray and in a pending state. Once it goes into running state, click on it to see more options.
Here we see, among other things, the possibility of connecting from the browser via SSH. There is also important information about the user we will connect to: ec2-user
. In this tab we can also configure network parameters. By default, after clicking Networking, it looks like the picture below.
Using the trash icon, we remove the opening to the world for the HTTP protocol. By clicking +Add rule
, we add the possibility of communication via UDP on port 5060 for VoIP telephony purposes. We disable the possibility of communication via IPv6, and add a static IP address (Attach static IP
). This will make our work easier because otherwise, after each restart of the machine, our IP address would change .
Now we can connect to the machine using either a browser window or, as in my case, my favorite putty tool. Of course, we enter the static IP address we obtained.
2) System preparation
We will now update the system and install the necessary software such as the handy nano text editor, wget and tar unpacking software downloader and other dependencies. We perform these operations on the root user.
sudo dnf -y update
sudo dnf -y install nano wget tar epel-release chkconfig libedit-devel
It turns out that some of these activities are unnecessary because the system already has the latest updates and some additional software.
3) SELinux options
We will also check the status of SELinux.
sudo nano /etc/sysconfig/selinux
It turns out that the permissive mode is suitable for us, so we do not make any changes.
OPTION
You can also completely disable SELinux by typing disabled instead of permissive.
sed -i s/SELINUX=permissive/SELINUX=disabled/g /etc/selinux/config
reboot
You can also hold off on restarting and temporarily disable SELinux with the command:
setenforce 0
4) Configuring software dependencies
First, download the Asterisk sources. The /usr/src
directory is a convenient place to store all your installations. We download the software from the official Asterisk website.
cd /usr/src
sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20-current.tar.gz
sudo tar zxvf asterisk-20-current.tar.gz
sudo rm -rf asterisk-20-current.tar.gz
cd asterisk-20*/
Now we will install the necessary Asterisk dependencies. We can also switch to the root account for convenience.
sudo -i
contrib/scripts/install_prereq install
ATTENTION!!! Almost immediately we get a misleading message: install completed successfully
It turns out that the install_prereq
script did not recognize the type of our Linux. In the os-release
file we can find this information (ID=”amzn” and ID_LIKE=”fedora”)
cat /etc/os-release
We will modify the install_prereq file. We will add one more condition to check the operating system: elif [ -f /etc/os-release ] && . /etc/os-release && [ "$ID" = "amzn" ]; then handle_rh
We choose handle_rh
, which is a family based on Red Hat, because Amazon Linux comes from this environment. More on that you can read here: https://aws.amazon.com/linux/amazon-linux-2023/
nano contrib/scripts/install_prereq
Now we will execute the install command again.
contrib/scripts/install_prereq install
Then we will configure the Asterisk.
Due to the fact that chan_pjsip
requires some additional libraries, we also add the --with-jansson-bundled
option
So our configurator command will be:
./configure --with-jansson-bundled
ATTENTION!
If we do not add the --with-jansson-bundled
option, the configuration will stop with the following error:
configure: *** Asterisk requires libjansson >= 2.11 and no system copy was found
This stage should end with the display of our system logo.
5) Asterisk compilation and installation
Now we can select additional components to install, for example additional sound packs from the Core Sound Packages, Music on Hold and Extra Sound sections
make menuselect
Here, unlike Alma Linux, the chan_sip and odbc modules are already installed and can be selected immediately. After selecting the appropriate options and dependencies, execute the make
command itself to prepare the Asterisks for proper installation. This and the next process may take a little longer.
make
Calling make install
will finally install Asterisk on your server
make install
Then we will create sample documentation files and create a basic Asterisk configuration.
make samples
mkdir /etc/asterisk/samples
mv /etc/asterisk/*.* /etc/asterisk/samples/
make basic-pbx
Asterisk is now ready. Unfortunately, there are no startup files yet. On CentoOS, Debian, Ubuntu you can do make config
, but Amazon Linux 2023, AlmaLinux or Rocky don’t understand it. We need to use systemd
to manage the asterisk service. I invite you to read the article devoted to this topic. To do this, we will create an asterisk.service file and enter the necessary information into it.
touch /usr/lib/systemd/system/asterisk.service
cat <<'EOF' >/usr/lib/systemd/system/asterisk.service
[Unit]
Description=Asterisk PBX and telephony daemon.
#After=network.target
#include these if Asterisk need to bind to a specific IP (other than 0.0.0.0)
Wants=network-online.target
After=network-online.target network.target
[Service]
Type=simple
Environment=HOME=/var/lib/asterisk
WorkingDirectory=/var/lib/asterisk
ExecStart=/usr/sbin/asterisk -mqf -C /etc/asterisk/asterisk.conf
ExecReload=/usr/sbin/asterisk -rx 'core reload'
ExecStop=/usr/sbin/asterisk -rx 'core stop now'
LimitCORE=infinity
Restart=always
RestartSec=4
# Prevent duplication of logs with color codes to /var/log/messages
StandardOutput=null
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
6) Launch of Asterisk
Now we will add the asterisk service to the startup, start it and check its status. If you see the word active (running)
, you have just started Asterisk!
systemctl enable asterisk.service
systemctl start asterisk
systemctl status asterisk
WARNING
However, if out of habit you executed the make config
command and tried to start the asterisk service, you will unfortunately receive the error: "Job for asterisk.service failed because the control process exited with error code."
and "Active: failed (Result: exit-code)"
and further messages like:
asterisk.service: Control process exited, code=exited, status=1/FAILURE
asterisk.service: Failed with result 'exit-code'.
Failed to start LSB: Asterisk PBX.
This is because Amazon Linux does not create startup files using make config. You should use the systemd described earlier
Before doing this, you need to remove the incorrectly created connections.
systemctl disable asterisk.service
You can then run the switchboard with the command asterisk -r
and start working.
asterisk -r
If you would like to monitor everything on your switchboard, try our VOIPERO software
Installation and configuration takes a few moments and the system is now available completely free of charge.
Read what our VOIPERO system can do at live monitoring and reporting of VoIP systems based on Asterisk.