Installing Asterisk 20 From source On Rocky 9

Update your system and install the required dependencies. At the same time, install a convenient text editor, for example Nano, and the wget and tar applications to download and unpack the installer. If we are used to the yum installer, here we will use the DNF package manager, which is its newer equivalent. Webrtc with Asterisk 16 : complete configuration with SIP

System Update

dnf -y update
dnf -y install nano wget tar epel-release chkconfig libedit-devel

Configuring software dependencies

First, download the Asterisk sources. The /usr/src directory is a convenient place to store all your installations.

wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20-current.tar.gz
tar zxvf asterisk-20-current.tar.gz
rm -rf asterisk-20-current.tar.gz
cd asterisk-20*/

Before continuing with the installation, we need to add all the dependencies from the previously loaded repositories.

contrib/scripts/install_prereq install

Finally, we can  configure our asterisk for the final build.

Rocky 9 requires a 64-bit system, so we add the --libdir=/usr/lib64 option to configure the command.

Due to the fact that chan_pjsip requires some additional libraries, we add two more options --with-jansson-bundled --with-pjproject-bundled

./configure --libdir=/usr/lib64 --with-pjproject-bundled --with-jansson-bundled

Compilation and installation

Now we can simply execute make command without parameters and compile the software. Of course, it is better to be able to choose additional options, functions, applications, codecs, so I suggest using make menuselect. It will display a menu where you can simply select what you need.

make menuselect

During the process, you can check or uncheck selected options, e.g. use ODBC instead of FILE storage for voicemail.

Sometimes the system will not allow you to select certain modules, but it also shows which dependencies are required.

Once you have selected the appropriate options, remember to select the Save & Exit exiting the configurator.

After selecting the appropriate options and dependencies, execute the make command itself and prepare for the actual installation. This and the next process may take several minutes.

make

The system will tell you what to do next. Executing  make install  will finally install Asterisk on your server.

make install

After successful installation, we will receive a window with information similar to the one below. Let’s start by making sample files with make samples. This will create all documentation files.

make samples

Asterisk is ready now (there is no information about it on the main screen). Unfortunately, there are no startup files yet. On CentoOS you can do make config, but Rocky 9 doesn’t understand it. We need to use systemd to manage the asterisk service. To do this, we will create the 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

Starting Asterisk

Now you can add the asterisk service to the startup, start it and check its status.

systemctl enable asterisk.service
systemctl start asterisk
systemctl status asterisk

Leave a Reply