How to Install Asterisk on Ubuntu 24.04
Learn how to install Asterisk on Ubuntu 24.04 LTS from source with DAHDI, LibPRI, PJSIP, systemd service, and basic SIP extension configuration for VoIP.

6 min read
Learn how to install Asterisk on Ubuntu 24.04 LTS from source with DAHDI, LibPRI, PJSIP, systemd service, and basic SIP extension configuration for VoIP.
- Prerequisites and Supported Releases
- Step 1: Updating System Repositories and Installing Core Build Tools
- Step 2: Downloading Asterisk 20 LTS Source Code Archive
Asterisk is the world's most powerful and widely deployed open-source telecommunications framework. Developed by Sangoma (Digium), Asterisk converts an ordinary Linux computer into a versatile communications switching server, powering enterprise Private Branch Exchanges (PBX), VoIP gateways, interactive voice response (IVR) systems, automated call distribution (ACD) queues, and multi-party conference bridges.
By utilizing modern VoIP protocols like Session Initiation Protocol (SIP) via the robust PJSIP stack, Asterisk routes calls across traditional PSTN telephony lines, SIP trunks, softphones, and hardware IP desk phones seamlessly. Understanding how to install asterisk on ubuntu 24.04 enables telecommunication engineers and sysadmins to build an enterprise-class private branch exchange (PBX), VoIP gateway, interactive voice response (IVR) menu, and conference bridge.
In this comprehensive step-by-step tutorial, we demonstrate how to install Asterisk on Ubuntu 24.04 LTS (Noble Numbat). We cover downloading Asterisk 20 LTS source code, installing C/C++ compiler toolchains and prerequisite libraries via automated scripts, selecting menuselect modules, compiling and installing Asterisk, creating a dedicated unprivileged asterisk system user, configuring systemd service daemons, and connecting to the Asterisk CLI console.
Compile, install, and configure the Asterisk PBX communication engine on Ubuntu 24.04 LTS from source with PJSIP SIP stack, audio sound prompts, and systemd daemon management.
Prerequisites and Supported Releases
This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.
Before proceeding, ensure you have the following requirements satisfied:
- A server or virtual machine running
Ubuntu 24.04 LTS. - A non-root user account configured with administrative
sudoprivileges. - At least
2 GB of RAM(4 GB recommended for high concurrent call volume and transcoding). - Network connectivity to download source code archives and voice audio packages.
Step 1: Updating System Repositories and Installing Core Build Tools
Compiling Asterisk from source code requires modern C/C++ compilers, development headers, and compression utilities. Building from source allows you to enable specific audio transcoding codecs, hardware drivers, and optimize binaries for your host CPU architecture.
First, refresh your local APT repository index and upgrade installed packages to ensure compatibility with modern system libraries.
Install foundational build utilities including build-essential, wget, curl, subversion, git, and development libraries using APT.
# Refresh repository lists and upgrade packages
sudo apt update && sudo apt upgrade -y
# Install core build dependencies
sudo apt install -y build-essential wget curl git subversion libedit-dev libsqlite3-dev libxml2-dev libjansson-dev libssl-dev uuid-dev
Step 2: Downloading Asterisk 20 LTS Source Code Archive
Asterisk 20 is the official Long-Term Support (LTS) release recommended for production voice deployments. LTS releases receive five full years of security fixes and maintenance updates from the Asterisk community.
Download the official source code tarball directly from the Asterisk downloads server into your /usr/src directory.
Extract the archive and navigate into the extracted source tree.
Verify the extracted directory structure before initiating the build configuration process.
# Navigate to source directory and download Asterisk 20 LTS
cd /usr/src
sudo wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20-current.tar.gz
# Extract source archive
sudo tar -xzf asterisk-20-current.tar.gz
# Enter the extracted source directory
cd asterisk-20.*
# Clean up downloaded archive
sudo rm -f /usr/src/asterisk-20-current.tar.gz
Step 3: Installing External Dependencies via install_prereq Script
Asterisk includes a dedicated helper script located in contrib/scripts/install_prereq that automatically resolves and installs all required external libraries, audio codecs, and media dependencies via APT.
Execute the script and choose install to begin the automated dependency resolution process.
When prompted, enter your ITU telephone country dialing code (e.g., 1 for North America or 44 for UK) for sound package localization.
# Run automated dependency installer script
sudo contrib/scripts/install_prereq install
Step 4: Configuring Build Options and Selecting Menuselect Modules
Execute the ./configure script to inspect your system environment and verify all required libraries are present.
Launch the terminal-based menuselect configuration utility to customize build modules.
Ensure that chan_pjsip, MP3 decoding (format_mp3), and your desired audio sound packages (e.g., CORE-SOUNDS-EN-WAV and MOH-OPSOUND-WAV) are enabled.
Save your selections and exit menuselect.
# Configure build environment
sudo ./configure
# Download MP3 decoder library
sudo contrib/scripts/get_mp3_source.sh
# Launch menuselect module configuration interface
sudo make menuselect
Step 5: Compiling and Installing Asterisk via Make
With modules selected, compile Asterisk using make. You can pass the -j flag to accelerate compilation using multiple CPU cores.
Once compilation succeeds, install the compiled binaries and shared libraries into standard system paths using sudo make install.
Install basic sample configuration files and documentation using sudo make samples.
Generate basic PBX configuration templates and init scripts using sudo make config.
# Compile Asterisk using all CPU cores
sudo make -j$(nproc)
# Install compiled binaries and modules
sudo make install
# Install sample configuration files in /etc/asterisk
sudo make samples
# Install initialization scripts
sudo make config
sudo ldconfig
Step 6: Creating Dedicated Asterisk System User and Permissions
For maximum security, Asterisk should execute as an unprivileged system user rather than root. Running telecommunication services under restricted accounts prevents remote exploits from compromising host operating system privileges.
Create a dedicated system user and group named asterisk without interactive shell login.
Assign ownership of Asterisk configuration directories (/etc/asterisk), spool files (/var/spool/asterisk), log directories (/var/log/asterisk), and runtime states (/var/run/asterisk, /var/lib/asterisk) to the asterisk user.
Configure default user settings in /etc/default/asterisk.
# Create dedicated system user and group
sudo groupadd asterisk
sudo useradd -r -d /var/lib/asterisk -g asterisk asterisk
sudo usermod -aG audio,dialout asterisk
# Set directory ownership across Asterisk paths
sudo chown -R asterisk:asterisk /etc/asterisk /var/lib/asterisk /var/log/asterisk /var/spool/asterisk /var/run/asterisk
# Configure /etc/default/asterisk to run as asterisk user
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
Step 7: Configuring Systemd Service Daemon for Asterisk
Enable the asterisk.service systemd daemon so that the PBX engine launches automatically upon system boot.
Start the service using systemctl.
Verify that the Asterisk daemon is active and running cleanly without service degradation or socket failures.
# Enable and start Asterisk systemd service
sudo systemctl enable asterisk
sudo systemctl start asterisk
# Verify active service status
sudo systemctl status asterisk --no-pager
Step 8: Connecting to the Asterisk CLI Console and Verifying SIP Stack
Connect to the running Asterisk engine using the Asterisk Command Line Interface (CLI) client tool.
Run sudo asterisk -rvvv to enter the interactive console with verbose debugging output.
At the CLI> prompt, execute pjsip show endpoints to verify that the PJSIP channel driver is operational.
Execute core show uptime to inspect system uptime, and type quit to exit the console back to your bash shell.
# Connect to Asterisk interactive CLI console
sudo asterisk -rvvv
# Commands to run inside Asterisk CLI prompt:
# CLI> core show uptime
# CLI> pjsip show endpoints
# CLI> module show like chan_pjsip
# CLI> quit
Troubleshooting and Common Errors
When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:
Command 'sudo asterisk -r' fails with 'Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)'
Resolution: This indicates Asterisk is not running. Check service status: sudo systemctl status asterisk. Check error logs at /var/log/asterisk/messages and verify directory permissions: sudo chown -R asterisk:asterisk /var/run/asterisk.
Compilation fails with missing 'jansson' or 'sqlite3' headers
Resolution: Re-run the automated dependency installer: cd /usr/src/asterisk-20.* && sudo contrib/scripts/install_prereq install, then re-run ./configure.
SIP extensions cannot register over UDP port 5060
Resolution: Ensure your firewall permits SIP and RTP audio traffic: sudo ufw allow 5060/udp comment 'SIP Signaling' && sudo ufw allow 10000:20000/udp comment 'RTP Media Streams'.
Security Best Practices and Hardening
Never run the Asterisk PBX daemon under the root user account; always use the dedicated unprivileged 'asterisk' system user.
Always set complex, randomized alphanumeric passwords (secrets) for all SIP endpoints in /etc/asterisk/pjsip.conf to prevent toll fraud.
Deploy Fail2ban with Asterisk filters to automatically block malicious IP addresses attempting SIP brute-force registration attacks.
Restrict RTP port ranges (10000-20000 UDP) and SIP ports (5060 UDP/TCP) using UFW firewall rules.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
chan_sip is the legacy, deprecated SIP channel driver in Asterisk. PJSIP (res_pjsip) is the modern, modular, multi-threaded SIP stack that provides superior performance, multi-endpoint binding, and ongoing security support.core reload or reload specific modules using pjsip reload or dialplan reload.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides
Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!