Installing asterisk and freePBX on a debian gnu Linux (alix1d)
Updated on 2009-04-14 by Kerim Teboulbi
Created on 2008-12-10 by Kerim Teboulbi
[personal_context]Create personal context
[Ext_200_201]Accounts 200 and 201
[Ext_202_to_220]Extensions 202 to 220
[Outbound_routes] Outbound routes
[Inbound_routes] Inbound routes
This document describes how to install and configure asterisk and freePBX on a debian Etch. For Installation, we will use the script advised on freePBX website [link]. If Debian is still not installed proceed this document [processing]
The script is just compatible with Debian Etch(4.0r5) with kernel 2.6.18, it will download the asterisk (v. 1.4.21.2) and freePBX(v. 2.4.1) source and compile it. The version of the script used was 0.3.2b. There is a problem with right permission when saving a message on the server with voicemail if you use the default script. Three lines should be commented in app_voicemail.c. The script was modified to download app_voicemail.c from our server, after downloading and decompressing all the sources from Asterisk. Also you should use our copy of the script. You can check if there is some new version of the script here [link]. If you try a new script you should absolutely test the voicemail. Here is the local copy of the script [txt].
All the command line of this part should be done with Putty and a ssh connection. You should always copy and past, never try to rewrite the command.
SwitzernetPBX:~# wget -O asterisk-freepbx_0.3.2_fr_2008-08-28.sh http://switzernet.com/public/081210-install-freepbx/data/asterisk-freepbx_0.3.2_fr_2008-08-28.sh.txt
--15:14:32-- http://switzernet.com/public/081210-install-freepbx/data/asterisk-freepbx_0.3.2_fr_2008-08-28.sh.txt
=> `asterisk-freepbx_0.3.2_fr_2008-08-28.sh'
Resolving switzernet.com... 62.2.195.69
Connecting to switzernet.com|62.2.195.69|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27,737 (27K) [text/plain]
100%[====================================>] 27,737 --.--K/s
15:14:32 (356.68 KB/s) - `asterisk-freepbx_0.3.2_fr_2008-08-28.sh' saved [27737/27737]
SwitzernetPBX:~# chmod a+x asterisk-freepbx_0.3.2_fr_2008-08-28.sh
To install asterisk + freePBX just run the script, this script return a very big result you can see a command result here [txt]:
SwitzernetPBX:~# ./asterisk-freepbx_0.3.2_fr_2008-08-28.sh
You have nothing special to do in the two first part of the script just keep the default option when you have yes or no questions (you should write the letter unless it is in capital, you should write it in tiny letters.) Never press other touch than y, n or enter. Don't install any specific modules now; you will install it with the web interface, and never put any username or password.
If you have the error bellow: just press Ctrl + C, it will retry to start the mysql server later and it will work :
Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!
If you have the error: just before the next question you should see something like this to see that the error was repaired:
Errors were encountered while processing:
mysql-server-5.0
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install. Trying to recover:
Setting up mysql-server-5.0 (5.0.32-7etch8) …
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld ..
Checking for corrupt, not cleanly closed and upgrade needing tables..
+----------------------------------------------------------------+
| Telechargement des sources dans /tmp/freepbx/ |
+----------------------------------------------------------------+
Appuyer sur <Entrer> pour continuer
This part doesn't concern the mysql error: Setting password, download and execute this script [txt]:
SwitzernetPBX:~# wget -O change-password.sh http://switzernet.com/public/081210-install-freepbx/data/change_password.txt
.
.
.
SwitzernetPBX:~# chmod a+x change-password.sh
SwitzernetPBX:~# ./change-password.sh
mysql password changed and manager password changed
When finishing installing this script, restart asterisk:
SwitzernetPBX:~# /etc/init.d/freepbx restart
Stopping FreePBX ...
STOPPING ASTERISK
STOPPING FOP SERVER
Starting FreePBX ...
SETTING FILE PERMISSIONS
Permissions OK
STARTING ASTERISK
Asterisk Started
STARTING FOP SERVER
FOP Server Started
Connect with your favorite web browser on IP address: 192.168.1.200
Now you should select the FreePBX administration link :
Two additional modules should be installed (ring-groups, IVR).
Go on Module Admin Tabulation and click on check for updates online
Now you should select the Ring-group extension and IVR.
Install the package by clicking on process in the bottom of the page. Select also Follow Me, Forward Call and Conferences.
To force the client to use the right outbound route when making external calls, you should create customized context. We created 22 default contexts. You can download the default file here [txt].
wget -O /etc/asterisk/extensions_custom.conf http://switzernet.com/public/081210-install-freepbx/data/extensions_custom.conf.txt
--10:41:50-- http://switzernet.com/public/081210-install-freepbx/data/extensions_custom.conf.txt
=> `/etc/asterisk/extensions_custom.conf'
Resolving switzernet.com... 62.2.195.69
Connecting to switzernet.com|62.2.195.69|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 45,244 (44K) [text/plain]
100%[====================================>] 45,244 --.--K/s
10:41:55 (417.27 KB/s) - `/etc/asterisk/extensions_custom.conf' saved [45244/45244]
Be careful, when using this context you should absolutely use swirternet1 to switzernet22 for the outbound routes.
If you use another name you will break all the configuration.
Now we should configure all internal line, it's exactly the same for all accounts.
Before starting configuring the two extensions we are going to edit a file to set msmtp to send the voicemail instead of sendmail (a mail server). We should edit this file only once.
You should replace the line which start with mailcmd in /etc/asterisk/voicemail.conf
SwitzernetPBX:~# nano /etc/asterisk/voicemail.conf
Now search mailcmd with Ctrl+W
mailcmd line should look like this one (mailcmd=/usr/bin/msmtp –t) :
Ctrl X to exit and choose y to save the file and than press to time enter :
Just click enter to replace the old configuration file
Now we start entering the two first extensions. For number 200 you don't need to put any Outband CID, this line shouldn't be used. This line is just to create a voicemail. So for 200 you can put a random password (not 00).
Go on Extensions Tab and choose Generic SIP Device. Standard we create local line from 202 to 220 (200 and 201 are a little bit different).
You can let quite all informations by default. You should put the User Extension, the display name, the outband CID (number to see when we call), the password (secret) and the voice mail information.
Specify the right context
On voicemail configuration, we should put the client email.
Put the email of the client (from contract).
In case you have more than 2 numbers you should be careful when using the context. You should put the context corresponding to your outbound CID.
The only difference between the lines 200 and 201 is the Outband CID which contains the second phone number and the extension at the end. For account 205 you should put your email address. We will check the voicemail function later.
Specify the right context
On voicemail configuration, we should put the client email.
Now you can add all Extensions you need, when you have done this, don't forget to apply configuration changes like below.
If you're using internet explorer you should restart freepbx with this command:
SwitzernetPBX:~# /etc/init.d/freepbx restart
Stopping FreePBX ...
STOPPING ASTERISK
STOPPING FOP SERVER
Starting FreePBX ...
SETTING FILE PERMISSIONS
Permissions OK
STARTING ASTERISK
Asterisk Started
STARTING FOP SERVER
FOP Server Started
Now we create all internal lines. We can create the group, which will ring when we will receive general calls.
Put the number which will activate the ring group. The Extension List should contain all extensions (from 201 to 220). Voicemail <n°200> will answer if the destination doesn't answer.
Before creating the digital receptionist we will create the message which will speak at the beginning of the IVR
Go on System Recordings tab and choose Built-in Recordings on the right.
You will have a very long list of all messages already on the server. Choose Please-enter-the
Rename Please-enter-the by Please enter-the-extension and add the word extension in the second list choice.
Now your welcome message is ready.
Choose the IVR tab and click on Add IVR
Put a name to the IVR, choose the good announcement, and you can increase a lot of option (there propose 3 at the beginning and we need 21).
After complete all the extension to the correct place (200 to ring_group all), and all the others to the extension number.
Save when you've done all the extensions.
Now all local settings are ok, next steps will configure the external communications.
You can test internal calls now, it should work.
A trunk is a way to communicate from this server with external services (VOIP server or PSTN Line). We have two SIP connections with Switzernet voip server (one for each phone number). So you will make this part twice.
Before adding any informations about trunk we should edit sip.conf, we should add a line after [general] to specify the PBX_Name. The PBX_name shouldn't start with Asterisk. Edit or create if not exit the file /etc/asterisk/sip_general_custom.conf [conf] . Be careful the file name should be exact (because included by sip.conf)
SwitzernetPBX:~# echo "useragent=switzernetPBX" >> /etc/asterisk/sip_general_custom.conf
It's normal if you don't see any result line
Now you can connect on freePBX to create the trunk. Click on Trunks in the left menu, and on Add SIP Trunk.
Now you shouldn't complete the entire page, just complete the Outbound Caller ID and the Outgoing Setting and the register string. Be careful, with secret don't put 'password' but the sip password.
You should put this part to the peer details.
fromdomain=youroute.net
host=sip8.youroute.net
username=412X550XXXX
insecure=invite
secret=XXXXXX
type=friend
You should put a Register String :
412x550xxxx:password@sip8.youroute.net/412x550xxxx
Don't forget to do it twice, one for each number.
We should configure the same number of routes as the number of trunks.
The name of the route should be switzernet x, with x from 1 to 22. It's important to check if the name of the route is corresponding to outbound CID we defined in the extensions.
The dial patterns (here just a . because we don't use special dial patterns).
You should select the good trunk, in Trunk sequence.
We will configure the two inbound routes. Here we explain for one, it's the same thing for the second (just choose the right destination, first ring group and the second IVR)
In general setting, allow anonymous incoming SIP Call..
Don't forget to apply all your changes.
If you're using internet explorer you should restart freepbx with this command:
SwitzernetPBX:~# /etc/init.d/freepbx restart
Stopping FreePBX ...
STOPPING ASTERISK
STOPPING FOP SERVER
Starting FreePBX ...
SETTING FILE PERMISSIONS
Permissions OK
STARTING ASTERISK
Asterisk Started
STARTING FOP SERVER
FOP Server Started
We finished configuring the Asterisk server.
Install asterisk + freepbx:
http://switzernet.com/public/081210-install-freepbx/ (this document)
http://unappel.ch/public/081210-install-freepbx/ (this document)
Asterisk Project Main Page
http://switzernet.com/public/081216-asterisk-main
http://unappel.ch/public/081216-asterisk-main
Asterisk product description:
http://switzernet.com/public/081216-asterisk-description
http://unappel.ch/public/081216-asterisk-description
All process for asterisk product:
http://switzernet.com/company/081215-doc-install-asterisk
http://unappel.ch/company/081215-doc-install-asterisk
Install debian:
http://switzernet.com/public/081201-install-debian-alix1d/
http://unappel.ch/public/081201-install-debian-alix1d/
Install OpenVPN client:
http://switzernet.com/public/081215-openvpn-client
http://unappel.ch/public/081215-openvpn-client
SCP:
http://switzernet.com/public/081212-use-scp
http://unappel.ch/public/081212-use-scp
Install OpenVPN server:
http://switzernet.com/public/081215-openvpn-server
http://unappel.ch/public/081215-openvpn-server
Manage Asterisk through VPN:
http://switzernet.com/company/081216-manage-asterisk-openvpn
http://unappel.ch/company/081216-manage-asterisk-openvpn
Debian OS configuration files (company):
http://switzernet.com/company/081212-install-debian-alix1d-secure
VPN configuration files (company):
http://switzernet.com/company/081216-openvpn-secure
FreePBX:
FreePBX on debian:
http://www.queret.net/blog/index.php/Voip-asterisk-telephonie
* * *
Copyright © 2008 Switzernet