AsteriskFreePBXTestingWithSoftphones

Revision 18 as of 2007-10-12 18:07:30

Clear message

THIS IS DRAFT DOCUMENT

As such most of the information IS INCOMPLETE AND MAY LEAD TO A NON-WORKING SYSTEM. It is being written as I try the installation procedure and information I find elsewhere. -- FabiánRodríguez DateTime(2007-01-29T14:42:58Z)

Introduction

This is intended to provide a quick reference to How-Tos, documentation and other information relating to installing Asterisk on Ubuntu Dapper (LTS, 6.06.1). It focuses on this version even though Edgy is out, for stability and support reasons.

From the Ubuntu Dapper [http://packages.ubuntu.com/dapper/comm/asterisk asterisk package] page: Asterisk is an Open Source PBX and telephony toolkit. It is, in a sense, middleware between Internet and telephony channels on the bottom, and Internet and telephony applications at the top.

Asterisk can be used with Voice over IP (SIP, H.323, IAX) standards, or the Public Switched Telephone Network (PSTN) through Supported Hardware.

Asterisk + FreePBX on Ubuntu 6.06.1 LTS

These instructions are for installing Asterisk along with FreepBX, a web administration interface for Asterisk. IMPORTANT: using FreePBX may introduce security risks as it changes important settings in Apache's web server configuration, and requires file permissions that may make possible unauthorized execution of commands on your server. See this [[http://lists.alioth.debian.org/pipermail/pkg-voip-maintainers/2006-March/004228.html Discussion] on the pkg-voip maintainers mailing list.

Initial server install

  1. Using the Alternate install CD, install a "server" version of Ubuntu
  2. Login to the server
  3. Enable the Universe repository (using [https://help.ubuntu.com/community/Repositories/CommandLine command line] or the [https://help.ubuntu.com/community/Repositories/Ubuntu#head-5bbef89639d9a7d93fe38f6356dc17847d373096 graphical interface]).

  4. Update the packages list and upgrade your system: {{{$ sudo apt-get update

[...] $ sudo apt-get upgrade [...]}}}

Preparation for Asterisk install

Making sure you have remote access

You may want to install an SSH server to easily access the server from other computers on you local network. OpenSSH fits this task well and can be installed simply using apt-get install ssh. This will install OpenSSH server and generate the appropriate keys for remote access.

Setting up a static or dynamic DHCP address

Most configuration of hardware or software that will be interacting with your server will require its IP address information. It's highly unlikely you would want this IP address to change often. You should either setup a static IP address within your LAN for the server or configure your networking equipment (like a router) to assign the same IP address based on MAC address of the server's network interface.

Zaptel hardware support configuration

One interesting aspect of running an Asterisk server is the possibility to have incoming analog, regular phone lines handled by the system. One particular cheap way of doing these for experimentation purposes or in small systems is to use [http://www.voip-info.org/wiki/view/X100P+clone cheap hardware clones] that uses the [http://www.voip-info.org/wiki/view/Zaptel Zaptel] drivers, like the Wildcard interface cards X100P.

  1. Install the zaptel package, a set of utilities to confgure the Zapata kernel drivers : {{{$ sudo apt-get install zaptel

}}}

  1. Obtain the source code for such drivers:

    user@server:/home/user$ sudo apt-get install zaptel-source
    Password:
    Reading package lists... Done
    Building dependency tree... Done
    The following extra packages will be installed:
      binutils debconf-utils debhelper dpkg-dev gettext html2text intltool-debian make module-assistant
      patch po-debconf
    [...]
    Setting up module-assistant (0.10.2) ...
    Setting up zaptel-source (1.2.5-1) ...
  2. Verify that the zaptel archive containing the source code has been downloaded: {{{user@server:/home/user$

user@server:/home/user$ ls /usr/src modules zaptel.tar.bz2}}}

  1. Prepare the system for the drivers build: {{{user@server:/home/user$ sudo module-assistant prepare

Getting source for kernel version: 2.6.15-26-server apt-get install linux-headers-2.6.15-26-server Reading package lists... Done Building dependency tree... Done The following extra packages will be installed:

  • linux-headers-2.6.15-26

The following NEW packages will be installed:

  • linux-headers-2.6.15-26 linux-headers-2.6.15-26-server

0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded. Need to get 7761kB of archives. After unpacking 79.5MB of additional disk space will be used. Do you want to continue [Y/n]? [...] Setting up g++ (4.0.3-1) ...

Setting up build-essential (11.1) ...

Done! }}}

  1. Using module assistant, compile and build the zaptel drivers:

    user@server:/home/user$ sudo m-a -t build zaptel
    Extracting the package tarball, /usr/src/zaptel.tar.bz2, please wait...
    dh_testdir
    dh_testroot
    rm -f build-*-stamp configure-stamp
    # Add here commands to clean up after the build process.
    rm -rf modexamples
    /usr/bin/make clean
    make[1]: Entering directory `/usr/src/modules/zaptel'
    rm -f torisatool makefw tor2fw.h radfw.h
    [...]
  2. If the drivers build was successful, a new .deb archive suitable for their installation will be present in the /usr/src/ directory. This can be verified as follows:

    user@server:/home/user$ cd /usr/src
    user@server:/home/user$ ls *.deb
    zaptel-modules-2.6.15-26-server_1.2.5-1+2.6.15-26.47_i386.deb
  3. Now it's time to manually install the zapata kernel drivers:

    user@server:/home/user$ sudo dpkg -i zaptel-modules-2.6.15-26-server_1.2.5-1+2.6.15-26.47_i386.deb
    (Reading database ... 34841 files and directories currently installed.)
    Preparing to replace zaptel-modules-2.6.15-26-server 1:1.2.5-1+2.6.15-26.47 (using zaptel-modules-2.6.15-26-server_1.2.5-1+2.6.15-26.47_i386.deb) ...
    Unpacking replacement zaptel-modules-2.6.15-26-server ...
    Setting up zaptel-modules-2.6.15-26-server (1.2.5-1+2.6.15-26.47) ...
  4. Update the module dependencies:

    user@server:/home/user$ sudo depmod -a
  5. Now we need to verify that the installation was successful. To load the driver, we use modprobe with administrative rights - the name of the second driver may vary depending on your card:

    user@server:/home/user$ sudo modprobe zaptel
    user@server:/home/user$ sudo modprobe wcfxo

{{{Digium Card Module Map:

  • TE110P => wcte11xp TE205P/TE207P/TE210P/TE212P => wct2xxp TE405P/TE407P/TE410P/TE412P => wct4xxp TDM400P => wctdm TDM2400P => wctdm24xxp

}}}

On Feisty, this will fail - follow AsteriskOnUbuntuFeisty for a workaround.

  1. If the driver load was succesful, no output is received at the console. We can check this by looking at the kernel ring buffer which contains bootup messages but also new devices detected. This is done with the dmesg command. Lots of information will scroll, the last few links should look similar to this:

    [18101.810739] Zapata Telephony Interface Registered on major 196
    [18101.810754] Zaptel Version: 1.2.5 Echo Canceller: KB1
    [19918.574377] PCI: Found IRQ 11 for device 0000:00:0e.0
    [19918.659735] wcfxo: DAA mode is 'FCC'
    [19918.659752] Found a Wildcard FXO: Generic Clone
    [19927.892975] Registered tone zone 0 (United States / North America)
  2. Once we have confirmed this is succesful, we need to configure the system to load the drivers at boot time:

    user@server:/home/user$ sudo -s
    <enter your main user password>
    root@server:/home/user# echo 'zaptel' >>/etc/modules
    root@server:/home/user# echo 'wcfxo' >>/etc/modules
    exit
  3. Create the /etc/zaptel.conf file containing the following, depending on your card (see [http://www.voip-info.org/wiki-Asterisk+config+zaptel.conf the voip-info.org page about this file] for more info):

    loadzone=us
    defaultzone=us
    fxsks=1
  4. Using ztcfg -vv verify your card's operation:

    user@server:/home/user$  ztcfg -vv
    
    Zaptel Configuration
    ======================
    
    Channel map:
    
    Channel 01: FXS Kewlstart (Default) (Slaves: 01)
    
    1 channels configured.
    
    Changing signalling on channel 1 from Unused to FXS Kewlstart

Basic Asterisk install

  1. Install the Asterisk package: {{{$ sudo apt-get install asterisk

}}}

  1. Start asterisk by issuing this command: {{{ $ sudo /etc/init.d/asterisk start

}}}

  1. Change the /etc/default/asterisk file so the RUNASTERISK option is set to yes. This will make the Asterisk services start automatically upon starting your server.

FreePBX installation

FreePBX source code download

As of october 2006, FreePBX has not been packaged yet for inclusion in Debian / Ubuntu via the standard repositories. See this [http://lists.alioth.debian.org/pipermail/pkg-voip-maintainers/2006-March/004228.html discussion] for more information. As such, FreePBX needs to be downloaded and compiled directly from FreePBX's site.

To download FreePBX's source code, you will need to have a Subversion client install. Subversion is a version control system which allows many individuals (who may be distributed geographically) to collaborate on a set of files (typically source code). In Ubuntu the subversion package includes the Subversion client (svn), tools for creating a Subversion repository and tools to make a repository available over the network using a program like ssh.

  • Install the svn package: {{{$ sudo apt-get install svn

}}}

  • (or, on Gutsy): {{{$ sudo apt-get install subversion

}}}

Now, you must go to the /usr/src directory and get the source to freepbx using svn: {{{root@server:/home/user:# cd /usr/src/ root@server:/usr/src# svn co https://svn.sourceforge.net/svnroot/amportal/freepbx/branches/2.1 freepbx A freepbx/amp_conf A freepbx/amp_conf/astetc [... freePBX now downloads ...] Checked out revision 2574. root@server:/usr/src# cd freepbx/ }}}

Apache 2 installation

FreePBX requires Apache 2, as it is a web configuration interface for Asterisk.

  • Install the Apache 2 package: {{{$ sudo apt-get install apache2

}}}

Unfortunately, issues in Asterisk 1.2 require us to run the web server process as the same user as asterisk. In this situation, it's easier for us to run httpd as 'asterisk', rather than asterisk as 'httpd', as there's far less configuration that needs to be done. --Question: Could you just add Asterisk to the www-data group?--{{{ $ chown asterisk /var/lib/php4 }}}

Using nano (or your favorite editor, but nano is fine), you need to change User apache and Group apache to User asterisk and Group asterisk.{{{ [root@server ~]# nano +101 /etc/apache2/apache2.conf (Push Control-X to save when you've finished) }}}

You also want to change AllowOverride None to AllowOverride All {{{ [root@server ~]# nano +132 /etc/apache2/apache2.conf (Push Control-X to save when you've finished) }}}

And then restart apache2 to re-load its configuration.{{{ root@server:~# /etc/init.d/apache2 restart }}}

Set up MySQL for use by FreePBX

Before you can do anything to MySQL, you need to make sure it's running: {{{root@server:~# /etc/init.d/mysql start Starting MySQL database server: mysqld. root@server:~#}}}

Now, to configure the databases for FreePBX: {{{ root@server:/usr/src/freepbx# mysqladmin create asterisk root@server:/usr/src/freepbx# mysqladmin create asteriskcdrdb root@server:/usr/src/freepbx# mysql asterisk < SQL/newinstall.sql root@server:/usr/src/freepbx# mysql asteriskcdrdb < SQL/cdr_mysql_table.sql }}}

They also need to be secured, so that not just anyone can access them. freePBX will prompt you for a database password when you do the install. You need to pick that now. We'll assume that you've picked 'asteriskuser' and 'amp109' - you probably shouldn't use these, as they are well known passwords for Asterisk@Home builds. If anyone's trying to attack your machine, they will try this. {{{root@server:/usr/src/freepbx# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 to server version: 5.0.22-Debian_0ubuntu6.06.2-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY 'amp109'; (This is the first username and password asked for below) Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY 'amp109'; Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)

mysql> \q Bye root@server:/usr/src/freepbx# }}}

Now, after all of this, you need to pick a root 'mysql' password. For this, we'll pretend it's 's33kret'. If you need to do anything else with mysql, you'll need to provide this password. root@server:/usr/src/freepbx# mysqladmin -u root password 's33kret'

Alternative Method using Xorcom Sources

Sorry, this fragments the wiki article, but I had to throw this up there. You made still need Zaptel stuff if you have PCI hardware, but this will get you a basic Asterisk+FreePBX really quick. Xorcom.com has already packaged Asterisk and FreePBX for Debian, and they are helping FreePBX.org with Debian packages that don't violate Debian's packaging rules. Once they're in the Debian repos, we'll have them in the Universe or Multiverse, but for now we can get the ones that Xorcom hosts that are in violation of Debian's rules.

add the repository

 $ sudo nano /etc/apt/sources.list

add the lines

 deb http://updates.xorcom.com/astribank/debian/ etch main
 deb-src http://updates.xorcom.com/astribank/debian/ etch main

Refresh

 $ sudo aptitude update

Install the FreePBX dummy package. There are a few to choose from. Options are freepbx-apache-mysql, freepbx-apache2-mysql, freepbx-apache2-mysql-php5, freepbx-mathopd-mysql, freepbx-mathopd-sqlite. I'm running Feisty Beta, so I chose the php5 package. !!Any one of these packages is required before freepbx-admin is installed!!

 $ sudo aptitude install freepbx-apache2-mysql-php5

Install Freepbx-admin

 $ sudo aptitude install freepbx-admin

Edit the asterisk config file. Set "RUNASTERISK=yes"

 $ sudo nano /etc/default/asterisk

Start Asterisk and Restart Apache2

 $ sudo /etc/init.d/asterisk start
 $ sudo /etc/init.d/apache2 restart

You can now log into FreePBX to administer and configure Asterisk. Access http://localhost/freepbx Log in using User: Admin, Password: Admin

If you get an error about mysql database not configured,[https://wiki.ubuntu.com/AsteriskOnUbuntu#head-81dfdf8ae1441ad138ead73da60f9433f897d542 setup the mysql database]

If you get an error "Cannot connect to Asterisk Manager with admin," you may have to create/edit the Asterisk Manager's admin user:

 $ sudo nano /etc/amportal.conf

This is the conf file for freepbx. Find and set (you should use different values for security)

 # AMPMGRUSER: the user to access the Asterisk manager interface
 AMPMGRUSER=admin

 # AMPMGRPASS: the password for AMPMGRUSER
 AMPMGRPASS=secret

Set the same with Asterisk Manager:

 $ sudo nano /etc/asterisk/manager.conf 

Note the Username is in [], so for AMPMGRUSER=admin we set [admin].

 [admin]
 secret = secret
 read = system,call,log,verbose,command,agent,config
 write = system,call,log,verbose,command,agent,config
 displayconnects= yes

NOTE: THIS MAY NOT BE SECURED. PLEASE SECURE THIS BEFORE PUTTING YOUR BOX ON THE INTERNET. It would probably be wise to ask on the Xorcom.com mailing list, setup iptables, or something. I'm not sure what security settings are defaults in these packages/how they differ from first install method in this wiki.

References