How to Install Asterisk 22 in CentOS 9

Published: 20 February 2025
on channel: Flavio E. Goncalves
47
3

This is the recipe to install Asterisk in CentOS 9

Complete Asterisk Training - https://www.voip.school/p/complete-as...
Quick Start to Asterisk - https://www.voip.school/p/quick-start...

#Disable SELINUX
sudo vi /etc/selinux/config
SELINUX=disabled
reboot

Update system first
sudo dnf update -y

Install EPEL repository
sudo dnf install -y epel-release

Install development tools group
sudo dnf groupinstall -y "Development Tools"

#PowerTools Codeready
sudo dnf config-manager --set-enabled crb

#Dependencies
sudo dnf install -y bison wget openssl openssl-devel alsa-lib-devel glibc-devel libxml2-devel sqlite-devel newt-devel ncurses-devel zlib-devel gcc gcc-c++ make perl perl-interpreter libuuid-devel git subversion unixODBC-devel unixODBC autoconf libedit-devel libsrtp-devel spandsp-devel bzip2 libcurl-devel opus opus-devel jansson jansson-devel sqlite-devel wget libedit-devel chkconfig libxslt-devel libuuid-devel

cd /usr/src/
sudo wget https://downloads.asterisk.org/pub/te...
sudo tar xvf asterisk-22-current.tar.gz
cd asterisk-22*

#Preparation
sudo ./configure
sudo make menuselect

#Compilation
sudo make
sudo make install
sudo make samples # Install sample configuration files
sudo make config # Install init scripts

#Create the user
sudo groupadd asterisk
sudo useradd -r -d /var/lib/asterisk -g asterisk asterisk

#Rights
sudo chown -R asterisk:asterisk /var/lib/asterisk
sudo chown -R asterisk:asterisk /var/log/asterisk
sudo chown -R asterisk:asterisk /var/run/asterisk
sudo chown -R asterisk:asterisk /var/spool/asterisk
sudo chown -R asterisk:asterisk /usr/lib/asterisk

#Edit the file asterisk.service
sudo systemctl edit --full asterisk.service

#Use the following content in the file
[Unit]
Description=Asterisk PBX and telephony daemon
After=network.target

[Service]
Type=forking
ExecStart=/usr/sbin/asterisk -g
ExecStop=/usr/sbin/asterisk -rx 'core stop now'
ExecReload=/usr/sbin/asterisk -rx 'core reload'
PIDFile=/run/asterisk/asterisk.pid
Restart=always
User=asterisk
Group=asterisk
WorkingDirectory=/var/lib/asterisk

[Install]
WantedBy=multi-user.target


#Enable and Start
sudo systemctl enable asterisk
sudo systemctl start asterisk

#Firewall (Optional)
sudo firewall-cmd --permanent --add-port=5060/udp # SIP
sudo firewall-cmd --permanent --add-port=5060/tcp # SIP
sudo firewall-cmd --permanent --add-port=10000-20000/udp # RTP
sudo firewall-cmd --reload

#Asterisk #CentOS9 #LinuxTutorial #VoIP #OpenSource #SysAdmin #InstallationGuide #TechTutorial