Instalación de Asterisk 18 en Debian 11 ou Debian 10

July 11, 2022

Escollemos compilalo xa que a versión do Asterisk que ten Debian no repo do Debian é a 16.

Paso 1: Actualizar o sistema

apt updateapt full-upgrade -yreboot -f

Paso 2: Instalar dependencias

Xa que se vai compilar o Asterisk fai falta instalar as dependencias para poder facelo:

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

Verificar que exiten GCC e CMAKE no sistema:

make --versionGNU Make 4.3[...]gcc --versiongcc (GCC) 12.1.0[...]

Paso 3: Baixar o tarball do Asterisk 18 LTS

cd /usr/src/curl -O http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz

Descomprimilo:

tar xvf asterisk-18-current.tar.gzcd asterisk-18*/

Baixar a biblioteca de decodificación mp3 ó directorio de código:

./contrib/scripts/get_mp3_source.shA    addons/mp3A    addons/mp3/MPGLIB_READMEA    addons/mp3/common.cA    addons/mp3/huffman.hA    addons/mp3/tabinit.cA    addons/mp3/MakefileA    addons/mp3/READMEA    addons/mp3/decode_i386.cA    addons/mp3/dct64_i386.cA    addons/mp3/MPGLIB_TODOA    addons/mp3/mpg123.hA    addons/mp3/layer3.cA    addons/mp3/mpglib.hA    addons/mp3/decode_ntom.cA    addons/mp3/interface.cExported revision 202.

Confirmar que están instaladas todas as dependencias executando o script *install_prereq*:

./contrib/scripts/install_prereq install

Este é o mensaxe de salida de si está todo correcto:

[...]Setting up odbcinst (2.3.6-0.1+b1) ...Setting up odbcinst1debian2:amd64 (2.3.6-0.1+b1) ...Setting up unixodbc-dev:amd64 (2.3.6-0.1+b1) ...Processing triggers for initramfs-tools (0.140) ...update-initramfs: Generating /boot/initrd.img-5.10.0-8-amd64Processing triggers for libglib2.0-0:amd64 (2.66.8-1) ...No schema files found: doing nothing.Processing triggers for libc-bin (2.31-13) ...Processing triggers for man-db (2.9.4-2) ...Setting up libgmime-3.0-dev:amd64 (3.2.7-1) ...############################################### install completed successfully#############################################

Paso 4: Compilar e instalar Asterisk 18 en Debian 11 / Debian 10

Despóis de instalar tódalas dependencias xa se pode iniciar a compilación e instalación.

Executa o script *configure* para satisfacer as dependencias de compilación:

./configure[...]configure: creating ./config.statusconfig.status: creating makeoptsconfig.status: creating autoconfig.hconfigure: Menuselect build configuration successfully completed               .$$$$$$$$$$$$$$$=..            .$7$7..          .7$$7:.          .$$:.                 ,$7.7        .$7.     7$$$$           .$$77     ..$$.       $$$$$            .$$$7    ..7$   .?.   $$$$$   .?.       7$$$.   $.$.   .$$$7. $$$$7 .7$$$.      .$$$. .777.   .$$$$$$77$$$77$$$$$7.      $$$, $$$~      .7$$$$$$$$$$$$$7.       .$$$..$$7          .7$$$$$$$7:          ?$$$.$$$          ?7$$$$$$$$$$I        .$$$7$$$       .7$$$$$$$$$$$$$$$$      :$$$.$$$       $$$$$$7$$$$$$$$$$$$    .$$$.$$$        $$$   7$$$7  .$$$    .$$$.$$$$             $$$$7         .$$$.7$$$7            7$$$$        7$$$ $$$$$                        $$$  $$$$7.                       $$  (TM)   $$$$$$$.           .7$$$$$$  $$     $$$$$$$$$$$$7$$$$$$$$$.$$$$$$       $$$$$$$$$$$$$$$$.configure: Package configured for:configure: OS type  : linux-gnuconfigure: Host CPU : x86_64configure: build-cpu:vendor:os: x86_64 : pc : linux-gnu :configure: host-cpu:vendor:os: x86_64 : pc : linux-gnu :

Personaliza a instalación do Asterisk usando o menú de opciós:

make menuselect

Usando as flechas do teclado para navegar polos menus e a tecla *Enter* para aceptar a selección.

Por exemplo: selecciona *Add-ons* e baixando ata *format_mp3* acepta para dar soporte as locuciós en mp3.

Activa ou desactiva os módulos que necesites, coa configuración por defecto funcionará perfectamente.

Garda e sal para actualizar a configuración.

