Asterisk is the foundational open-source telephony engine powering most self-hosted PBX systems — giving you full control over call routing, voicemail, and telephony features without a commercial phone system vendor.
Prerequisites
- Ubuntu 22.04/24.04 VPS: 2 vCPU, 2-4 GB RAM (scales with concurrent call volume)
- Root or sudo access
Step 1 — Install Build Dependencies
sudo apt update
sudo apt install build-essential libssl-dev libncurses5-dev libnewt-dev libxml2-dev linux-headers-$(uname -r) libsqlite3-dev uuid-dev libjansson-dev -y
Step 2 — Download Asterisk Source
cd /usr/src
sudo wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-VERSION-current.tar.gz
sudo tar xvfz asterisk-*-current.tar.gz
Check Asterisk's official site for the current recommended long-term support version.
Step 3 — Install Prerequisite Libraries
cd asterisk-*/
sudo contrib/scripts/install_prereq install
Step 4 — Configure and Compile
sudo ./configure
sudo make menuselect.makeopts
sudo make -j$(nproc)
sudo make install
sudo make samples
sudo make config
Compilation can take significant time depending on your VPS's CPU — this is normal.
Step 5 — Start Asterisk
sudo systemctl enable --now asterisk
Step 6 — Access the Asterisk CLI
sudo asterisk -rvvv
The interactive console lets you monitor calls, reload configuration, and debug in real time.
Step 7 — Allow Required Firewall Ports
sudo ufw allow 5060/udp
sudo ufw allow 10000:20000/udp
Port 5060 handles SIP signaling; the RTP range handles actual voice media — both are required for calls to function correctly.
Basic Configuration Files to Know
| File | Purpose |
|---|---|
| sip.conf / pjsip.conf | SIP endpoint/extension definitions |
| extensions.conf | Call routing/dialplan logic |
| voicemail.conf | Voicemail box configuration |
Next Steps
Raw Asterisk configuration is done entirely via text files — if you'd prefer a web-based management interface, see How to Install FreePBX on a VPS, which wraps Asterisk with a friendlier admin GUI.
Securing Your Installation Immediately
A newly installed, internet-facing Asterisk server is a common target for toll fraud attacks — see How to Secure a VoIP Server Against Toll Fraud before configuring any real extensions or trunks.
Common Errors
Compilation fails with missing dependency errors — re-run install_prereq install and verify all required packages installed successfully before retrying make.
No audio on calls despite successful connection — almost always an RTP port/firewall or NAT configuration issue; verify the RTP port range is open and correctly configured in rtp.conf.
Continue Reading
- How to Install FreePBX on a VPS
- How to Secure a VoIP Server Against Toll Fraud
- How to Configure Extensions and Voicemail in Asterisk
Browse more articles in VoIP & Communication Servers.