VMware ESXi and vSphere Cluster Management

Install Asterisk from Source on CentOS

Learn how to compile and install Asterisk from source on CentOS, including dependencies, configuration, compilation, service setup, and validation.

Overview

Asterisk is open-source communications and PBX software used to build telephony and VoIP systems. It is Linux-distribution agnostic, so it can run on CentOS and other compatible Enterprise Linux systems.

This lesson covers a source-based installation: updating CentOS, installing build dependencies, downloading and extracting an Asterisk tarball, configuring the build, compiling the source, installing the resulting files, adding service-management support, and validating the running installation.

For basic shell, package-management, and privilege concepts, see the CentOS Asterisk installation guide.

Source Installation Versus Repository Installation

A source installation downloads a program's source code, extracts it, compiles it, and installs the resulting binaries and support files. The compiler transforms C and C++ source code into executable programs and modules for the target system.

A repository installation uses the operating system's package manager to install a prebuilt package. Repository packages are generally faster and simpler to install because the software has already been compiled and packaged.

ApproachAdvantagesTrade-offs
Source installationMore control over release selection, optional modules, compiler settings, and installation behavior. It also helps administrators understand Asterisk's build structure.Requires more time, disk space, build knowledge, and ongoing responsibility for upgrades and maintenance.
Repository installationUsually easier to install, update, remove, and integrate with the operating system.Available versions and build options depend on the repository. The package may not provide the customization needed for a particular deployment.

Choose an Asterisk Release

Select the Asterisk version before downloading its source. Asterisk release lines generally fall into two categories:

Release typeSupport lifecycle characteristicTypical use case
LTSLong Term Support releases are intended to receive support for a longer period.Stability-oriented deployments, labs that should remain consistent, and production systems with a longer maintenance horizon.
StandardStandard releases have a shorter support lifecycle than LTS releases.Testing newer features or using a release line whose shorter maintenance period is acceptable.

For a real deployment, review the currently supported release lines and choose the version that matches your compatibility and maintenance requirements. Obtain the current, version-specific source URL from the official Asterisk download location. Do not assume that an older example version is still supported or preferred.

Installation Workflow

StagePrimary command or actionPurposeExpected result
System updateyum updateApply current operating-system packages and security fixes.CentOS reports that packages were updated or are current.
Dependency installationyum install ...Install compilers, build tools, download utilities, and development headers.Required build packages are installed.
Source downloadwget <official-source-url>Retrieve the selected Asterisk tarball.A complete archive exists in the working directory.
Archive extractiontar xvfz <archive>Unpack the compressed source archive.A versioned source directory is created.
Configuration check./configureDetect tools, headers, libraries, and optional capabilities.Build files are generated without unresolved required dependencies.
CompilationmakeCompile Asterisk and its selected components.Object files, binaries, and modules are built.
Installationmake installCopy compiled software and support files into their installation locations.Asterisk files are installed on the host.
Service initializationmake config or the host's systemd methodInstall service-management support.The operating system has a way to start and manage Asterisk.
Validationasterisk -V, service status, and asterisk -rvvvCheck the installed version and confirm that the daemon is running.The binary reports its version and the CLI connects to the local process.

Prepare the CentOS Host

Run the following commands from a shell with appropriate administrative privileges. On systems where your account uses sudo, prefix package and installation commands with sudo. Alternatively, open a root shell carefully.

yum update

Updating first applies available operating-system fixes and ensures that the build uses current installed libraries. If the update includes a new kernel or other major system components, reboot when appropriate before continuing:

reboot

A reboot is not required after every update, but it is often appropriate after a kernel update so the running system and installed packages are aligned.

Command availability and package names vary across CentOS releases and related Enterprise Linux distributions. Older CentOS systems commonly use yum; modern systems may provide dnf, sometimes with yum as a compatibility command.

Install Build Tools and Development Dependencies

A compiler is not enough by itself. Asterisk's configure stage may need library headers, linker metadata, and optional feature libraries. A development package usually contains the headers and metadata required to compile software against a library. Missing development headers can disable modules or cause configuration failures.

yum install gcc gcc-c++ make wget subversion libxml2-devel ncurses-devel openssl-devel sqlite-devel libuuid-devel vim-enhanced jansson-devel.x86_64
Package or package groupRole in the buildTypical failure if missing
gcc and gcc-c++C and C++ compilers used to build Asterisk.Compilation cannot start or compiler checks fail.
makeBuild automation tool that follows generated build rules.There is no build command available after configuration.
wgetCommand-line downloader for retrieving the source archive.The documented download command is unavailable.
subversionSource-management utility that may be required by build or development workflows.Source-related helper steps or expected build tooling may be unavailable.
libxml2-develXML headers and metadata.XML-dependent checks or modules may be disabled or fail.
ncurses-develTerminal UI headers used by console and CLI-related components.Terminal interface support may be unavailable.
openssl-develOpenSSL/TLS headers and libraries.TLS-related capabilities or modules may not configure.
sqlite-develSQLite development headers and linker information.SQLite-backed functionality may be disabled.
libuuid-develUUID generation and related development files.UUID checks or dependent modules may fail.
jansson-devel.x86_64Jansson JSON development files for JSON-related functionality.JSON-dependent modules may be disabled or rejected during configuration.
vim-enhancedText editor for inspecting or editing configuration files.Editing files from the terminal is less convenient; it is not normally a compiler requirement.

