Installing The Asterisk PBX And The Asterisk Web-Based Provisioning GUI On Linux
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-184.108.40.206.tar.gz
ln -s zaptel-220.127.116.11 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 80x21 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 asterisk and 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.