Periodically, I need to install and configure Asterisk. I'm a bit tired of having to remember the entire sequence of actions and searching for all the commands on the internet each time. So, I decided to write my own guide.
This will describe the installation process without configuration, without installing additional components like chan_dongle and FreePBX, etc. Separate articles will be written about the installation and configuration of these components.
We will install it on Ubuntu 14. The description below will also work for other Linux systems, but some commands will need to be edited. For Debian, everything should work without changes.
WARNING, all the posted code can be copied in blocks, not one command at a time.
Installing all necessary dependencies. If something is not installed, then something will not work in the end!
sudo apt-get install libncurses5-dev libssl-dev libxml2-dev libsqlite3-dev libmysqlclient15-dev curl mpg123 libxml2 libxml2-dev libaudiofile-dev subversion sox libiksemel-dev libssl-dev sudo apt-get install linux-headers-`uname -r`
Download and compile the latest version of DAHDI
The link is valid as of early 2019.
Download and unzip
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz tar -zxvf dahdi-linux-complete-current.tar.gz
Go to the directory we unpacked and compile DAHDI
cd dahdi* sudo make all && sudo make install && sudo make config cd ..
Download and compile the latest version of libpri
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz tar -zxvf libpri-current.tar.gz cd lib* sudo make && sudo make install cd ..
Prepare Asterisk
Download Asterisk itself. At the time of writing, the latest version was asterisk-11.25.3 (Since the development of this version has already ended, there will be no new ones)
wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-11.25.3.tar.gz tar -zxvf asterisk* cd asterisk*
Configure Asterisk
./configure
When finished, you should see an asterisk.
Invoke the configuration menu
make menuselect
Select the following
Add-ons: format_mp3, app_mysql, cdr_mysql
Resource Modules: res_xmpp (not mandatory. Used for notifications in Jabber about missed calls)
Core Sound Packages: CORE-SOUNDS-EN-ALAW, CORE-SOUNDS-EN-GSM, CORE-SOUNDS-EN-G729, CORE-SOUNDS-RU-ALAW, CORE-SOUNDS-RU-GSM, CORE-SOUNDS-RU-G729
Music On Hold File Packages: MOH-OPSOUND-WAV
Extras Sound Packages: ALAW, GSM, and G729
Press [S] to save the configuration
Since we selected the mp3 support module, we run the script to download the mp3 source
contrib/scripts/get_mp3_source.sh
Compile and install
sudo make install
The compilation takes a long time; the weaker the computer, the longer the compilation. It took me about 5 minutes
Demo configs (if not needed, skip this point)
sudo make samples
Generate all necessary scripts and configs without which it will not work.
sudo make config
Exit the directory and start
cd .. sudo /etc/init.d/asterisk start
Next, enter the Asterisk console; if you got in, everything is okay
sudo asterisk -rvvvvvvvvvv
You can exit it by typing "exit" or using the key combination "Ctrl+C"
Install the G279 codec
G.729 is a narrowband speech codec used for efficient digital representation of narrowband telephone speech.
Open in your browser http://asterisk.ru/codecs/
And select the version of the G279 codec that is suitable for your processor. Then copy the link and substitute it into the command (right-click on the link and select "Copy link address")
wget -P /usr/lib/asterisk/modules -O codec_g729.so "link address"
(do not include the quotes, you should get something like this)
wget -P /usr/lib/asterisk/modules -O codec_g729.so http://asterisk.hosting.lv/bin/codec_g729-ast110-gcc4-glibc-x86_64-core2-sse4.so
Minimum configuration needed for Asterisk to work properly
Create user, groups, and launch directory
sudo /etc/init.d/asterisk stop sudo adduser --system --group --home /var/lib/asterisk --no-create-home --gecos "Asterisk PBX" asterisk sudo adduser asterisk dialout sudo adduser asterisk audio sudo adduser www-data asterisk sudo mkdir -p /var/run/asterisk
Change permissions on the necessary directories
If you do not have Dahdi devices in your system, the system will complain about this. This is normal
sudo chown -R asterisk:asterisk /var/lib/asterisk sudo chown -R asterisk:asterisk /var/log/asterisk sudo chown -R asterisk:asterisk /var/run/asterisk sudo chown -R asterisk:asterisk /var/spool/asterisk sudo chown -R asterisk:asterisk /usr/lib/asterisk sudo chown -R asterisk:asterisk /dev/dahdi sudo chmod -R u=rwX,g=rX,o= /var/lib/asterisk sudo chmod -R u=rwX,g=rX,o= /var/log/asterisk sudo chmod -R u=rwX,g=rX,o= /var/run/asterisk sudo chmod -R u=rwX,g=rX,o= /var/spool/asterisk sudo chmod -R u=rwX,g=rX,o= /usr/lib/asterisk sudo chmod -R u=rwX,g=rX,o= /dev/dahdi sudo chown -R asterisk:asterisk /etc/asterisk sudo chmod -R u=rwX,g=rX,o= /etc/asterisk
In the file /etc/default/asterisk, uncomment two lines and change the group name
AST_USER="asterisk"
AST_GROUP="dialout"
Start Asterisk and check which user it started under
sudo /etc/init.d/asterisk start ps aux | grep asterisk
All is well!
Reboot the system and enjoy)