VMware ESXi and vSphere Cluster Management
Install Asterisk from a Package Repository on Ubuntu
Learn to install Asterisk on Ubuntu with apt-get, review dependencies, validate the service, connect to the CLI, and handle common package-management problems.
Asterisk is open-source communications software for building PBX, VoIP, IVR, conferencing, voicemail, and call-routing systems. On Ubuntu, the simplest installation method is usually the configured software repository.
A software repository is a package source containing indexed and signed software packages and metadata. A package is a distributable unit of software managed by the operating system. A dependency is another package required to provide libraries, tools, features, or runtime support.
How Repository Installation Works
Ubuntu repositories provide prebuilt Asterisk packages and the dependencies needed to run them. APT is the package-management system used by Ubuntu and other Debian-based distributions, while apt-get is its command-line utility for updating package indexes and installing, upgrading, or removing packages.
The basic flow is:
- APT contacts the configured repository mirrors.
- APT downloads a package index, which is local metadata describing available packages.
- APT selects the Asterisk package and resolves required dependencies.
- APT downloads and installs the packages.
- The distribution's service-management system may start Asterisk after installation.
Repository Packages Versus Building from Source
| Consideration | Repository Package | Source Build |
|---|---|---|
| Installation effort | Usually straightforward; APT resolves dependencies and records installed files. | Requires build tools, development libraries, configuration choices, compilation, and installation steps. |
| Updates | Managed through normal Ubuntu package operations. | Usually requires repeating a deliberate source-build and upgrade process. |
| Version | Selected and maintained for the Ubuntu release; it may not be the newest upstream version. | Can target a specific upstream release when compatible dependencies are available. |
| Optional features | Limited to what the distribution packages and enables. | Provides more control over modules and compile-time options. |
| Best fit | Basic deployments, learning, and systems that prioritize distribution integration. | Deployments needing a particular release or features unavailable in the repository package. |
Prerequisites
- Use a supported Ubuntu or another Debian-based distribution.
- Ensure the host has network access to the configured package mirrors.
- Use an account that can run commands with sudo. Sudo permits an authorized user to run a command with administrative privileges.
- Check available disk space, especially on the root filesystem and the filesystem used for the APT cache.
- Confirm that another APT, dpkg, update, or unattended-upgrade process is not currently running.
On a production system, plan a maintenance window and review system upgrades before applying them. A system-wide upgrade can change more than Asterisk.
Refresh Package Metadata and Apply Updates
Before installing software, refresh the local package index. Without current metadata, APT may not know about packages available from the configured repositories or may try to use stale version information.
For a basic setup, refresh the index and upgrade installed packages with:
sudo apt-get update && sudo apt-get upgrade
The first command downloads current repository metadata. The second replaces installed packages with newer versions when available. Review the proposed upgrades, package removals, download size, and disk-space impact before confirming. On production systems, some administrators run the commands separately so that the upgrade plan can be reviewed independently.
| Command | Purpose | When to Use It | Operational Notes |
|---|---|---|---|
sudo apt-get update | Refreshes local package indexes. | Before installing or searching for packages. | Requires access to the configured repository mirrors. |
sudo apt-get upgrade | Upgrades installed packages without intentionally removing packages to resolve changes. | After reviewing available updates. | Review the transaction carefully on production systems. |
sudo apt-get install asterisk | Installs Asterisk and required dependencies. | After the package index is current. | Review the transaction summary before entering Y. |
dpkg -l asterisk | Shows the package-manager status of Asterisk. | To verify whether the package is installed. | Look for an installed package status in the output. |
asterisk -V | Displays the installed Asterisk version. | After installation. | Confirms that the executable is available in the command path. |
sudo systemctl status asterisk | Shows the Asterisk service state on systemd-based systems. | To check whether the service is running. | Unit availability and behavior can vary by distribution release. |
sudo asterisk -rvvv | Connects to a running local Asterisk CLI with increased verbosity. | After confirming that the service is running. | Requires a local running instance and sufficient privileges. |
Install Asterisk
Install the repository package named asterisk:
sudo apt-get install asterisk
APT calculates the dependency set and presents a transaction summary. Read the summary before continuing. It commonly includes:
- Packages to be installed or upgraded.
- Total download size.
- Additional disk space required after installation.
- Repository versions selected for Asterisk and its dependencies.
Enter Y when the prompt appears only after confirming that the proposed changes are appropriate. APT then downloads, unpacks, and configures Asterisk and its required packages.
What the Installation May Include
The exact dependency list is release-specific. Do not treat the following categories as a fixed list or assume that every item has the same package name on every Ubuntu release.
| Package Category | Purpose | Examples of Contents | Whether It Is Usually Installed Automatically |
|---|---|---|---|
| Core application files | Provides the Asterisk executable and primary runtime files. | Server process, standard directories, and base runtime components. | Yes, as part of the main package. |
| Configuration files | Supplies initial configuration used by the installed service. | System and Asterisk configuration templates or defaults. | Usually, through the main package or associated packages. |
| Loadable modules | Adds channel, application, codec, and integration functionality. | Protocol handling, dialplan applications, codecs, and resource modules. | Required modules are; optional modules vary by release and packaging. |
| English core sound prompts | Provides standard prompts used by many Asterisk applications. | English language system audio. | Often, depending on the distribution package split. |
| Music-on-hold audio | Provides audio used while callers wait. | Packaged music-on-hold files or supporting resources. | Often included or pulled in as a related package. |
| Voicemail support | Enables voicemail-related applications and runtime support. | Voicemail application components and related modules. | Commonly included when required by the distribution package. |
| Media and telephony libraries | Supports audio processing, codecs, timing, and communications functions. | Runtime libraries used by Asterisk modules. | Required libraries are installed automatically. |
| Audio utilities | Supports handling or conversion of audio resources. | Tools or libraries for supported audio formats. | Required components are; additional formats may be optional. |
APT may also list suggested packages that are not installed automatically. These can include documentation, development files, DAHDI integration, protocol add-ons, ODBC or database drivers, and additional audio-format support. DAHDI is hardware and telephony interface support commonly used with certain traditional telephony cards and timing sources. Install optional packages only when a planned feature requires them.
Validate the Installation
Check the Package Status
dpkg -l asterisk
This queries dpkg, the lower-level Debian package database. The result should show that the Asterisk package is installed. If the package is missing or only partially configured, inspect the APT output and resolve that problem before proceeding.
Check the Version
asterisk -V
Record the reported version when documenting the host or comparing available features. The version reflects the package supplied by the configured Ubuntu repositories.
Check the Service
sudo systemctl status asterisk
On systemd-based Ubuntu releases, this displays whether the service is active, inactive, or failed. You can also check whether it is configured to start at boot:
sudo systemctl is-enabled asterisk
Service unit availability and automatic-start behavior can vary by package and distribution release. If the service is stopped, do not assume that the package installation failed; inspect its status and startup logs first.
Connect to the Asterisk CLI
The Asterisk CLI is the interactive command-line interface for inspecting and administering a running Asterisk instance.
sudo asterisk -rvvv
The command attaches to the local running instance and requests increased CLI verbosity. Exit the CLI with exit or the appropriate end-of-input key sequence for your terminal.
Troubleshooting
Repository Connection Errors
If apt-get update cannot download package information, check network connectivity, DNS, proxy settings, repository mirror availability, and the configured Ubuntu release sources. Resolve the source or connectivity problem before retrying.
No Installation Candidate
If APT reports that asterisk has no installation candidate, the package indexes may be stale, the required Ubuntu repository components may not be enabled, or the selected release may not provide the package in its configured sources. Run the package index update, inspect the APT source configuration, and query the available package information before trying again.
sudo apt-get update
apt-cache policy asterisk
apt-cache search asterisk
Package Manager Is Locked
A locked package manager usually means that another APT, dpkg, update, or unattended-upgrade process is active. Identify the active process and allow it to finish. Do not delete lock files while a valid package-management process is running, because doing so can corrupt package-management state.
Insufficient Disk Space
Check filesystem capacity if installation stops because there is not enough space. Free appropriate space on the affected filesystem, then rerun the installation. Account for both downloaded packages and their unpacked contents.
Service Does Not Run or the CLI Cannot Connect
If Asterisk installs but the service is not running, inspect the service state and system logs:
sudo systemctl status asterisk
sudo journalctl -u asterisk
A startup failure can result from a configuration problem, a permission issue, a missing runtime component, or a service that has not been started or enabled. Inspect the reported error and Asterisk logs before attempting to connect to the CLI.
Expected Feature or Module Is Missing
The Ubuntu package may be an older distribution-maintained release, or the requested feature may be packaged separately or omitted. Compare asterisk -V and the available package set with the feature's requirements. Consider another supported package source or a source build only when the repository package cannot meet the requirement and the operational consequences are understood.
Package Lifecycle
Manage future Asterisk upgrades and removal with APT. A normal system upgrade can update the repository-provided Asterisk version along with other installed packages.
sudo apt-get update
sudo apt-get upgrade
Locally edited configuration files may trigger package-maintainer prompts during upgrades. Back up configuration before changes, record which files are locally managed, and deliberately choose how to handle a package-provided version versus the locally modified version.
Removing the package is also an APT operation, but removal and configuration-file cleanup have different effects. Review the proposed transaction before confirming any removal, especially on a host that may contain call data or custom configuration.
Ubuntu and Other Distribution Families
This lesson uses Ubuntu's Debian-based APT workflow. CentOS, RHEL, Fedora, and other RPM-based systems use different package managers, package names, repository conventions, service packaging, and dependency layouts. Their procedures are not interchangeable with the commands shown here.
Next Steps
- Review the Asterisk directory layout, configuration files, and logs.
- Learn to manage the service with systemd.
- Create SIP or PJSIP endpoints.
- Write a dialplan and configure trunks and outbound routing.
- Configure firewall, NAT, and RTP behavior for VoIP.
- Apply Asterisk security hardening and establish an update-management process.
- Evaluate DAHDI when traditional telephony hardware or timing support is required.
For this repository-based procedure, return to the Asterisk repository installation guide when repeating the workflow on another Ubuntu host.