For the uninitiated, Asterisk is an open-source, widely used private branch exchange (PBX) platform. Individuals, businesses, and governments across the globe are using it to power their VoIP and conferencing infrastructures. Asterisk provides a complete set of features that include voicemail, interactive voice response, conference calling, music on hold, call queuing, call recording, and many more that I can’t list here. If you need an open-source PBX platform to run your business or institution, then look no further than Asterisk. This post should come in handy and get you started and quickly. For more about Asterisk, please visit its homepage. To get started with installing Asterisk, please follow the steps below:
Download and Install Asterisk
To install Asterisk, you’ll have to have some basic packages installed. To install these packages, run the commands below: Since we’re going to be manually downloading Asterisk packages, let’s put them in the system /usr/src directory since it’s where most source files are stored. To do that, change into the /usr/src directory and download Asterisk. To get the latest version of Asterisk, the visit is package repository here. Then replace the version number in the commands below with the latest. At the time of this wiring, the current version is 17. Once the Asterisk file is downloaded, extract it, then change it into its directory and run the installation script that will download and install all dependencies, including MP3 modules. After running the commands above, the script should download and install all packages. then prints out a successful message similar to the one below: Next, run the commands below to configure and perform some checks and validate that all is well. After successful completion, it should display similar lines as below: After that, you will want to select some modules to compile and install. You can access the menu system using the commands below: Because we want to use MP3 as our audio format and have already downloaded its module above, choose the format_mp3 as shown in the image below: Once you are finished, press F12 to save and exit, or switch to the Save and Exit button and press Enter. When you’re all done, run the commands below to start the compilation process. The compilation may take some time, depending on your system. The -j flag with the number represents the number of CPUs on your server. If your server has more than 2 CPU cores, then change it to that. Once the packages and modules are compiled, you should see a success message similar to the one below: After compiling the above, you can finally install Asterisk by running the commands below: After the installation, you should see a similar message as below: Installation is complete. You can now begin configuring your system. First, you may want to add some sample data to help you with configuring your platform. To do that, run the commands below: Finish the configuration by running the commands below:
Creating Asterisk User
We don’t want to have an Asterisk running as the root user. So let’s create a dedicated user that will run as an Asterisk. To do that, run the commands below to create an account and a group called asterisk. After creating the account above, open the /etc/default/asterisk file and make the highlighted changes below: Then make the highlighted changes below and save the file. After that, add an asterisk user to the dialout and audio groups: Next, change permissions on all of the Asterisk files and directories to make their users owners.
Starting Asterisk
At this point, all is done. Run the commands below to enable and start the Asterisk service. To verify that Asterisk is running, run the commands below: You’ll see the default Asterisk CLI prompt: Most Ubuntu installations don’t have a firewall enabled. If you do, you’ll want to allow the ports below. By default, SIP uses the UDP port 5060. Open the following port. For Real-Time Protocol (RTP) open the following port range: That’s it! Conclusion: This post showed you how to install and configure Asterisk on Ubuntu 18.04 | 16.04. If you find any error above, please use the form below to report it.