How to Install Asterisk PBX on a VPS

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

FilePurpose
sip.conf / pjsip.confSIP endpoint/extension definitions
extensions.confCall routing/dialplan logic
voicemail.confVoicemail 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

Browse more articles in VoIP & Communication Servers.

  • asterisk pbx, asterisk installation, self hosted voip, asterisk vps
  • 0 Usuários acharam útil
Esta resposta lhe foi útil?

Artigos Relacionados

How to Install FreePBX on a VPS

FreePBX is a widely-used, open-source web interface built on top of Asterisk — making PBX...

How to Set Up SIP Trunking for Your PBX

A SIP trunk connects your self-hosted PBX to the public telephone network, letting you make and...

How to Configure Extensions and Voicemail in Asterisk

Extensions are the individual phone lines within your PBX system, and voicemail lets callers...

How to Secure a VoIP Server Against Toll Fraud

An unsecured VoIP server is a common target for toll fraud — attackers who compromise weak...

How to Set Up an IVR (Interactive Voice Response) Menu

An IVR menu greets callers with recorded prompts and routes them based on their keypad selections...