Para compilar o Asterisk 18 LTS no Debian 11 ou Debian 10 executa:

make

O proceso de compilación debería rematar en breves, depende da potencia da máquina:

[...]   [LD] res_pjsip_publish_asterisk.o -> res_pjsip_publish_asterisk.so   [CC] res_calendar_exchange.c -> res_calendar_exchange.o   [LD] res_calendar_exchange.o -> res_calendar_exchange.so   [CC] res_pjsip_registrar.c -> res_pjsip_registrar.o   [LD] res_pjsip_registrar.o -> res_pjsip_registrar.soBuilding Documentation For: third-party channels pbx apps codecs formats cdr cel bridges funcs tests main res addons +--------- Asterisk Build Complete ---------+ + Asterisk has successfully been built, and + + can be installed by running:              + +                                           + +                make install               + +-------------------------------------------+

O último paso é instalar o Asterisk executando o comando _make install_:

make install

Paso 5: Configurar o Asterisk 18 LTS despóis da instalación

Despóis de instalar o Asterisk, podes instalar a documentación:

make progdocs

Instala as configuraciós por defecto e os exemplos:

make samplesmake configldconfig

Instala o códec g729:

wget http://asterisk.hosting.lv/bin/codec_g729-ast180-gcc4-glibc-x86_64-core2.somv codec_g729-ast180-gcc4-glibc-x86_64-core2.so /usr/lib/asterisk/modules/codec_g729.so

Máis adiante, unha vez arranque o asterisk podes comprobar si está ben instalado co comando:

asterisk -rx "core show translation recalc 10"

Instala as locuciós en español:

wget https://www.sinologic.net/proyectos/voces/asterisk-es_ES-alaw.tar.gzwget https://www.sinologic.net/proyectos/voces/asterisk-es_ES-ulaw.tar.gzwget https://www.sinologic.net/proyectos/voces/asterisk-es_ES-g729.tar.gzwget https://www.sinologic.net/proyectos/voces/asterisk-es_ES-gsm.tar.gzls asterisk-es_ES-*.tar.gz | xargs -n1 tar -C / -xvzf

Crea o usuario Asterisk

Crea un usuario e grupo aparte para executar os servicios asterisk e asigna os permisos correctos:

groupadd asteriskuseradd -r -d /var/lib/asterisk -g asterisk asteriskusermod -aG audio,dialout asteriskchown -R asterisk.asterisk /etc/asteriskchown -R asterisk.asterisk /var/{lib,log,spool}/asteriskchown -R asterisk.asterisk /usr/lib/asterisk

Confirma o id do usuario asterisk:

id asteriskuid=997(asterisk) gid=1001(asterisk) groups=1001(asterisk),20(dialout),29(audio)

Establece o usuario e grupo co que vai executarse o servicio asterisk:

vim /etc/default/asteriskAST_USER="asterisk"AST_GROUP="asterisk"

O arquivo de configuración por defecto que usa o asterisk é */etc/asterisk/asterisk.conf*.

Podes abrilo e ver si fai falta aplicar algún cambio.

vim /etc/asterisk/asterisk.confrunuser = asterisk              ; The user to run as.rungroup = asterisk             ; The group to run as.

Reinicia o servicio asterisk despóis de facer os cambios:

/etc/init.d/asterisk restart

ou

systemctl restart asterisk

Ahora podes conectar ó CLI do Asterisk para comprobar que se está executando:

asterisk -rvvAsterisk 18.11.1, Copyright (C) 1999 - 2021, Sangoma Technologies Corporation and others.Created by Mark Spencer [...]Connected to Asterisk 18.11.1 currently running on debian-bullseye-01 (pid = 48369)debian-bullseye-01*CLI>

Executa algún comando de asterisk para comprobar a funcionalidade:

debian-bullseye-01*CLI> core show  uptimeSystem uptime: 16 minutes, 29 secondsLast reload: 16 minutes, 29 secondsdebian-bullseye-01*CLI> core show  sysinfoSystem Statistics-----------------  System Uptime:             18 hours  Total RAM:                 2030244 KiB  Free RAM:                  160672 KiB  Buffer RAM:                58964 KiB  Total Swap Space:          0 KiB  Free Swap Space:           0 KiB  Number of Processes:       172debian-bullseye-01*CLI> exitAsterisk cleanly ending (0).Executing last minute cleanups

Ahora tes instalado e configurado o Asterisk 18 LTS en unha máquina con Debian 11 ou Debian 10.

Podes consultar a documentación oficial, moito máis detallada, na [Páxina oficial](https://www.asterisk.org/community/documentation/).

→ home