Setting up Asterisk and FreePBX 2.3 in a Debian etch chroot
From PowerPC Kernel Archives
- bootstrap the Debian system:
export PBXDIR=/path/to/pbx-chroot-dir # this downloads the Debian base system and installs it in $PBXDIR; it will take awhile debootstrap stable $PBXDIR http://http.us.debian.org/debian cp /etc/resolv.conf $PBXDIR/etc/resolv.conf cp /etc/hosts $PBXDIR/etc/hosts cp /etc/hostname $PBXDIR/etc/hostname
- enter the chroot:
chroot $PBXDIR /usr/bin/env -i HOME=/root \
TERM=$TERM PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin \
/bin/bash --login
mount -t proc none /proc
- install Asterisk:
apt-get install asterisk asterisk-sounds-extra vim /etc/default/asterisk # and set RUNASTERISK=yes vim /etc/asterisk/manager.conf # and choose a new manager password
- if you want, modify the passwd files inside and outside the chroot to contain the same entry for the asterisk user (so the UIDs line up, at least). If you do this, be sure to run
find / -xdev -user 100 -print | xargs chown asteriskafterwards, to update the UID on the files owned by asterisk (substitute your old asterisk UID if it wasn't 100 for some reason). Alternatively, you could just hardlink the passwd file from outside the chroot before installing asterisk. Comments from someone more familiar with chroot user management welcome here. :)
- start Asterisk:
/etc/init.d/asterisk * install FreePBX dependencies (adapted from package list in INSTALL file) <pre> apt-get install libxml2 libxml2-dev libtiff4 libtiff4-dev toolame libmysqlclient15-dev mysql-client apache2 php4 libapache2-mod-php4 php-pear php-db php4-mysql php4-gd php4-curl openssl libssl-dev perl bison libncurses5-dev libaudiofile-dev curl sox
- if you run another Apache instance outside the chroot:
vim /etc/apache2/ports.conf # and set Listen to something other than 80 (the port you'll use to connect to FreePBX)
- increase upload file size limits:
vim /etc/php4/apache2/php.ini # set upload_max_filesize = 20M vim /etc/apache2/conf.d/php4.conf # add "LimitRequestBody 20000000" inside IfModule directive
- set Apache to run as the asterisk user:
vim /etc/apache2/apache2.conf # replace all instances of 'www-data' with 'asterisk' (User and Group settings)
- enable the Apache init script and start Apache
vim /etc/default/apache2 # and set NO_START=0 /etc/init.d/apache2 start
- download FreePBX:
cd wget http://mirror.freepbx.org/freepbx-2.3.1.tar.gz tar xzf freepbx-2.3.1.tar.gz cd freepbx-2.3.1
- Setup MySQL databases. I just use the MySQL instance I have installed outside the chroot. You can just as easily use an external MySQL server or install it inside the chroot if you want and adapt the following instructions for your setup. Enter your MySQL root pass when prompted (default on Debian is empty).
# specify -h 127.0.0.1 to force connections on TCP/IP, since we don't have access to the unix socket inside the chroot # none of these commands should generate output mysqladmin create asteriskcdrdb1 -h 127.0.0.1 -p mysql -h 127.0.0.1 -u root -p asteriskcdrdb1 < SQL/cdr_mysql_table.sql mysqladmin create asterisk1 -h 127.0.0.1 -p mysql -h 127.0.0.1 -u root -p asterisk1 < SQL/newinstall.sql
- Grant privileges to asteriskuser on the above databases by running
mysql -h 127.0.0.1 -u root -p mysqland executing the following statements. Be sure to specify a real password and keep track of it for later.
GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY '<somepass>'; GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost;
- Finally, install FreePBX. Most of the defaults will work fine. Enter the DB password chosen above. Be sure to specify a new manager password. Using the default HTML directory can modules that aren't aware of this setting (VoicePulse, e.g.). Replace any asterisk config files if asked (well, if you haven't made any changes).
./install_amp
- Enable FreePBX database authentication:
vim /etc/amportal.conf # and set AUTHTYPE=database (around line 57)
After doing this, navigate to Basic -> Administrators on the FreePBX admin page, and set a new password for the admin user. Then logout and login with your new password.
[edit]
Caveats
- Right after installing, when I navigated to the FreePBX admin, it reported that a 2.2 beta version was installed, not 2.3.1. I re-ran ./install_amp and that fixed it. No idea why this happened...
- None of my phones ever ring at the moment. When called, every ext just goes straight to voice mail, even if I have followme setup with a cell # (the cell never rings). Outbound calls to the PSTN work just fine. Inbound calls from the PSTN also go straight to VM.
