Tutorial March 12, 2025 15 min read

How to Install Asterisk on Debian 13 (Trixie)

A complete step-by-step guide to compiling and installing Asterisk PBX from source on Debian 13 Trixie. Configure your system for production use with IPComms SIP trunking.

1. Prerequisites

Before installing Asterisk on Debian 13 (Trixie), ensure your system meets the following requirements. This guide assumes you have root access or sudo privileges.

System Requirements

Minimum

  • 1 CPU core
  • 1 GB RAM
  • 10 GB disk space
  • Debian 13 (Trixie) x64

Recommended

  • 2+ CPU cores
  • 2+ GB RAM
  • 20+ GB SSD
  • Static public IP address

Required Information

Gather this information before starting:

  • Your server's public IP address
  • IPComms SIP trunk credentials (username, password, server)
  • DID phone numbers for inbound routing

Cloud Servers: If you are running on AWS, Google Cloud, or DigitalOcean, ensure you have configured security groups to allow SIP (UDP 5060) and RTP (UDP 10000-20000) traffic.

2. Installing Dependencies

Asterisk requires several development libraries and tools to compile from source. First, update your system and install the build essentials.

Update System Packages

# Update package lists and upgrade existing packages
sudo apt update && sudo apt upgrade -y

Install Build Dependencies

# Install essential build tools
sudo apt install -y build-essential git wget curl

# Install Asterisk dependencies
sudo apt install -y libncurses5-dev libssl-dev libxml2-dev \
    libsqlite3-dev uuid-dev libjansson-dev libspeex-dev \
    libspeexdsp-dev libogg-dev libvorbis-dev libasound2-dev \
    libcurl4-openssl-dev libical-dev libneon27-dev libsrtp2-dev \
    unixodbc-dev libmyodbc odbc-mariadb libiksemel-dev \
    libnewt-dev libpopt-dev libedit-dev libradcli-dev

Install PJSIP Dependencies

PJSIP is the recommended SIP channel driver for Asterisk. These libraries are required for PJSIP support:

# PJSIP and codec dependencies
sudo apt install -y libpjproject-dev libopus-dev

Tip: On Debian 13, the system PJSIP library is compatible with Asterisk. You do not need to compile PJSIP separately like on older Debian versions.

3. Downloading Asterisk Source

Download the latest Asterisk LTS version from the official Asterisk downloads page. As of 2026, Asterisk 22 LTS is the recommended version for production systems.

Download and Extract

# Create a source directory
cd /usr/src

# Download Asterisk 22 LTS (latest version)
sudo wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-22-current.tar.gz

# Extract the archive
sudo tar -xvzf asterisk-22-current.tar.gz

# Enter the Asterisk directory
cd asterisk-22*/

Install MP3 Support (Optional)

If you want MP3 playback support for music on hold or prompts:

# Download MP3 source module
sudo contrib/scripts/get_mp3_source.sh

Run Prerequisite Script

Asterisk includes a script that installs any missing dependencies:

# Install any missing prerequisites
sudo contrib/scripts/install_prereq install

Note: The install_prereq script may prompt you for your ITU country code. Enter your two-letter country code (e.g., US, GB, AU) when prompted.

4. Compiling and Installing Asterisk

Now we will configure, compile, and install Asterisk. This process takes 10-30 minutes depending on your server's CPU.

Configure the Build

# Run the configure script
sudo ./configure --with-pjproject-bundled=no

Select Modules (menuselect)

Use menuselect to choose which modules to build. For a SIP trunk setup, ensure PJSIP and common codecs are selected:

# Open the module selection menu
sudo make menuselect

In the menuselect interface, verify these are enabled:

  • chan_pjsip - PJSIP channel driver
  • res_pjsip - PJSIP core module
  • codec_opus - Opus codec (if available)
  • format_mp3 - MP3 format support

Compile Asterisk

# Compile Asterisk (use -j for parallel compilation)
sudo make -j$(nproc)