The exact package names and architecture suffixes can differ. If the package manager cannot find one of these names, search the repositories for the corresponding library's development package and use the name appropriate for your CentOS or Enterprise Linux release.

Download and Extract the Asterisk Source

Move to a workspace with sufficient disk space, then download the archive for the release you selected. Replace the placeholder with the current official source URL:

wget <official-asterisk-source-url>

The following is a version-specific example format. It illustrates the command structure only; verify the release and URL before using it:

wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz

Verify that the download completed successfully before extracting it. Check the file's size and type, and compare any available checksum from the official release source. A surprisingly small file may be an error page rather than a tarball.

ls -lh asterisk-*.tar.gz
file asterisk-*.tar.gz

Extract the gzip-compressed tar archive:

tar xvfz asterisk-13-current.tar.gz

List the resulting directories and enter the one created by extraction. The exact name depends on the selected version:

ls -ld asterisk-*
cd asterisk-13.13.1

Replace asterisk-13.13.1 with the actual directory name on your system. If cd fails, list the current directory rather than assuming the example version was extracted.

Configure the Build

Run configure from inside the extracted source directory:

./configure

configure is a build-preparation script. It checks for compiler tools, headers, libraries, and optional capabilities, then generates the build files that make will use.

Read the output instead of treating the command as a formality. Look for failed checks, missing libraries, and disabled optional features. A missing -devel package can prevent a feature from being detected even when the corresponding runtime library is installed.

If you install additional dependencies after a failed configuration, run ./configure again before compiling. Proceed only when required checks complete successfully and the resulting summary matches the features you expect.

Compile and Install Asterisk

Compile the source with make:

make

Compilation can take time, depending on the host's processor, memory, storage, and selected modules. Build errors must be resolved before installation. The first meaningful error is usually more useful than the final summary message.

When compilation completes successfully, install the compiled binaries, modules, configuration templates, and related support files:

make install

make builds software in the source tree. make install copies the completed results into the filesystem locations expected by the Asterisk installation.

Install Service Initialization Support

The source tree may provide a configuration target that installs initialization support:

make config

An init script is a script used by traditional SysV init systems to start, stop, and manage a service. systemd is the service manager used by modern Enterprise Linux releases. These systems do not always use the same service definition or commands.

Installing an init script is not the same as proving that Asterisk starts successfully. On a systemd-based host, confirm that the source version's service method is compatible with systemd. You may need a systemd-specific service unit or another service-management configuration supplied for that release.

Validate the Installation

Check the Installed Binary

Confirm that the executable is available and report its version:

asterisk -V

A successful result identifies the installed Asterisk version. If the shell cannot find the command, check whether the installation completed and whether the binary's installation directory is in the current PATH.

Inspect and Start the Service

Use the service manager supported by the host. Traditional SysV-style systems may use a service command, while systemd systems commonly use systemctl. The exact service name and unit configuration should match the source installation and operating-system generation.

service asterisk status
service asterisk start
systemctl status asterisk
systemctl start asterisk

Do not assume that a successful service-installation command means the daemon is healthy. Inspect the status output and startup messages.

Connect to the Asterisk CLI

Once the daemon is running, connect to its local command-line interface:

asterisk -rvvv

The -r option requests a remote connection to the running local Asterisk process, and the repeated v options increase console verbosity. A successful connection confirms that the process is running and that the CLI can reach its local runtime environment.

Review Logs

If the service does not start, the CLI cannot connect, or modules fail to load, review the operating-system service logs and Asterisk logs. Look for permission errors, invalid configuration, missing shared libraries, port conflicts, and module-loading failures. Correct the underlying error, restart the service, and repeat the version, status, and CLI checks.

Troubleshooting

SymptomLikely causeResolution
The configure script reports a missing library, header, or feature.A required development package is absent, or its package name differs for the CentOS release.Install the matching -devel package, rerun ./configure, and confirm that the dependency is detected.
The downloaded file cannot be extracted or is unexpectedly small.The download was interrupted, the URL is invalid, or an HTML error page was saved instead of the archive.Check the file type and size, obtain the correct official release URL, and download the archive again.
The cd command fails after extraction.The extracted directory name differs from the example because another version was downloaded.Run ls and enter the actual extracted source directory.
make fails during compilation.Compiler tools, headers, or compatible dependency versions may be missing, or configuration reported an earlier problem.Read the first meaningful build error, install the relevant dependency, rerun ./configure if needed, and run make again.
make config completes but the expected service command does not work.The host uses systemd while the installed method targets SysV init, or the service definition is not enabled.Identify the service manager and use or create the appropriate service unit or initialization configuration.
Asterisk is installed but does not start or the CLI cannot connect.The daemon is stopped, startup failed because of permissions or configuration, or the CLI is targeting the wrong runtime environment.Check service status and Asterisk logs, correct the startup issue, start the daemon, and retry asterisk -rvvv.

Exam-Relevant Notes

  • Source installation means downloading, extracting, compiling, and installing source code; it is different from installing a prebuilt repository package.
  • LTS releases have longer support lifecycles and are usually preferred for stability-oriented deployments. Standard releases have shorter lifecycles.
  • configure detects capabilities and generates build files; make compiles; make install installs; and make config installs initialization support where compatible.
  • A runtime library alone may not be sufficient for compilation. The corresponding development package usually provides required headers and metadata.
  • Installing service support does not prove that Asterisk starts successfully. Validate with service status, logs, asterisk -V, and asterisk -rvvv.
  • Package names, commands, and service-management behavior vary between CentOS generations and related Enterprise Linux distributions.