Asterisk is the most widely deployed open-source PBX (Private Branch Exchange) platform in the world. It powers VoIP gateways, IP PBX systems, conference servers, and call center infrastructure for individuals, businesses, and governments. Its features include voicemail, music on hold, conference calling, call queuing, call recording, and interactive voice response (IVR).
This guide covers how to install Asterisk on Ubuntu 18.04 from the official source tarball. Building from source installs Asterisk 18, which is a long-term support release. The Ubuntu repository only provides Asterisk 13.
<strong>Prerequisite:</strong> You need sudo access.
Install the initial build tools:
bashsudo apt update && sudo apt upgradesudo apt install wget build-essential subversion
Download and extract the Asterisk 18 source. The /usr/src/ directory is the conventional location for source tarballs on Linux systems:
bashcd /usr/src/sudo wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gzsudo tar zxf asterisk-18-current.tar.gzcd asterisk-18.*/
Download the MP3 source files. Due to licensing restrictions, Asterisk does not bundle the MP3 codec sources. The get_mp3_source.sh script fetches them separately:
bashsudo contrib/scripts/get_mp3_source.sh
Resolve all build dependencies automatically. The install_prereq script reads the dependency list for the detected Ubuntu release and calls apt to install everything Asterisk needs:
bashsudo contrib/scripts/install_prereq install
Run the configure script. This checks that all required libraries and headers are present and generates the Makefiles for the build:
bashsudo ./configure
Select the modules to compile using the Menuselect interface (an ncurses TUI). Navigate with the arrow keys, press Space to toggle a module, and press F12 to save and exit. Enable format_mp3 in the Format Interpreters section to build MP3 support:
bashsudo make menuselect
Compile and install Asterisk:
bashsudo make -j2sudo make install
The -j2 flag runs two compilation jobs in parallel. Replace 2 with the number of CPU cores on your system (nproc prints this value) for faster compilation.
Install configuration files and the init script:
bashsudo make samples # OR: sudo make basic-pbxsudo make configsudo ldconfig
make samples installs the full reference configuration with inline documentation comments. make basic-pbx installs a minimal working PBX configuration without the documentation noise. Run ldconfig last to update the shared library cache so Asterisk’s dynamically linked modules can be found at runtime.
Running Asterisk as root is a security risk. Create a dedicated system user:
bashsudo adduser --system --group --home /var/lib/asterisk --no-create-home --gecos "Asterisk PBX" asterisk
Configure Asterisk to run as this user. Open /etc/default/asterisk and uncomment:
AST_USER="asterisk"AST_GROUP="asterisk"
Add the asterisk user to the dialout and audio groups. The dialout group grants access to serial and modem devices; audio grants access to sound cards:
bashsudo usermod -a -G dialout,audio asterisk
Transfer ownership and set permissions on all Asterisk directories:
bashsudo chown -R asterisk: /var/{lib,log,run,spool}/asterisk /usr/lib/asterisk /etc/asterisksudo chmod -R 750 /var/{lib,log,run,spool}/asterisk /usr/lib/asterisk /etc/asterisk Start the Asterisk service:
bashsudo systemctl start asterisksudo systemctl enable asterisk
Connect to the running Asterisk instance through the CLI:
bashsudo asterisk -vvvr
The -r flag connects to an already-running Asterisk process via its control socket rather than starting a new instance. The three -v flags set the verbosity level — more v characters produce more detailed output. You should land at the *CLI> prompt. Type core show version to confirm the running version, then type exit to disconnect without stopping the service.
Open the firewall ports. SIP (Session Initiation Protocol) handles call signaling on UDP port 5060. RTP (Real-time Transport Protocol) carries the actual audio streams over a configurable port range:
bashsudo ufw allow 5060/udpsudo ufw allow 10000:20000/udp
SIP and RTP use separate ports because they serve different functions: SIP negotiates and controls calls, RTP delivers the media. Both must be open for VoIP calls to work end to end.
Asterisk is now installed and running on Ubuntu 18.04. Open the Asterisk documentation to learn how to configure SIP trunks, dial plans, and voicemail. Leave a comment below if you run into any issues during the build or startup.
Ghost is an open-source publishing platform built on Node.js. It is designed for bloggers, journalists, and…
Mattermost is an open-source, self-hosted team messaging platform and a direct alternative to Slack. It is…
Ruby is a dynamic, open-source programming language known for its clean, readable syntax. It powers the…
PyCharm is a full-featured Python IDE developed by JetBrains. It includes built-in debugging, embedded Git control,…
PHP 8.5 is included in Ubuntu 26.04's default repositories and is the recommended version for…
Ubuntu 26.04 LTS "Resolute Raccoon" arrived on April 23, 2026 with Linux kernel 7.0, GNOME 50,…