Install Asterisk

# Install Asterisk binaries
sudo make install

# Install sample configuration files
sudo make samples

# Install init scripts for systemd
sudo make config

# Install logrotate configuration
sudo make install-logrotate

Create Asterisk User

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

# Set ownership of Asterisk directories
sudo chown -R asterisk:asterisk /etc/asterisk
sudo chown -R asterisk:asterisk /var/lib/asterisk
sudo chown -R asterisk:asterisk /var/log/asterisk
sudo chown -R asterisk:asterisk /var/spool/asterisk
sudo chown -R asterisk:asterisk /var/run/asterisk

Security Best Practice: Always run Asterisk as a non-root user. Edit /etc/asterisk/asterisk.conf and set runuser = asterisk and rungroup = asterisk.

5. Basic Configuration

Configure the essential Asterisk files for a basic working system. We will set up the main configuration and prepare for PJSIP trunking.

Configure asterisk.conf

# Edit the main Asterisk configuration
sudo nano /etc/asterisk/asterisk.conf

Ensure these settings are configured:

[options]
runuser = asterisk
rungroup = asterisk
documentation_language = en_US

[files]
astctlpermissions = 0660
astctlowner = asterisk
astctlgroup = asterisk

Configure modules.conf

Enable PJSIP and disable the legacy chan_sip module:

# Edit modules configuration
sudo nano /etc/asterisk/modules.conf
[modules]
autoload = yes

; Disable legacy SIP module
noload => chan_sip.so

; Ensure PJSIP is loaded
load => res_pjsip.so
load => chan_pjsip.so

Configure RTP Ports

# Edit RTP configuration
sudo nano /etc/asterisk/rtp.conf
[general]
rtpstart = 10000
rtpend = 20000
rtpchecksums = no
strictrtp = yes
icesupport = no

Start Asterisk

# Enable Asterisk to start on boot
sudo systemctl enable asterisk

# Start Asterisk service
sudo systemctl start asterisk

# Check status
sudo systemctl status asterisk

6. Configuring for IPComms SIP Trunk

Connect your Asterisk system to IPComms SIP trunking for inbound and outbound calling. Replace the placeholder values with your actual IPComms credentials.

Create pjsip.conf for IPComms

# Edit PJSIP configuration
sudo nano /etc/asterisk/pjsip.conf
; ===================================
; IPComms SIP Trunk Configuration
; ===================================

[global]
type = global
user_agent = Asterisk PBX

[transport-udp]
type = transport
protocol = udp
bind = 0.0.0.0:5060
external_media_address = YOUR_PUBLIC_IP
external_signaling_address = YOUR_PUBLIC_IP
local_net = 10.0.0.0/8
local_net = 172.16.0.0/12
local_net = 192.168.0.0/16

; IPComms Trunk Registration
[ipcomms]
type = registration
transport = transport-udp
outbound_auth = ipcomms-auth
server_uri = sip:sip.ipcomms.net
client_uri = sip:YOUR_TRUNK_USERNAME@sip.ipcomms.net
retry_interval = 60
expiration = 3600

[ipcomms-auth]
type = auth
auth_type = userpass
username = YOUR_TRUNK_USERNAME
password = YOUR_TRUNK_PASSWORD

[ipcomms-aor]
type = aor
contact = sip:sip.ipcomms.net

[ipcomms-identify]
type = identify
endpoint = ipcomms-endpoint
match = sip.ipcomms.net

[ipcomms-endpoint]
type = endpoint
transport = transport-udp
context = from-ipcomms
disallow = all
allow = ulaw
allow = alaw
allow = g722
outbound_auth = ipcomms-auth
aors = ipcomms-aor
from_user = YOUR_TRUNK_USERNAME
from_domain = sip.ipcomms.net
direct_media = no
ice_support = no
force_rport = yes
rewrite_contact = yes
rtp_symmetric = yes

