Installing Asterisk 18 on Debian 11
Asterisk must be built with mysql support (modules cdr_mysql,res_config_mysql).
Update your system first
sudo apt update && sudo apt full-upgrade -y
install all required Asterisk dependency packages:
sudo apt -y install build-essential git curl wget libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev libjansson-dev libxml2-dev uuid-dev default-libmysqlclient-dev
Make sure GCC and CMAKE are installed and working on our local system
make --version
gcc --version
cd /usr/src/ && sudo wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz &&
sudo tar xvf asterisk-18-current.tar.gz && cd asterisk-18*/ && sudo contrib/scripts/get_mp3_source.sh
Installing the required dependencies
sudo contrib/scripts/install_prereq install
in the process, offer to select a country code, set 7
The script will install all required packages and upon successful completion will display the following message:
#######################################
install completed successfully
#######################################
Clean up the system from temporary files of the installation package
make distclean
Now we need to check if all the dependencies are present on your system in order to compile the source code. Then run the following command:
sudo ./configure
At the end you will be greeted by a beautiful ASCII Asterisk logo.
Then select the modules you want to compile and install. To access the menu, enter the following:
sudo make menuselect
choose the following
Add-ons (See README-addons.txt)
[] chan_ooh323
[] format_mp3
[] res_config_mysql
[] cdr_mysql
Applications - добавить
[] app_macro
Call Detail Recording
[ ] cdr_radius убрать
Channel Event Logging
[ ] cel_radius убрать
Core Sound Packages
[] CORE-SOUNDS-RU-WAV
[] CORE-SOUNDS-RU-ULAW
[] CORE-SOUNDS-RU-ALAW
[] CORE-SOUNDS-RU-GSM
[] CORE-SOUNDS-RU-G729
[] CORE-SOUNDS-RU-G722
[] CORE-SOUNDS-RU-SLN16
[] CORE-SOUNDS-RU-SIREN7
[] CORE-SOUNDS-RU-SIREN14
Music On Hold File Packages
[] MOH-OPSOUND-WAV
[] MOH-OPSOUND-ULAW
[] MOH-OPSOUND-ALAW
[] MOH-OPSOUND-GSM
Extras Sound Packages
[] EXTRA-SOUNDS-EN-WAV
[] EXTRA-SOUNDS-EN-ULAW
[] EXTRA-SOUNDS-EN-ALAW
[] EXTRA-SOUNDS-EN-GSM
Save & Exit
Upon completion, you should receive:
menuselect changes saved!
make[1]: Leaving directory '/home/infoit/asterisk-18'
To start compiling the source code, run the command
sudo make
If everything went well, you should get:
+--------- Asterisk Build Complete ---------+
Asterisk has successfully been built, and +
can be installed by running: +
+
make install +
+-------------------------------------------+
Once compilation is complete, install Asterisk and its modules by typing:
Then install Asterisk
sudo make install
Sample output:
+---- Asterisk Installation Complete -------+
+
YOU MUST READ THE SECURITY DOCUMENT +
+
Asterisk has successfully been installed. +
If you would like to install the sample +
configuration files (overwriting any +
existing config files), run: +
+
For generic reference documentation: +
make samples +
+
For a sample basic PBX: +
make basic-pbx +
+
+
+----------------- or ---------------------+
+
You can go ahead and install the asterisk +
program documentation now or later run: +
+
make progdocs +
+
Note This requires that you have +
doxygen installed on your local system +
+-------------------------------------------+
Install documentation as shown if you wish
sudo make progdocs
Creation of C-API documentation. It will take some time.
Then finally use the commands below to install configurations and examples
sudo make samples &&
sudo make config &&
sudo ldconfig
you can enable log rotation like this
make install-logrotate
Create an Asterisk user and run
sudo groupadd asterisk &&
sudo useradd -r -d /var/lib/asterisk -g asterisk asterisk &&
sudo usermod -aG audio,dialout asterisk &&
sudo chown -R asterisk.asterisk /etc/asterisk &&
sudo chown -R asterisk.asterisk /var/{lib,log,run,spool}/asterisk &&
sudo chown -R asterisk.asterisk /usr/lib/asterisk
Let’s verify the Asterisk user ID:
id asterisk
To configure Asterisk to run as the newly created user, open the file and uncomment the following two lines at the beginning (remove the # in front of the lines):
sudo sed -i 's/#AST_USER="asterisk"/AST_USER="asterisk"/' /etc/default/asterisk &&
sudo sed -i 's/#AST_GROUP="asterisk"/AST_GROUP="asterisk"/' /etc/default/asterisk &&
sudo sed -i 's/;runuser = asterisk/runuser = asterisk/' /etc/asterisk/asterisk.conf &&
sudo sed -i 's/;rungroup = asterisk/rungroup = asterisk/' /etc/asterisk/asterisk.conf
move and archive to home category
mv /etc/init.d/asterisk ~/asterisk.init.d.bak
Create your new service file in/etc/systemd/system/asterisk.service
sudo tee /etc/systemd/system/asterisk.service<<EOF
[Unit]
Description=Asterisk PBX and telephony daemon.
Documentation=man:asterisk(8)
Wants=network.target
After=network.target
[Service]
Type=simple
User=asterisk
Group=asterisk
ExecStart=/usr/sbin/asterisk -f -C /etc/asterisk/asterisk.conf
ExecStop=/usr/sbin/asterisk -rx 'core stop now'
ExecReload=/usr/sbin/asterisk -rx 'core reload'
safe_asterisk emulation
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
check your service file
nano /etc/systemd/system/asterisk.service
After the change
systemctl daemon-reload
After making changes, restart the asterisk service
sudo systemctl restart asterisk && sudo systemctl enable asterisk && sudo systemctl status asterisk
Check connection to Asterisk CLI
sudo asterisk -rvvvv
You should see output similar to this:
Connected to Asterisk GIT-18-804b1987fb currently running on infoit (pid = 31426)
infoit*CLI>
go out
Let’s try to enter a couple of commands to test the work.
core show channels
core show uptime
core show sysinfo
Firewall setup
sudo apt update
sudo apt install ufw -y
Allow port access on the firewall by running the following command:
sudo ufw allow 80
sudo ufw allow 22
sudo ufw allow 10000:20000/udp
sudo ufw allow 5060:5061/udp
check status
sudo ufw status verbose
Status: inactive
turn on
sudo ufw enable
set ports in config
sudo tee /etc/asterisk/rtp.conf<<EOF
[general]
rtpstart=10000
rtpend=20000
EOF
verify
nano /etc/asterisk/rtp.conf
you can view the status
sudo ufw status verbose