Selasa, 06 November 2007

Asterisk with FreePBX on Ubuntu 7.04 Desktop

Why Asterisk 1.2?
I use FreePBX - It greatly simplifies the menial Asterisk config changes I make on a daily basis. Asterisk 1.4 doesn’t yet play nicely with FreePBX… So for now, we’re sticking with 1.2. The 1.2 branch is still updated, and is still supported by Digium, so it shouldn’t pose any problems for anyone.

Why Ubuntu 7.04 Desktop? Why not Server?
I plan to follow this guide up with a ChanSkype tutorial on Ubuntu. ChanSkype requires an X server to be running, so it was easier to let the Ubuntu devs set everything up for me than it was to set up an X server on the Server release.

Long story short - If you want the latest features and you’re not going to be using ChanSkype, go with Asterisk 1.4 and Ubuntu Server… But in that case, this guide isn’t for you. Now then, let’s get started… After the jump

Starting Point

It is assumed that at this point you have a clean install of Ubuntu 7.04 Desktop. If you have not gotten this far yet, please do so before continuing. Installing Ubuntu is beyond the scope of this document.

This document will walk through the process of installing Asterisk 1.2.18 and FreePBX 2.2.1. It is likely that both of these branches will be updated at some point. That being the case, it is recommended that the updated versions be used in place of the ones listed here. However, this guide cannot account for quirks in new versions, so try new releases with caution.

System Setup
Open up a terminal window (Applications -> Accessories -> Terminal).
Elevate yourself to the root user:
sudo su -

Type your password if prompted and hit the Enter key.
Install the necessary dependencies:
apt-get install build-essential php5 php5-cli php5-mysql mysql-server php-pear php-db openssh-server curl sox apache2 subversion libncurses5-dev libssl-dev linux-headers-`uname -r` libmysqlclient15-dev

Getting and Building Asterisk
Switch to the /usr/src directory:
cd /usr/src
Download Asterisk, Asterisk-Addons, Zaptel, LibPRI:
wget http://ftp.digium.com/pub/asterisk/asterisk-1.2.18.tar.gz
wget http://ftp.digium.com/pub/asterisk/asterisk-addons-1.2.6.tar.gz
wget ftp://ftp1.digium.com/pub/zaptel/zaptel-
wget ftp://ftp1.digium.com/pub/libpri/libpri-1.2.4.tar.gz
wget http://superb-east.dl.sourceforge.net/sourceforge/amportal/freepbx-2.2.1-withmodules.tar.gz
Extract the newly downloaded files:
tar zxf asterisk-1.2.18.tar.gz
tar zxf asterisk-addons-1.2.6.tar.gz
tar zxf libpri-1.2.4.tar.gz
tar zxf zaptel-
tar zxf freepbx-2.2.1-withmodules.tar.gz
Build LibPRI, Zaptel, Asterisk and Asterisk-Addons (this step will take several minutes as everything is compiled - older/slower machines could take upwards of half an hour):
cd libpri-1.2.4make installcd ../zaptel- install config
cd ../asterisk-1.2.18
make install
cd ../asterisk-addons-1.2.6
make install
Setup users, groups, folders and permissions:
addgroup asteriskuseradd -g asterisk -c "Asterisk PBX" -d /var/lib/asterisk asterisk
mkdir /var/run/asterisk
chown asterisk:asterisk /var/run/asterisk
chown -R asterisk /var/lib/php5

Setup the Apache2 Web Server
Force Apache2 to run as the asterisk user:
sed -i 's!^User www-data!User asterisk!' /etc/apache2/apache2.conf
sed -i 's!^Group www-data!Group asterisk!' /etc/apache2/apache2.conf
Allow override of earlier Apache directives:
nano +12 /etc/apache2/sites-enabled/000-default

Change the line your cursor is on from AllowOverride None to AllowOverride All. Press Ctrl+X, followed by Y, followed by Enter to save the file and exit.
Restart Apache web server:
/etc/init.d/apache2 restart

Setting Up the MySQL Database Server
Ensure the MySQL daemon is started:
/etc/init.d/mysql start
Create database tables:
mysqladmin create asteriskmysqladmin create asteriskcdrdb
Switch to the FreePBX directory:
cd /usr/src/freepbx-2.2.1
Setup table structures:
mysql asterisk < SQL/newinstall.sqlmysql asteriskcdrdb < SQL/cdr_mysql_table.sql
Setup access restrictions on the FreePBX database:
GRANT ALL PRIVILEGES ON asterisk.* TO user1@localhost IDENTIFIED BY 'pass1';

Replace user1 with a username of your choice and pass1 with a password of your choice. Make a note of both of these, as you will need them later during the FreePBX install.
GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO user1@localhost IDENTIFIED BY 'pass1';

Like above, replace user1 and pass1 with the same username and password that you used in the previous step.
flush privileges
Set a root password on your MySQL server. If you are ever performing maintenance on your MySQL server in the future, this is the login you will need to use:
mysqladmin -u root password 'pass2'

Replace pass2 with a password of your choosing.

Install FreePBX
Switch to the FreePBX directory:
cd /usr/src/freepbx-2.2.1
Run the FreePBX installer:
You will be prompted with several questions during installation:
Enter your USERNAME to connect to the ‘asterisk’ database
Enter the username you entered for user1, above.
Enter your PASSWORD to connect to the ‘asterisk’ database
Enter the password you entered for pass1, above.
Enter the hostname of the ‘asterisk’ database
Leave this as the default, locahost.
Enter a USERNAME to connect to the Asterisk Manager interface
Leave this as the default, admin.
Enter a PASSWORD to connect to the Asterisk Manager interface
Pick a secure password that FreePBX will use to communicate with the Asterisk management interface.
Enter the path to use for your AMP web root
Enter /var/www and push Enter.
Enter the IP ADDRESS or hostname used to access the AMP web-admin
Enter the IP address/hostname of your Ubuntu box. Depending on how you plan to access the server, this may be either the internal or the external IP/hostname.
Enter a PASSWORD to perform call transfers with the Flash Operator Panel
Pick a secure password. If you use the Flash Operator Panel to perform call bridges, this is the password you must give it when prompted.
Use simple Extensions [extensions] admin or separate Devices and Users [deviceanduser]
Most people will want to leave this at the default of extensions. This can always be changed later on if necessary.
Enter directory in which to store AMP executable scripts
Leave this at the default of /var/lib/asterisk/bin.
Enter directory in which to store super-user scripts
Leave this at the default of /usr/sbin.
Change ownership of amportal.conf:
chown asterisk:asterisk amportal.conf
Re-run the FreePBX installer now that it can access amportal.conf:
Force the safe_asterisk script to use BASH instead of DASH:
sed -i 's!^#!/bin/sh!#!/bin/bash!' /usr/sbin/safe_asterisk

Finishing Up
Ubuntu seems to have a problem understanding the ztdummy module. If you have no zaptel hardware (Digium, Sangoma, etc.), then you will need to run the following command:
sed -i 's!^noload => chan_oss.so!noload => chan_oss.sonnoload => chan_zap.so!' /etc/asterisk/modules.conf
Start the server:
amportal start
Add Asterisk/FreePBX start scripts to system boot:
sed -i 's!^exit 0!/usr/sbin/amportal start &nexit 0!' /etc/rc.local

That’s it! Your server is now accessible by accessing http://localhost/. The default username/password for FreePBX is admin/admin. Make sure you go to the “administrators” section (under Setup (top menu bar) -> Administrators (left menu bar)) and change the password ASAP. After that, install/activate all of the modules, and start configuring your system!

Tidak ada komentar: