Перейти к основному контенту

Развертывание Asterisk

Скачиваем Астерикс

curl -O https://downloads.asterisk.org/pub/telephony/certified-asterisk/asterisk-certified-18.9-current.tar.gz

Распаковываем архив

tar xvf asterisk*

Переходим в директорию

cd asterisk*

Добавляем звуки и устанвливаем необходимые компоненты

makecontrib/scripts/get_mp3_source.sh
sudo apt -y install git curl wget libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev build-essential libjansson-dev libxml2-dev  uuid-dev
contrib/scripts/get_mp3_source.sh

Устанвливаем зависимости Asterisk

sudo contrib/scripts/install_prereq install

Собираем и устанвливаем Asterisk

sudo ./configure
sudo make menuselect
sudo make
sudo make install
sudo make progdocs
sudo make config
sudo ldconfig
sudo make basic-pbx

Меняем права для директорий

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,spool}/asterisk
sudo chown -R asterisk.asterisk /usr/lib/asterisk
sudo chmod -R 750 /var/{lib,log,run,spool}/asterisk /usr/lib/asterisk /etc/asterisk

Приводим /etc/default/asterisk к виду

AST_USER="asterisk"
AST_GROUP="asterisk"
COLOR=yes

Приводим /etc/asterisk/asterisk.conf к виду

runuser = asterisk
rungroup = asterisk

Редактируем файл для модуля pjsip /etc/asterisk/pjsip.conf

[transport-udp-nat]
type = transport
protocol = udp
bind = 0.0.0.0

[100]
type = endpoint
disallow = all
allow = alaw
allow = ulaw
context = internal
callerid = 100
auth = 100-auth
aors = 100

[100-auth]
type = auth
auth_type = userpass
username = 100
password = 123

[100]
type = aor
max_contacts = 5


[101]
type = endpoint
disallow = all
allow = alaw
allow = ulaw
context = internal
callerid = 101
auth = 101-auth
aors = 101

[101-auth]
type = auth
auth_type = userpass
username = 101
password = 123

[101]
type = aor
max_contacts = 5

Редактируем /etc/asterisk/extensions.conf

[globals]
[general]
[default]

[internal]
exten => _1xx,1,Dial(PJSIP/${EXTEN})
exten => s,n,Hangup

Запускаем Asterisk

sudo systemctl restart asterisk.service
sudo systemctl enable asterisk.service --now