UPDATE:Try this to fix the problems with mysql permissions. This was suggested by someone else. I have not tried it myself. "The 'astrundir' must be changed to /var/run/asterisk before installing FreePBX. Otherwise, the owner for /var/run/mysqld will be changed to asterisk and that causes mysqld to fail starting. Or you can just change permission of /var/run/mysqld to 777"
I have updated the how-to build asterisk with freepbx on debian sarge with a minimal install that was originally located atsquishychicken.com.
The total install is around 500MB (after deb archives are removed of course :) )... enjoy. Please let me know if there are any glaring errors that I have over looked.
Just a quick note before we get started.... there are a couple of things that I assume here. One is that you are familiar with your shell. Be sure that you don't just blindly cut and paste this into a window... look at the command and think about what they are doing. When you see cat > /some/file <<EOF make sure you cut to the next EOF...
#Install barebones Debian Sarge using the "linux26" command from the initial boot screen.
boot:linux26
# update all packages and make sure we are current
# update all packages and make sure we are current
apt-get update
apt-get upgrade
apt-get upgrade
# install and configure etherconf for static IP
# specify the hostname and assign a static ip for later
# specify the hostname and assign a static ip for later
apt-get install etherconf
#install sshd so that you can do the rest of the install remotely without the need for a mouse/kb/monitor. It is also handy for doing the cut and paste thing which Windows users know and love.
apt-get install ssh
# get needed software and dependencies
# get needed software and dependencies
apt-get install vim libasound2 libgsm1 libltdl3 libpq3 libspeex1 libsqlite0 libtonezone1 odbcinst1 unixodbc openssl libssl0.9.7 libssl-dev libreadline4 libreadline4-dev libeditline0 libeditline-dev libedit-dev libedit2 libncurses5 libncurses5-dev zlib1g-dev bison libnet-telnet-perl mime-construct libipc-signal-perl libmime-types-perl libproc-waitstat-perl subversion libipc-signal-perl libproc-waitstat-perl apache2 mysql-server php4 php4-cli php4-mysql php4-pear libapache2-mod-php4 php4-curl libmysqlclient14-dev libmysqlclient14 php4-gd make gcc g++ fxload
# don't forget the kernel headers
apt-get install kernel-headers-`uname -r`
apt-get install kernel-headers-`uname -r`
# get the latest asterisk from cvs
cd /usr/src
svn checkout http://svn.digium.com/svn/asterisk/branches/1.2 asterisk-1.2
svn checkout http://svn.digium.com/svn/zaptel/branches/1.2 zaptel-1.2
svn checkout http://svn.digium.com/svn/libpri/branches/1.2 libpri-1.2
svn checkout http://svn.digium.com/svn/asterisk-addons/branches/1.2 asterisk-addons-1.2
svn checkout http://svn.digium.com/svn/asterisk-sounds/trunk asterisk-sounds
cd /usr/src
svn checkout http://svn.digium.com/svn/asterisk/branches/1.2 asterisk-1.2
svn checkout http://svn.digium.com/svn/zaptel/branches/1.2 zaptel-1.2
svn checkout http://svn.digium.com/svn/libpri/branches/1.2 libpri-1.2
svn checkout http://svn.digium.com/svn/asterisk-addons/branches/1.2 asterisk-addons-1.2
svn checkout http://svn.digium.com/svn/asterisk-sounds/trunk asterisk-sounds
# build zaptel drivers for 2.6 kernel
cd zaptel-1.2
make clean; make linux26; make install
# if you need pri support
cd ../libpri-1.2
make clean; make install
cd zaptel-1.2
make clean; make linux26; make install
# if you need pri support
cd ../libpri-1.2
make clean; make install
#NOTE: In asterisk 1.2.x and above you no longer need the mpg123 player so the installation procedure has been removed from this document. You DO need to install the asterisk-addons package in order to use the built in MOH.
cd ../asterisk-1.2
make clean; make install
make clean; make install
# build asterisk addons with mysql patch to makefile
cd ../asterisk-addons-1.2
perl -p -i.bak -e 's/CFLAGS.*D_GNU_SOURCE/CFLAGS+=-D_GNU_SOURCE\nCFLAGS+=-DMYSQL_LOGUNIQUEID/' Makefile
make clean; make install
# build asterisk-sounds
cd ../asterisk-sounds
make clean; make install
# build asterisk-sounds
cd ../asterisk-sounds
make clean; make install
# install lame for mp3 resample
cd /usr/src
wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.96.1.tar.gz
tar -xvzf lame-3.96.1.tar.gz
cd lame-3.96.1
./configure --prefix=/usr --sysconfdir=/etc
make && make install
cd /usr/src
wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.96.1.tar.gz
tar -xvzf lame-3.96.1.tar.gz
cd lame-3.96.1
./configure --prefix=/usr --sysconfdir=/etc
make && make install
# use xorcoms handy zaptel toolset
cd /usr/src
wget http://rapid.sunsite.dk/rapid/pool/main/z/zaptel/zaptel_1.2.5-3_i386.deb
dpkg -i zaptel_1.2.5-3_i386.deb
cd /usr/src
wget http://rapid.sunsite.dk/rapid/pool/main/z/zaptel/zaptel_1.2.5-3_i386.deb
dpkg -i zaptel_1.2.5-3_i386.deb
# If it asks you whether to keep the existing package or install the new one
go with the default by hitting 'ENTER' or typing 'N'
# auto detect zaptel hardware
go with the default by hitting 'ENTER' or typing 'N'
# auto detect zaptel hardware
genzaptelconf -ds
# install asterisk perl
cd /usr/src
wget http://asterisk.gnuinter.net/files/asterisk-perl-0.08.tar.gz
tar zxf asterisk-perl-0.08.tar.gz
cd asterisk-perl-0.08
perl Makefile.PL
make install
cd /usr/src
wget http://asterisk.gnuinter.net/files/asterisk-perl-0.08.tar.gz
tar zxf asterisk-perl-0.08.tar.gz
cd asterisk-perl-0.08
perl Makefile.PL
make install
# get freepbx
cd /usr/src
wget http://ufpr.dl.sourceforge.net/sourceforge/amportal/freepbx-2.1.1.tar.gz
tar -xvzf freepbx-2.1.1.tar.gz
cd freepbx-2.1.1
# create the databases and tables
mysqladmin create asteriskcdrdb
mysql asteriskcdrdb < /usr/src/freepbx-2.1.1/SQL/cdr_mysql_table.sql
mysqladmin create asterisk
wget http://ufpr.dl.sourceforge.net/sourceforge/amportal/freepbx-2.1.1.tar.gz
tar -xvzf freepbx-2.1.1.tar.gz
cd freepbx-2.1.1
# create the databases and tables
mysqladmin create asteriskcdrdb
mysql asteriskcdrdb < /usr/src/freepbx-2.1.1/SQL/cdr_mysql_table.sql
mysqladmin create asterisk
mysql asterisk < /usr/src/freepbx-2.1.1/SQL/newinstall.sql
#grant access to asterisk user. The usernames and passwords here MUST be the same as those configured during the freepbx install. Freepbx defaults (username 'asteriskuser' and password 'amp109') are used here. If you change them here you MUST also change them to the same during the freepbx install.
echo "GRANT ALL ON asterisk.* to asteriskuser@localhost identified by 'amp109'" | mysql
echo "GRANT ALL ON asteriskcdrdb.* to asteriskuser@localhost identified by 'amp109'" | mysql
# add the asterisk user and group
groupadd asterisk
useradd -g asterisk -d /var/lib/asterisk -s /bin/bash asterisk
# make the directory for the virtual host and for recordings.
mkdir -p /var/www/`uname -n`/cgi-bin
mkdir -p /var/www/`uname -n`/htdocs
mkdir -p /var/lib/asterisk/sounds/custom
# build the default zapata.conf
cat > /etc/asterisk/zapata.conf << EOF
[channels]
language=en
language=en
context=from-pstn
signalling=fxs_ks
rxwink=300 ; Atlas seems to use long (250ms) winks
;
; Whether or not to do distinctive ring detection on FXO lines
;
;usedistinctiveringdetection=yes
usecallerid=yes
hidecallerid=no
callwaiting=yes
usecallingpres=yes
callwaitingcallerid=yes
threewaycalling=yes
transfer=yes
cancallforward=yes
callreturn=yes
echocancel=yes
echocancelwhenbridged=no
echotraining=800
rxgain=0.0
txgain=0.0
group=0
callgroup=1
pickupgroup=1
immediate=no
;faxdetect=both
relaxdtmf=yes
faxdetect=incoming
;faxdetect=outgoing
;faxdetect=no
; include zap extensions defined in AMP
#include zapata_additional.conf
#include zapata-channels.conf
EOF
[channels]
language=en
language=en
context=from-pstn
signalling=fxs_ks
rxwink=300 ; Atlas seems to use long (250ms) winks
;
; Whether or not to do distinctive ring detection on FXO lines
;
;usedistinctiveringdetection=yes
usecallerid=yes
hidecallerid=no
callwaiting=yes
usecallingpres=yes
callwaitingcallerid=yes
threewaycalling=yes
transfer=yes
cancallforward=yes
callreturn=yes
echocancel=yes
echocancelwhenbridged=no
echotraining=800
rxgain=0.0
txgain=0.0
group=0
callgroup=1
pickupgroup=1
immediate=no
;faxdetect=both
relaxdtmf=yes
faxdetect=incoming
;faxdetect=outgoing
;faxdetect=no
; include zap extensions defined in AMP
#include zapata_additional.conf
#include zapata-channels.conf
EOF
# don't forget the run directory
mkdir /var/run/asterisk
# Now install freepbx. During this install, it will ask for changes to the defaults. If you hit ENTER the default will be used. You MUST pay close attention to these defaults as they need to be changed to the defaults used earlier and in the next step after this one. There is nothing preventing you from using different usernames, passwords, and directories as long as they are the same in the freepbx setup as they are through out the rest of this document which I have/will point out.
uname -n
#Change the defaults during the install to the following. Substitute "uname -n" to whatever was returned when you typed in "uname -n" above:
#Enter the path to use for your AMP web root:[/var/www/"uname -n"/htdocs]
#Enter the path to use for your FOP web root:[/var/www/"uname -n"/htdocs/panel]
#Enter the path to your Apache cgi-bin:[/var/www/"uname -n"/cgi-bin]
#Enter the IP ADDRESS or hostname used to access the AMP web-admin:[xx.xx.xx.xx] The IP Address of your #Asterisk Machine
#Enter the path to use for your FOP web root:[/var/www/"uname -n"/htdocs/panel]
#Enter the path to your Apache cgi-bin:[/var/www/"uname -n"/cgi-bin]
#Enter the IP ADDRESS or hostname used to access the AMP web-admin:[xx.xx.xx.xx] The IP Address of your #Asterisk Machine
cd /usr/src/freepbx-2.1.1
./install_amp
# create the virtual host file with good defaults. These original defaults MUST have been changed manually during the automated freepbx install above.
cat > /etc/apache2/sites-available/pbx.conf << EOF
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName `uname -n`
DocumentRoot /var/www/`uname -n`/htdocs
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/`uname -n`/htdocs>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /var/www/`uname -n`
<Directory "/var/www/`uname -n`/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
EOF
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName `uname -n`
DocumentRoot /var/www/`uname -n`/htdocs
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/`uname -n`/htdocs>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /var/www/`uname -n`
<Directory "/var/www/`uname -n`/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
EOF
# make apache run as user asterisk and enable the virtual host
ln -s /etc/apache2/sites-available/pbx.conf /etc/apache2/sites-enabled
perl -p -i.bak -e 's/User www-data/User asterisk/' /etc/apache2/apache2.conf
perl -p -i.bak -e 's/Group www-data/Group asterisk/' /etc/apache2/apache2.conf
# make tweeks for php to allow for file uploads
perl -p -i.bak -e 's/upload_max_filesize.*$/upload_max_filesize = 20M/' /etc/php4/apache2/php.ini
perl -p -i.bak -e 's#AddType application/x-httpd-php-source .phps#AddType application/x-httpd-php-source .phps\nLimitRequestBody 20000000#' /etc/apache2/mods-available/php4.conf
# restart to get changes
/etc/init.d/apache2 restart
# change the security to database authentication. The username and password must be the same as those used during the freepbx install earlier in this document. The freepbx defaults (username=admin, password=amp111) are used
perl -p -i.bak -e 's/AUTHTYPE=none/AUTHTYPE=database/' /etc/amportal.conf
echo "insert into ampusers values ('admin','amp111','','','','*');" | mysql asterisk
# You will probably get an error/warning here. Something about "duplicate entry 'admin' for key 1". Just ignore it.
# install astmanproxy for astapi dialing
cd /usr/src/
svn checkout http://svncommunity.digium.com/svn/astmanproxy/tags/1.20
cd 1.20
make && make install
# modify /etc/asterisk/astmanproxy.conf and assign username/password
eg: host = localhost, 5038, proxy, 1234, on
# modify /etc/asterisk/manager_custom.conf to add the following
[proxy]
secret = 1234
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.255
read = system,call,log,verbose,command,agent,user
write = system,call,log,verbose,command,agent,user
[astapi]
secret = 1234
deny=0.0.0.0/0.0.0.0
permit=10.0.0.0/255.255.255.0
read = system,call,log,verbose,command,agent,user
write = system,call,log,verbose,command,agent,user
secret = 1234
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.255
read = system,call,log,verbose,command,agent,user
write = system,call,log,verbose,command,agent,user
[astapi]
secret = 1234
deny=0.0.0.0/0.0.0.0
permit=10.0.0.0/255.255.255.0
read = system,call,log,verbose,command,agent,user
write = system,call,log,verbose,command,agent,user
# build an rc.local startup script
echo '#!/bin/bash' > /etc/init.d/local
chmod +x /etc/init.d/local
update-rc.d local defaults 80
echo '/usr/local/sbin/astmanproxy' >> /etc/init.d/local
# change the user that astmanproxy runs as
perl -p -i -e 's/proc_user.*$/proc_user = asterisk/' /etc/asterisk/astmanproxy.conf
perl -p -i -e 's/proc_group.*$/proc_group = asterisk/' /etc/asterisk/astmanproxy.conf
# change permissions and start amp
amportal chown
amportal start
#If you don't have a zaptel card
modprobe ztdummy
#build a freepbx automatic start and stop script as last to start and first to stop. I know there is a way to do it with just one script but I haven't figured out how to modify the "skeleton" file included in init.d yet.
echo '#!/bin/bash' > /etc/init.d/amportal-start
chmod +x /etc/init.d/amportal-start
update-rc.d amportal-start start 99 2 3 4 5 .
# Add this line if you do NOT have a zaptel card
echo 'modprobe ztdummy' >> /etc/init.d/amportal-start
# Now complete the start script and add the stop script
echo '/usr/sbin/amportal start' >> /etc/init.d/amportal-start
echo '#!/bin/bash' > /etc/init.d/amportal-stop
chmod +x /etc/init.d/amportal-stop
update-rc.d amportal-stop stop 10 0 1 6 .
echo '/usr/sbin/amportal stop' >> /etc/init.d/amportal-stop
No comments:
Post a Comment