GIT – :
Asterisk is often referred to as “the open source PBX” and it’s true that you can use Asterisk to build a PBX, in fact, we’ve done that work for you with our line of turnkey Switchvox solutions, but a PBX is only one of many applications you can build with Asterisk. The limits of Asterisk are the limits of your imagination. Here we have outlined a number of the most common solutions built on Asterisk. We invite you to explore the power of Asterisk and to see what you can build. Click here for more information.http://www.asterisk.org/applications

This guide ” Asterisk with Freepbx” on / .

Freepbx:
FreePBX is an easy to use GUI (graphical user interface) that controls and manages Asterisk, the world’s most popular open source telephony engine software. Click here for more information. http://www.freepbx.org

Install required softwares;

apt-get update
apt-get upgrade
apt-get install -server build-essential -headers-`uname -r` openssh-server bison flex apache2 php5 php5-curl php5-cli php5-mysql php-pear php-db php5-gd curl sox libncurses5-dev libssl-dev libmysqlclient15-dev mpg123 libxml2-dev

Download Asterisk Software

cd /usr/src
wget http://downloads.digium.com/pub/asterisk/asterisk-1.8-current.tar.gz
tar -zxvf asterisk-1.8-current.tar.gz
cd asterisk-1.8.11.0/

Run following commands

./configure
make install

Add user and group

adduser asterisk –disabled-password –no-create-home –gecos “asterisk PBX user”
adduser www-data asterisk
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i ‘s/^\(User\|Group\).*/\1 asterisk/’ /etc/apache2/apache2.conf

vi /usr/sbin/safe_asterisk

Change the following line

1.#!/bin/sh

to

1.#!/bin/bash

This time for create the script that will manage the asterisk service.

cd /etc/init.d/
create a file
touch asterisk
vi asterisk

Paste this script

#!/bin/sh
#
# asterisk    start the asterisk PBX
# (c) Mark Purcell <msp@debian.org>
# (c) Tzafrir Cohen <tzafrir.cohen@xorcom.com>
# (c) Faidon Liambotis <paravoid@debian.org>
#
#   This package is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
### BEGIN INIT INFO
# Provides:          asterisk
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Should-Start:      dahdi mysql postgresql
# Should-Stop:       mysql postgresql
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Asterisk PBX
# Description:       Controls the Asterisk PBX
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=asterisk
USER=$NAME
GROUP=$USER
DAEMON=/usr/sbin/$NAME
CANARY=/usr/sbin/astcanary
DESC=”Asterisk PBX”
PIDFILE=”/var/run/asterisk/asterisk.pid”
ASTSAFE_PIDFILE=”/var/run/asterisk/asterisk_safe.pid”
UMASK=007 # by default
#MAXFILES=1024 # (the system default)

. /lib/lsb/init-functions

# by default: use real-time priority
PARAMS=””
CHDIR_PARM=””
AST_REALTIME=”yes”
RUNASTERISK=”yes”
AST_DUMPCORE=”no”
AST_DUMPCORE_DIR=”/var/spool/asterisk” # only used if AST_DUMPCORE != no
# core_pattern. See: http://lxr.linux.no/source/Documentation/sysctl/kernel.txt
#CORE_PATTERN=
if [ -r /etc/default/$NAME ]; then . /etc/default/$NAME; fi

if [ “$RUNASTERISK” != “yes” ];then
echo “Asterisk not yet configured. Edit /etc/default/asterisk first.”
exit 0
fi

if [ “$AST_REALTIME” != “no” ]
then
PARAMS=”$PARAMS -p”
fi

if [ “$AST_DUMPCORE” != “no” ]
then
PARAMS=”$PARAMS -g”
if [ “$CORE_PATTERN” != ” ]
then
echo “$CORE_PATTERN” >/proc/sys/kernel/core_pattern
fi
if [ -d “$AST_DUMPCORE_DIR” ]
then
CHDIR_PARM=”–chdir $AST_DUMPCORE_DIR”
fi
fi

if [ “x$USER” = “x” ]
then
echo “Error: empty USER name”
exit 1
fi
if [ `id -u “$USER”` = 0 ]
then
echo “Starting as not supported.”
exit 1
fi
PARAMS=”$PARAMS -U $USER”

if [ “x$AST_DEBUG_PARAMS” = x ]
then
AST_DEBUG_PARAMS=-cvvvvvddddd
fi
if [ “$RUNASTSAFE” = “yes” ];then
# The value of WRAPPER_DAEMON in can be set in /etc/default/asterisk
WRAPPER_DAEMON=${WRAPPER_DAEMON:-/usr/sbin/safe_asterisk}
REALDAEMON=”$WRAPPER_DAEMON”
else
REALDAEMON=”$DAEMON”
fi

test -x $DAEMON || exit 0

for dir in /var/run/asterisk /var/log/asterisk /var/log/asterisk/cdr-csv /var/log/asterisk/cdr-custom; do
[ -d $dir ] || install -d -o $USER -g $GROUP $dir
done

