New Install Asterisk 18 from source on CentOS Stream 8

Since Centos 7/8 approaches it’s EOL, below you will find all necessary commands and files to new install Asterisk 18 from source on Centos 8 Stream.Installing Asterisk 20 From source On Rocky 9

Prerequisites

First of all make sure that you run all command as root user. Just run su command and enter root password.

Update the system and install required dependencies.

yum -y update
yum-y install nano wget tar ncurses-devel

Configuring dependencies

First download Asterisk sources. /usr/src is a very convenient place to store all source files.

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

Just a Note:
Now (compared to eg. Asterisk 11) you don’t have to name all required dependencies (eg. make gcc gcc-c++ lynx bison ncurses-devel). You do all that with pre-created script. To be able to download more resources (like opus codec or spandsp for faxing) add EPEL repository first.

yum -y install epel-release # optional
contrib/scripts/install_prereq install

Since CentOS Stream 8 required 64bit system we can just add --libdir=/usr/lib64 to configure command.

Since chan_pjsip requires some additional libraries you may want to add --with-jansson-bundled --with-pjproject-bundled to configure command.

Just a note:
Beginning with Asterisk 15.0.0, it is enabled by default but can be disabled with the --without-pjproject-bundled option to ./configure.

./configure --libdir=/usr/lib64

If you see “Please install the “libedit” development package” error it means that you need to install libedit-devel package first. You may download it with PowerTools repo with command and then you need to run ./configure once again.

dnf --enablerepo=powertools install -y libedit-devel

Then you could just make and this would compile your software. But it’s better to be able to select some additional options, functions, applications, codecs, etc…..

To do that use make menuselect option. It will show you a menu in which you may simply select what you need.

make menuselect
make

The system tells you what to next. This will finally install Asterisk on your server.

make install

If you selected format_mp3 just follow on-screen instructions.

contrib/scripts/get_mp3_source.sh
make samples
make config
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

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