Asterisk without Tricks
From 2l2oWiki
Contents |
Background
If you are like a lot of new Asterisk users, you cut your Asterisk teeth on a packaged ISO PBX build. Unfortunately, corporate sponsorship has led to either bloated package inclusion or anonymous data collection in many of these packaged PBX's. This guide will show you how to build an Asterisk + FreePBX box based on CentOS and without all the bloat.
Away We Go
1. Install CentOS, enabling the following packages:
- DNS Name Server
- Web Server
- Mail Server
- MySQL Database
- Development Tools
yum install nano
reboot
2. Edit Network settings:
nano /etc/sysconfig/network
HOSTNAME=internal.hostname.DOMAIN.com (Set your internal hostname name here)
Ctrl-X to save, 'Y' to confirm
nano /etc/sysconfig/network-scripts/ifcfg-eth0
IPADDDR=192.168.1.20
NETMASK=255.255.255.0
NETWORK=192.168.1.0
Ctrl-X to save, 'Y' to confirm
yum -y install bind
echo "options {" >> /var/named/chroot/etc/named.conf
echo " directory \"/var/named\";" >> /var/named/chroot/etc/named.conf
echo " dump-file \"/var/named/data/cache_dump.db\";" >> /var/named/chroot/etc/named.conf
echo " statistics-file \"/var/named/data/named_stats.txt\";" >> /var/named/chroot/etc/named.conf
echo "};" >> /var/named/chroot/etc/named.conf
echo "include \"/etc/rndc.key\";" >> /var/named/chroot/etc/named.conf
service named start
chkconfig named on
nano /etc/resolv.conf
search internal.DOMAIN.com (Set your internal domain name here)
nameserver 192.168.1.5
nameserver 127.0.0.1
nano /etc/hosts
127.0.0.1 internal.hostname.DOMAIN.com (Set your internal hostname name here)
127.0.0.1 asterisk1.local
127.0.0.1 localhost
Ctrl-X to save, 'Y' to confirm
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -F
iptables -X
/etc/init.d/iptables save
service network restart
3. Update:
yum -y update
4. Disable Selinux:
nano /boot/grub/grub.conf
add selinux=0 to the end of both lines that begin with "kernel"
Ctrl-X to save, 'Y' to confirm
reboot
5. Install dependencies and extra packages:
yum install audiofile-devel bluez-utils bluez-gnome bluez-libs bluez-libs-devel bzip2 e2fsprogs-devel gnutls-devel keyutils-libs-devel krb5-devel libgcrypt-devel libgpg-error-devel libogg libogg-devel libsepol-devel libtiff-devel libvorbis libvorbis-devel libxml2-devel mysql-devel ncurses-devel openssl-devel perl-DateManip php-gd php-mysql php-pdo php-pear php-pear-DB wget zlib-devel
cd /usr/src
wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
tar zxvf lame-3.97.tar.gz
cd lame-3.97
./configure
make
make install
6. Install Asterisk and FreePBX:
cd /usr/src
wget http://downloads.digium.com/pub/asterisk/asterisk-1.4-current.tar.gz
wget http://downloads.digium.com/pub/asterisk/asterisk-addons-1.4-current.tar.gz
wget http://downloads.digium.com/pub/zaptel/zaptel-1.4-current.tar.gz
wget http://downloads.digium.com/pub/libpri/libpri-1.4-current.tar.gz
wget http://mirror.freepbx.org/freepbx-2.4.0.tar.gz
tar zxvf asterisk-1.4-current.tar.gz
tar zxvf asterisk-addons-1.4-current.tar.gz
tar zxvf zaptel-1.4-current.tar.gz
tar zxvf libpri-1.4-current.tar.gz
tar zxvf freepbx-2.4.0.tar.gz
cd /usr/src/zaptel-1.4-current
./configure
Make && make install && make config
/sbin/ztcfg
echo "/sbin/ztcfg" >> /etc/rc.d/rc.local
cd /usr/src/libpri-1.4-current
make && make install
cd /usr/src/asterisk-1.4-current
useradd -c "Asterisk PBX" -d /var/lib/asterisk asterisk
mkdir /var/run/asterisk
mkdir /var/log/asterisk
chown -R asterisk:asterisk /var/run/asterisk
chown -R asterisk:asterisk /var/log/asterisk
chown -R asterisk:asterisk /var/lib/php/session/
./configure
make && make install
cd /usr/src/asterisk-addons
./configure
make && make install
/etc/init.d/mysqld start
cd /usr/src/freepbx-2.4.0
mysqladmin create asterisk
mysqladmin create asteriskcdrdb
mysql asterisk < SQL/newinstall.sql
mysql asteriskcdrdb < SQL/cdr_mysql_table.sql
mysql
GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY 'SOMEPASSWORD';
GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY 'SOMEPASSWORD';
flush privileges;
\q
mysqladmin -u root password 'SOMEPASSWORD'
nano +231 /etc/httpd/conf/httpd.conf
Change User apache and Group apache to User asterisk and Group asterisk.
Ctrl-X to save, 'Y' to confirm
nano +327 /etc/httpd/conf/httpd.conf
Change AllowOverride None to AllowOverride All
Ctrl-X to save, 'Y' to confirm
service httpd restart
chkconfig httpd on
chkconfig mysqld on
./start_asterisk start
./install_amp --username=asteriskuser --password=MYSQLDBPASSWORD --asteriskuser=admin --asteriskpass=SOMEPASSWORD
Approve the first 6 options if the passwords you entered above are correct, otherwise, change as needed.
Press the 'space bar' once and hit enter for the IP Address
Select a password for the Flash Operator Panel
Select [extensions] or [deviceanduser] mode
Approve the last option
echo "/usr/local/sbin/amportal start" >> /etc/rc.local
Open browser to http://ipaddressofpbx/admin
Click red bar in FreePBX
7. Fix ARI password:
nano -w /var/www/html/recordings/includes/main.conf.php
$ari_admin_password = "SOMEPASSWORD";
Ctrl-X to save, 'Y' to confirm
8. Configure Sendmail:
nano /etc/mail/sendmail.mc
define(`SMART_HOST', `relay.DOMAIN.com)dnl
MASQUERADE_AS(`pbx.DOMAIN.com')dnl
FEATURE(`masquerade_envelope')dnl
Ctrl-X to save, 'Y' to confirm
make -C /etc/mail
9. Edit sip_nat.conf for proper NAT:
nano /etc/asterisk/sip_nat.conf
localnet=192.168.1.0/255.255.255.0
externhost=pbx.DOMAIN.com (Set your external hostname name here)
externrefresh=10
fromdomain=DOMAIN.com (Set your external domain name here)
nat=yes
qualify=yes
canreinvite=no
Ctrl-X to save, 'Y' to confirm
10. Add extra codecs to config:
nano /etc/asterisk/sip_custom.conf
allow=gsm
allow=h261
allow=h263
allow=h263p
videosupport=yes
Ctrl-X to save, 'Y' to confirm
nano /etc/asterisk/iax_custom.conf
allow=gsm
allow=h261
allow=h263
allow=h263p
videosupport=yes
Ctrl-X to save, 'Y' to confirm
..and if you have access to them:
allow=g723.1
allow=g729
asterisk -rx reload
11. Edit voicemail config:
nano /etc/amportal.conf
If the web interface on your PBX will be accessible on the internet:
AMPWEBADDRESS=pbx.DOMAIN.com (Set your external hostname name here)
If the web interface on your PBX will be accessible only on your internal network:
AMPWEBADDRESS=internal.hostname.DOMAIN.com (Set your internal hostname name here)
Ctrl-X to save, 'Y' to confirm
or if your users will NOT have access to the web interface:
nano /etc/asterisk/vm_email.inc
remove "Visit http://AMPWEBADDRESS/cgi-bin/vmail.cgi?action=login&mailbox=${VM_MAILBOX} to check your voicemail with a web browser.\n"
Ctrl-X to save, 'Y' to confirm
nano /etc/asterisk/vm_general.inc
serveremail=pbx@DOMAIN.com ; Who the e-mail notification should appear to come from
fromstring=DOMAIN PBX ; Real name of email sender
Ctrl-X to save, 'Y' to confirm
12. Fix MOH directory:
mv /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
13. Install Flite and Asterisk-Perl:
cd /usr/src
wget http://asterisk.gnuinter.net/files/asterisk-perl-0.10.tar.gz
tar zxvf asterisk-perl-0.10.tar.gz
cd asterisk-perl-0.10.tar.gz
perl Makefile.PL
make all
make install
cd /usr/src
wget http://dialogpalette.sourceforge.net/extras/flite-1.3-sharedlibs.patch
wget http://dialogpalette.sourceforge.net/extras/flite-1.3-alsa_support.patch
wget http://www.speech.cs.cmu.edu/flite/packed/flite-1.3/flite-1.3-release.tar.gz
wget asterisk-flite-0.5.tar.gz
tar zxvf flite-1.3-release.tar.gz
rm -f flite-1.3-release.tar.gz
cd /usr/src/flite-1.3-release
patch -p1 < ../flite-1.3-sharedlibs.patch
patch -p1 < ../flite-1.3-alsa_support.patch
./configure --enable-shared
make
make install
cd /usr/src
tar zxvf asterisk-flite-0.5.tar.gz
rm -f asterisk-flite-0.5.tar.gz
mv asterisk-flite-0.5 flite-1.3-release/
cd /usr/src/flite-1.3-release/asterisk-flite-0.5
make install
echo "include /usr/local/lib" >> /etc/ld.so.conf
ldconfig
asterisk -rx reload
14. Install ConfControl:
cd /var/www/html
wget http://www.2l2o.com/asterisk/ConfControl1.0.tar.gz
tar zxvf ConfControl1.0.tar.gz
rm ConfControl1.0.tar.gz
Open browser to http://ipaddressofpbx
Optional Packages
AstAssistant:
If you are looking for a Heads Up Display type application, AstAssistant is all that and more. It easily replaces other Heads Up Display type applications and uses the actual Asterisk Manager versus an additional client/server service. There's nothing "lite" about it, and it's completely free!
Changelog
Version 1.0: Original Version based on CentOS 5.1
Version 1.1: Updated for CentOS 5.2