Replace These Values: Update YOUR_PUBLIC_IP, YOUR_TRUNK_USERNAME, and YOUR_TRUNK_PASSWORD with your actual IPComms account credentials from the customer portal.

Configure Dialplan (extensions.conf)

# Edit extensions configuration
sudo nano /etc/asterisk/extensions.conf
[general]
static = yes
writeprotect = no

; Context for calls coming from IPComms
[from-ipcomms]
exten => _X.,1,NoOp(Incoming call from IPComms: ${CALLERID(all)})
 same => n,Answer()
 same => n,Playback(hello-world)
 same => n,Hangup()

; Context for outbound calls via IPComms
[outbound-ipcomms]
exten => _1NXXNXXXXXX,1,NoOp(Outbound call to ${EXTEN})
 same => n,Set(CALLERID(num)=YOUR_DID_NUMBER)
 same => n,Dial(PJSIP/${EXTEN}@ipcomms-endpoint,60)
 same => n,Hangup()

; International calls (E.164 format)
exten => _011.,1,NoOp(International call to ${EXTEN})
 same => n,Set(CALLERID(num)=YOUR_DID_NUMBER)
 same => n,Dial(PJSIP/${EXTEN}@ipcomms-endpoint,120)
 same => n,Hangup()

Get Your IPComms Credentials

Sign up for IPComms SIP trunking to get your trunk credentials, DID numbers, and access to the customer portal with real-time call analytics.

Sign Up for IPComms

7. Testing the Installation

Verify your Asterisk installation and IPComms trunk registration are working correctly.

Reload Configuration

# Reload Asterisk to apply changes
sudo asterisk -rx "core reload"

Check PJSIP Registration

# Connect to Asterisk CLI
sudo asterisk -rvvv

# Check registration status
pjsip show registrations

You should see output indicating your IPComms registration is "Registered":

Registration:  ipcomms/sip:YOUR_USERNAME@sip.ipcomms.net
   Status:  Registered

Verify Endpoint Configuration

# Show PJSIP endpoints
pjsip show endpoints

# Show detailed endpoint info
pjsip show endpoint ipcomms-endpoint

Make a Test Call

# Originate a test call from CLI
channel originate PJSIP/12025551234@ipcomms-endpoint application Playback hello-world

Testing Tip: IPComms provides free test credits for new accounts. Use these to verify your trunk configuration before going live.

8. Troubleshooting Common Issues

If you encounter issues with your Asterisk installation or IPComms trunk, use these troubleshooting steps to diagnose and resolve problems.

Registration Failures

SymptomCauseSolution
401 UnauthorizedWrong credentialsVerify username/password in pjsip.conf
408 Request TimeoutFirewall blockingOpen UDP 5060 and 10000-20000
503 Service UnavailableServer issueCheck IPComms status page

No Audio (One-Way or No Audio)

# Check RTP settings and NAT configuration
sudo asterisk -rx "rtp show settings"

# Verify external IP is set correctly
sudo asterisk -rx "pjsip show transport transport-udp"

Common audio issues and solutions:

  • Firewall: Ensure RTP ports (10000-20000) are open for UDP traffic
  • NAT: Verify external_media_address is set to your public IP
  • direct_media: Must be set to "no" for NAT environments

Enable Debug Logging

# Enable PJSIP debug logging in Asterisk CLI
pjsip set logger on

# View SIP messages in real-time
core set verbose 5
core set debug 5

Check System Logs

# View Asterisk logs
sudo tail -f /var/log/asterisk/messages

# View full log file
sudo tail -f /var/log/asterisk/full

Need Help? IPComms support team can help troubleshoot trunk connectivity issues. Contact us at support or check our PJSIP trunk setup guide for more detailed configuration options.

Ready to Connect Your Asterisk PBX?

Get started with IPComms SIP trunking. Reliable connectivity, competitive rates, and excellent Asterisk compatibility. Free test trunk available.

Related Articles