So I recently have had the opportunity to set up another PBX running asterisk – and some things have changed since the last time I’ve set one up. I’ve successfully got the system online and running, and I thought I’d post the steps to get one of these puppys built from scratch. First I’d like to mention that I highly recommend that you NOT use a canned asterisk solution such as trixbox or asteriskNOW – as those are based on CentOS and CentOS/RHEL have really crappy driver support. I went with a fresh minimal Ubuntu install (should also work with Debian Etch), compiled the packages from scratch (no apt asterisk / zaptel packages), and it worked great. Note that this will also run the FreePBX gui for management. Many thanks to undertoe for his guide – a lot of this is based on his guide and cleaned up a bit.
So you’ve got your Ubuntu minimal up and running. Here we go:
$ sudo su
(work as superuser for this session – this is generally considered a bad practice, but I’m lazy)
$ apt-get install cvs build-essential automake autoconf bison flex libtool libncurses5-dev libssl-dev php5 php5-cli php5-curl php5-gd php5-mysql mysql-server php-pear php-db curl sox apache2 subversion libssl-dev libmysqlclient15-dev
(this will install the needed packages for php/apache/etc. make sure you note the root password that you set for MYSQL, it will ask you during the install)
$ uname -a
(this will give you your kernel version – note it for the next step)
$ apt-get install linux-headers-2.6.24-19-server
(2.6.24-19-server comes from the uname-a output)
$ ln -s /usr/src/linux-headers-2.6.8.1-5-686-smp /usr/src/linux-2.6
(link the headers)
$ cd /usr/src/
$ wget http://downloads.digium.com/pub/zaptel/zaptel-1.4-current.tar.gz
$ tar -zxvf zaptel-1.4-current.tar.gz
$ cd zaptel-1.4.12.1
$ ./configure
$ make clean
$ make
$ make install
$ make config
(download the zaptel driver, compile, install, configure)
$ /etc/init.d/zaptel start
$ update-rc.d zaptel defaults 20 80
(start up zaptel and update rc.d)
To check to see if zaptel is running do a cat /proc/zaptel/* – you should see an output like this:
Span 1: WCTDM/0 “Wildcard TDM410P Board 1″
IRQ misses: 0
1 WCTDM/0/0 FXSKS (In use)
2 WCTDM/0/1 FXSKS (In use)
3 WCTDM/0/2 FXSKS (In use)
4 WCTDM/0/3 FXSKS (In use)
$ groupadd asterisk
$ useradd -c “asterisk PBX” -d /var/lib/asterisk -g asterisk asterisk
$ mkdir /var/run/asterisk
$ chown asterisk:asterisk /var/run/asterisk/
$ cd /usr/src/
$ wget http://downloads.digium.com/pub/asterisk/releases/asterisk-1.4.22.tar.gz
$ tar -zxvf asterisk-1.4.22.tar.gz
$ cd asterisk-1.4.22
$ make clean
$ ./configure
$ make
$ make install
$ make samples
(configure directories, permissions, download asterisk source, compile and install)
$ cd ..
$ wget http://downloads.digium.com/pub/asterisk/asterisk-addons-1.4.7.tar.gz
$ tar -zxvf asterisk-addons-1.4.7.tar.gz
$ asterisk-addons-1.4.7
$ perl -p -i.bak -e ’s/CFLAGS.*D_GNU_SOURCE/CFLAGS+=-D_GNU_SOURCE\nCFLAGS+=-DMYSQL_LOGUNIQUEID/’ Makefile
$ ./configure
$ make clean
$ make
$ make install
(download, compile, and install asterisk addons)
$ cd ..
$ mkdir asterisk-sounds
$ asterisk-sounds
$ wget http://downloads.digium.com/pub/telephony/sounds/asterisk-core-sounds-en-wav-current.tar.gz
$ wget http://downloads.digium.com/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz
$ wget http://downloads.digium.com/pub/telephony/sounds/asterisk-moh-freeplay-wav.tar.gz
$ tar -zxvf asterisk-core-sounds-en-wav-current.tar.gz
$ tar -zxvf asterisk-extra-sounds-en-wav-current.tar.gz
$ tar -zxvf asterisk-moh-freeplay-wav.tar.gz
$ cp -rf * /var/lib/asterisk/sounds/
$ ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
(download sound packages, extract, copy them to the asterisk sounds directory, and create a symlink for FreePBX music on hold)
$ chown asterisk:asterisk /etc/asterisk -R
$ chown asterisk:asterisk /var/lib/asterisk -R
$ chown asterisk:asterisk /var/log/asterisk -R
$ chown asterisk:asterisk /var/spool/asterisk/ -R
(set permissions for asterisk)
$ nano /etc/asterisk/asterisk.conf
(open asterisk.conf for editing)
Look for “astrundir” and change to /var/run/asterisk Save and quit when done.
$ cd /usr/src/
$ wget http://mirror.freepbx.org/freepbx-2.5.0.tar.gz
$ tar -zxvf freepbx-2.5.0.tar.gz
$ cd freepbx-2.5.0
$ mysql_install_db
$ mysqladmin u root password ‘<your MYSQL root password>’
$ mysqladmin create asteriskcdrdb -p
$ mysqladmin create asterisk -p
$ mysql –user=root –password=<your MYSQL root password> asterisk < ./SQL/newinstall.sql
$ mysql –user=root –password=<your MYSQL root password> asteriskcdrdb < ./SQL/cdr_mysql_table.sql
(Download FreePBX, and set up the MYSQL databases asterisk and asteriskcdrdb)
$ mysql –user root -p
$ GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY ‘amp109′;
<enter>
$ GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY ‘amp109′;
<enter>
$ quit
<enter>
(Set up appropriate MYSQL privileges)
$ nano /etc/apache/envvars
change “export APACHE_RUN_USER=www-data & export APACHE_RUN_GROUP=www-data”
to “export APACHE_RUN_USER=asterisk & export APACHE_RUN_GROUP=asterisk”
$ nano /etc/apache2/sites-enabled/000-default
change “AllowOveride None” to “AllowOverid All” under both /var/www and /var/www/
(Sets up apache for FreePBX)
$ nano /etc/php5/apache2/php.ini
change: upload_max_filesize to upload_max_filesize = 20M
$ nano /etc/php5/cli/php.ini
change: upload_max_filesize to upload_max_filesize = 20M
Set permissions on /var/lib/php5
$ chown asterisk:asterisk /var/lib/php5 -R
Set permissions on /var/www
$ chown asterisk:asterisk /var/www -R
Restart Apache
$ /etc/init.d/apache2 restart
Test by entering http://<pbx-ip-addresss>/ in a browser – you should get “It Works!” or a similar message letting you know apache is working.
$ cd /usr/src/freepbx-2.5.0
$ sudo ln -sf /bin/bash /bin/sh
$ sudo ./start_asterisk start
$ sudo ./install_amp
Accept the default on all questions except for:
Enter the path to use for your AMP web root: /var/www
IP address: <pbx-ip-addresss>
(Install FreePBX and start it up)
Now point your browser to http://<server-ip-addresss>/admin/ and click on the orange reload config banner at the top of the page. Yay! You should now have a working asterisk/FreePBX box.
To have it load on boot:
$ nano /etc/init.d/asterisk
Paste the following:
—————————————————————————-
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Asterisk"
NAME=amportal
DAEMON=/usr/local/sbin/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
test -x $DAEMON || exit 0
d_start() {
amportal start
}
d_stop() {
amportal stop
}
d_reload() {
amportal restart
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
restart|force-reload)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 10
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
exit 0
—————————————————————————-
Save the file and run:
$ chmod 755 /etc/init.d/asterisk
$ update-rc.d asterisk defaults 90 10