I have read about Asterisk and wanted to test it out as I will be managing/troubleshooting it at work anytime soon, so I thought of getting my hands dirty and getting some basic experience on it. First, I set up a box with Linux RedHat ES4 but I think any Linux distro would do. Kubuntu/Ubuntu, Fedora or Mandriva would work fine.
Here we go:
1) Get linux installed and mark down the IP address of the box.
2) su to root, then download the current tar files from http://downloads.digium.com/pub to /usr/src:
- Asterisk to /asterisk
- Zaptel to /zaptel
- Libpri to /libpri
- asterisk-addons to /asterisk-addons
3) Follow the commands bellow to untar each package in /usr/src (in this example I’m using versions that were up-to-date, change the version numbers to what ever versions you downloaded):
tar -zxvf asterisk-1.4.4.tar.gz
ln -s asterisk-1.4.4 asterisk
tar -zxvf zaptel-18.104.22.168.tar.gz
ln -s zaptel-22.214.171.124 zaptel
tar -zxvf libpri-1.4.0.tar.gz
mv libpri-1.4.0 libpri
tar -zxvf asterisk-addons-1.4.1.tar.gz
mv asterisk-addons-1.4.1 asterisk-addons
4) Start installing the different packages by following theses commands, again, as root:
Should be run before building Asterisk (NOTE: You may need to reboot if you see errors about missing kernel sources.):
make menuselect (make sure your terminal window is set for at least 80×21 or the menu select command will give you an error)
Optional (I still did it either way): If you have Zaptel digital cards:
Must be installed after zaptel and (if you need it) libpri (I did this also):
make menuselect # for extra configuration
Optional. Should be run after installing Asterisk:
5) Now’s a good time to go ahead and backup some files. Backup both sip.conf and extensions.conf which are located in the /etc/asterisk folder by doing theses commands:
cp sip.conf sip.backup
cp extensions.conf extensions.backup
6) Now that everything is installed (unless you got errors, if so, go to linuxforums.org and post messages there with your issues [BEST LINUX FORUM EVER !]), now’s the time to start Asterisk for the first time by entenring this command:
asterisk -vvvvgc (this will start in debug mode which is good to find out about errors)
7) There are several extensions already preconfigured in the basic install, and here they are:
- extension : 1000 (first one to try !)
- extension : 1234 (is a extension. call vmail and enter this as the extention and password 4242)
- extension : 1235 (dial this and leave a message to yourself)
- extension : 1236 (another extension)
- Main Vmail : 8500
- External test for SIP call : 500
- echo test : 600
So make calls to these using an SIP phone like X-Lite or an SIP enabled desk phone like the Mitel 5212/5224. To make a call, you type the extension # followed by the @ sign and the IP address of the box running the Asterisk software. Make sure the firewall is disabled or set up to allow port 5060 inbound/outbound.
CONGRATULATIONS! You did it!
There also exists an Asterisk manager. To enable this, you need to edit the /etc/asterisk/manager.conf and uncomment the four lines below by removing the ; on:
;[mark] (this is the username to use in the astman) ;secret = mysecret (this is the password to use in astman) ;read = system,call,log,verbose,command,agent,user,config ;write = system,call.log,verbose,command,agent,user,config
so it would look like :
[mark] (this is the username to use in the astman) secret = mysecret (this is the password to use in astman) read = system,call,log,verbose,command,agent,user,config write = system,call.log,verbose,command,agent,user,config
Save the file.
You will also need to restart Asterisk. To do this, from the CLI prompt, type
Once restarted, on the CLI prompt of Asterisk, you can type manager show users which will tell you what manager users are configured, hence ours is mark with password mysecret.
Now bring up a new terminal window, su to root, then type:
username = mark
password = mysercet
Make a call to 1000 and you will see your call there.
You can also use the web version called AJAM:
AJAM is a new technology available in Asterisk 1.4 which allows web browsers or other HTTP enabled applications and web pages to directly access the Asterisk Manager Interface (AMI) via HTTP. Setting up your server to process AJAM involves a few steps:
Set up the Asterisk HTTP server:
1) Uncomment the line enabled=yes in /etc/asterisk/http.conf to enable Asterisk’s built-in micro HTTP server.
3) Adjust your bindaddr and bindport settings as appropriate for your desired accessibility or leave them as default.
4) Adjust your prefix if appropriate, which must be the beginning of any URI on the server to match. The default is asteriskand the rest of these instructions assume that value.
Allow Manager Access via HTTP
1) Make sure you have both enabled = yes and webenabled = yes set up in /etc/asterisk/manager.conf.
2) You may also use httptimeout to set a default timeout for HTTP connections.
3) Make sure you have a manager username/secret.
Once these configuration changes are complete you can reload or restart Asterisk and you should be able to point your web browser to specific URI’s which will allow you to access various web functions. A complete list can be found by typing show http at the Asterisk CLI.
This logs you into the manager interface’s “HTML” view. Once you’re logged in, Asterisk stores a cookie on your browser (valid for the length of httptimeout) which is used to connect to the same session.
Assuming you’ve already logged into manager, this URI will give you a “raw” manager output for the “status” command.
This will give you the same status view but represented as AJAX data, theoretically compatible with RICO (http://www.openrico.org).
If you have enabled static content support and have done a make install, Asterisk will serve up a demo page which presents a live, but very basic, “astman” like interface. You can login with your username/secret for manager and have a basic view of channels as well as transfer and hangup calls. It’s only tested in Firefox, but could probably be made to run in other browsers as well.
A sample library (astman.js) is included to help ease the creation of manager HTML interfaces.
Note that for the demo, there is no need for *any* external web server.
How To Install The Asterisk Web-Based Provisioning GUI
Not sure if you’re like me, but command line is all good, but GUI is a lot faster. Here is a list of procedures to install the Asterisk GUI on a running clean install of Asterisk.
- Concurrent Versions System (CVS)
- asterisk 1.4 – and all modules needed to compile and install asterisk 1.4
Go to your installation directory (for example /usr/src) and download the latest version of asterisk-gui. To do this just execute the command:
svn checkout http://svn.digium.com/svn/asterisk-gui/trunk asterisk-gui
By executing this command the sources of Asterisk GUI will be downloaded (see our sample output log svn.log) into ./asterisk-gui/ directory.
Configuring, Compiling And Installing
You first need to go into the src directory where you downloaded the files, ie: /usr/src/asterisk-gui, then you need to configure, so type
Now, you need to compile the sources by executing the command:
Then distribute the compiled code by executing the command
With this step you will finish the installation of the asterisk-gui (see our sample output log make_install.log).
It is recommended to back up your configuration files before you continue. To achieve this just copy /etc/asterisk under a different name:
cp -r /etc/asterisk /etc/asterisk.backup
It is recommended to run:
This command will modify some of your Asterisk configuration files. After that you’ll have to finish the configuration modification manually.
There are two files which you should modify that are located in /etc/asterisk/:
enabled = yes webenabled = yes
We will have to add a new user to manager.conf (we will use the mark user as previously set up when we installed Asterisk):
[mark] secret = mysecret read = system,call,log,verbose,command,agent,user,config write = system,call,log,verbose,command,agent,user,config
Now we need to make some modifications to the http.conf file:
enabled=yes enablestatic=yes bindaddr=0.0.0.0
(If you set the bindaddr to 127.0.0.1 (loopback) you will only be able to access the GUI from the server itself.)
After that run
in your asterisk-gui directory. This script will check if your GUI is correctly configured.
In order to load the asterisk-gui, Asterisk must restart/reload. You can reload your Asterisk server from your CLI console by executing the command
You can use the asterisk-gui from these addresses (127.0.0.1 is the loopback IP if you’re accessing the page from the server itself, or from a different system, type the Asterisk server IP address):