Home › Blog › Install Asterisk on Ubuntu
How to install Asterisk and FreePBX on Ubuntu 24.04
Asterisk is the most popular open-source PBX. This guide builds Asterisk 20 LTS from source on Ubuntu 24.04, runs it as a dedicated non-root user, and adds the FreePBX web GUI so you can manage it from a browser.
downloads.asterisk.org and freepbx.org before you start, and always test on a non-production server first.Step 1 — Install dependencies
Update the system and enable the Universe repository, then install the build tools and libraries Asterisk needs:
sudo add-apt-repository universe -y
sudo apt update && sudo apt upgrade -y
sudo apt install -y git curl wget build-essential subversion \
libxml2-dev libncurses5-dev libjansson-dev libsqlite3-dev \
uuid-dev libedit-dev libssl-dev pkg-config sox
Step 2 — Build and install Asterisk
Download and extract Asterisk 20, pull in extra prerequisites, then configure and compile:
cd /usr/src
sudo wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20-current.tar.gz
sudo tar xvf asterisk-20-current.tar.gz
cd asterisk-20.*/
# MP3 source + remaining prerequisites
sudo contrib/scripts/get_mp3_source.sh
sudo contrib/scripts/install_prereq install
# Configure and pick modules
sudo ./configure
sudo make menuselect # enable Core/MOH/Extra sound packages, then Save & Exit
# Compile and install
sudo make -j$(nproc)
sudo make install
sudo make samples
sudo make config
sudo ldconfig
menuselect, enable Core Sound Packages, Music On Hold and Extra Sound Packages so you have prompts and hold music out of the box.Step 3 — Configure the asterisk user
Never run Asterisk as root. Create a dedicated user and hand it ownership of the Asterisk directories:
sudo groupadd asterisk
sudo useradd -r -d /var/lib/asterisk -g asterisk asterisk
sudo usermod -aG audio,dialout asterisk
sudo chown -R asterisk:asterisk /etc/asterisk
sudo chown -R asterisk:asterisk /var/{lib,log,spool}/asterisk
sudo chown -R asterisk:asterisk /usr/lib/asterisk
Tell Asterisk to run as that user. In /etc/default/asterisk set AST_USER="asterisk" and AST_GROUP="asterisk", and in /etc/asterisk/asterisk.conf uncomment and set runuser = asterisk and rungroup = asterisk.
Step 4 — Start and verify
sudo systemctl restart asterisk
sudo systemctl enable asterisk
sudo systemctl status asterisk
sudo asterisk -rvv # connect to the CLI; type 'exit' to leave
If you see the CLI banner and "Connected to Asterisk … running", the core install is done.
Step 5 — Install FreePBX (optional web GUI)
FreePBX gives you a browser interface for extensions, trunks and modules. Open the firewall, install the LAMP stack and PHP, then run the FreePBX installer:
# Firewall: SSH, web, SIP signalling and RTP media
sudo ufw allow 22/tcp
sudo ufw allow 80,443/tcp
sudo ufw allow 5060/udp
sudo ufw allow 10000:20000/udp
sudo ufw enable
# Web + database + PHP
sudo apt install -y apache2 mariadb-server nodejs npm \
php php-cli php-mysql php-curl php-gd php-mbstring php-xml \
php-intl php-zip php-bcmath php-soap libapache2-mod-php
# FreePBX
cd /usr/src
sudo wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-17.0-latest.tgz
sudo tar xvf freepbx-17.0-latest.tgz
cd freepbx
sudo ./install -n
Point Apache at the asterisk user, enable rewrites and restart, then open http://your-server-ip/admin in a browser to create the admin account and reach the FreePBX dashboard.
Security best practices
- Strong, unique passwords on every SIP account — weak extensions are the #1 way Asterisk boxes get toll-fraud abused.
- Restrict SIP/RTP ports to trusted IPs; never expose SIP wide-open to the internet.
- Enable TLS + SRTP for SIP where you can.
- Run
fail2banand keep the OS and Asterisk patched. - Watch
/var/log/asterisk/for repeated failed registrations.
Rather not run any of this?
Building and securing Asterisk is real ongoing work. Qallixo is a managed cloud platform built on this same technology — dialers, IVR, recording and WhatsApp with no servers to run. See the managed vs self-hosted comparison, or read how Asterisk compares to FreeSWITCH, Kamailio and OpenSIPS.