#Make the device belong to the right user
if [ -e /dev/dahdi ];then
chown $USER:$GROUP /dev/dahdi/*
fi

set -e

if [ “$UMASK” != ” ]
then
umask $UMASK
fi

# allow changing the per-process open files limit:
if [ “$MAXFILES” != ” ]
then
ulimit -n $MAXFILES
fi

status() {
status_of_proc “$DAEMON” “$DESC” && return 0 || return $?
}

asterisk_rx() {
if ! status >/dev/null; then return 0; fi

# if $HOME is set, asterisk -rx writes a .asterisk_history there
(
unset HOME
$DAEMON -rx “$1″
)
}

case “$1″ in
debug)
# we add too many special parameters that I don’t want to skip
# accidentally. I’m afraid that skipping -U once may cause
# confusing results. I also want to maintain the user’s choice
# of -p
echo “Debugging $DESC: “
$DAEMON $PARAMS $AST_DEBUG_PARAMS
exit 0
;;
start)
if status > /dev/null; then
echo “$DESC is already running. Use restart.”
exit 0
fi
echo -n “Starting $DESC: “
if [ “$RUNASTSAFE” != “yes” ];then
# TODO: what if we cought the wrapper just as its asterisk
# was killed? status should check for the wrapper if we’re in
# “safe mode”
if status > /dev/null; then
echo “$DESC is already running. Use restart.”
exit 0
fi
start-stop-daemon –start –group $GROUP –pidfile “$PIDFILE” \
$CHDIR_PARM \
–exec $REALDAEMON — $PARAMS > /dev/null
else
start-stop-daemon –start –group $GROUP \
–background –make-pidfile \
$CHDIR_PARM –pidfile “$ASTSAFE_PIDFILE” \
–exec $REALDAEMON — $PARAMS
fi

echo “$NAME.”
;;
stop)
echo -n “Stopping $DESC: $NAME”
# Try gracefully.
# this may hang in some cases. Specifically, when the asterisk
# processes is stopped. No bother to worry about cleanup:
# it will either fail or die when asterisk dies.
( asterisk_rx ‘core stop now’ > /dev/null 2>&1 & ) &
if [ “$RUNASTSAFE” = “yes” ];then
start-stop-daemon –stop –quiet –oknodo \
–pidfile $ASTSAFE_PIDFILE
rm -f $ASTSAFE_PIDFILE
fi
# just making sure it’s really, really dead.
# KILL is necessary just in case there’s an asterisk -r in the background
start-stop-daemon –stop –quiet –oknodo –retry=0/2/TERM/2/KILL/5 –exec $DAEMON
start-stop-daemon –stop –quiet –oknodo –retry=0/2/TERM/2/KILL/5 –exec $CANARY
echo “.”
;;
reload)
echo “Reloading $DESC configuration files.”
asterisk_rx ‘module reload’
;;
logger-reload)
asterisk_rx ‘logger reload’
;;
extensions-reload|dialplan-reload)
echo “Reloading $DESC configuration files.”
asterisk_rx ‘dialplan reload’
;;
restart-convenient)
asterisk_rx ‘core restart when convenient’
;;
restart|force-reload)
$0 stop
$0 start
;;
status)
status
exit $?
;;
*)
N=/etc/init.d/$NAME
echo “Usage: $N {start|stop|restart|reload|status|debug|logger-reload|extensions-reload|restart-convenient|force-reload}” >&2
exit 1
;;
esac

exit 0

Different and simple way asterisk installation

use the following command

apt-get install asterisk asterisk-mysql asterisk-mp3 asterisk-sounds-extra

Its time to install freepbx

Download Freepbx

Select Directory

cd /usr/src

wget http://mirror.freepbx.org/freepbx-2.9.0.tar.gz

tar -zxvf freepbx-2.9.0.tar.gz
cd freepbx-2.9.0

Create database and import to SQL directory

mysqladmin create asterisk -u root -p
mysqladmin create asteriskcdrdb -u root -p
mysql -u root -p asterisk < SQL/newinstall.sql
mysql -u root -p asteriskcdrdb < SQL/cdr_mysql_table.sql

Open a mysql prompt with:

mysql -u root -p

Create mysql user and set all privileges
On the prompt run the following queries

GRANT ALL PRIVILEGES ON asterisk.* TO asterisk@localhost IDENTIFIED BY ‘yourpassword’;
GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO  asterisk@localhost IDENTIFIED BY ‘yourpassword’;
flush privileges;
quit;

Before running the install command, make a copy of /etc/asterisk/modules.conf.

cp /etc/asterisk/modules.conf ~/asterisk-modules.conf

We are ready to install freepbx

./install_amp

After the complete installation restore asterisk-modules.conf file, which you backed up before installing FreePBX:

cp ~/asterisk-modules.conf /etc/asterisk/modules.conf

Apache runs as www-data, Asterisk as user asterisk, so we have to change some permission to make both programs work together. First, add www-data to asterisk group

adduser www-data asterisk

Open the amportal.conf file set the apache permision

vi /etc/amportal.conf

Chang the following lines
AMPASTERISKUSER=www-data
AMPASTERISKGROUP=asterisk
AMPASTERISKWEBUSER=www-data
AMPASTERISKWEBGROUP=asterisk

Its time to start amportal

amportal start

Open your web browser and go to http://servername-ipaddress/admin and you will be greeted with FreePBX site.

Print Friendly

Comments

comments

Bài viết liên quan