Building Asterisk 13 + FreePBX 13 on the SheevaPlug
In this tutorial you can read how to configure your very own open source PBX server on a SheevaPlug.
If you just purchased a new SheevaPlug, there are steps that you need to take to make it boot from an SD card.
Setting up a new SheevaPlug for the first time is outside the scope of this article, so please refer to this site instead.
Here are all of the files that you will need to get started. Copy them to a USB flash. Be sure to use the 3.4.19 version of Uboot.bin which is included in the archive. More helpful files for your Sheevaplug can be found at http://www.downloadsnewit.co.uk/CD-images/Sheeva_CD. This will allow you to connect to your Sheevaplug from within Windows. First install the Sheevaplug drivers from within Device Manager. Then install Putty and connect to your Sheevaplug at a baudrate of 115200. Use the following commands to install Debian on your Sheevaplug:
usb start
fatload usb 0:1 0x00800000 /uImage
fatload usb 0:1 0x01100000 /uInitrd
setenv bootargs console=ttyS0,115200n8 base-installer/initramfs-tools/driver-policy=most
bootm 0x00800000 0x01100000
Once installed, you will need to access your USB flash drive. The commands to access them from within Debian are:
mkdir /mnt/usbflash
mount /dev/sda1 /mnt/usbflash
If you built this server on a different SheevaPlug, you will need to edit the following file to remove eth0:
nano /etc/udev/rules.d/70-persistent-net.rules
Also, make sure that UDP ports 5060-5061 & 10001-20000 are open on your firewall. If you plan on using FreePBX remotely then open TCP port 8000 (or whichever web port you are using) on your firewall as well.
Log in as, or switch to, the Root User
Please note: THIS IS IMPORTANT! You must run the entire process as root. Attempting to use ‘sudo’ later on will not work. Please don’t ignore this. You must run this entire installer as the root user. If will be helpful to enable ssh logins as root. To do so, you need to change the line ‘PermitRootLogin without-password’ to ‘PermitRootLogin yes’ in /etc/ssh/sshd_config. You can do this with the following commands.
sed -i ‘s/PermitRootLogin without-password/PermitRootLogin yes/’ /etc/ssh/sshd_config service sshd restart |
Update Your System
apt-get update && apt-get upgrade -y |
Install Required Dependencies
apt-get install -y build-essential linux-headers-`uname -r` openssh-server apache2 mysql-server mysql-client bison flex php5 php5-curl php5-cli php5-mysql php-pear php5-gd curl sox libncurses5-dev libssl-dev libmysqlclient-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp0-dev libspandsp-dev sudo libmyodbc subversion |
As part of this install, you will be asked several times for a mysql password. You can leave this blank (just push enter) as the instructions further down will generate a secure password. If you set a password now, you will cause problems further down. Please do not set a mysql password unless you are confident in your abilities to secure a SQL server.
Reboot server
reboot |
Install Prerequisites
After you machine has rebooted, you are now sure you’re running the latest Linux kernel. (At the time of writing this document, the Kernel supplied was 3.16.)
Install Legacy pear requirements
pear install Console_Getopt |
Install Dependencies for Google Voice (if required)
You may skip this section if you do not require Google Voice support.
Install iksemel
cd /usr/src wget https://iksemel.googlecode.com/files/iksemel-1.4.tar.gz tar xf iksemel-1.4.tar.gz cd iksemel-* ./configure make make install ldconfig |
Install and Configure Asterisk
Download Asterisk source files.
cd /usr/src wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz wget -O jansson.tar.gz https://github.com/akheron/jansson/archive/v2.7.tar.gz wget http://www.pjsip.org/release/2.4/pjproject-2.4.5.tar.bz2 |
Compile and install DAHDI.
If you don’t have any physical PSTN hardware attached to this machine, you don’t need to install DAHDI.(For example, a T1 or E1 card, or a USB device). Most smaller setups will not have DAHDI hardware, and this step can be safely skipped.
cd /usr/src tar xvfz dahdi-linux-complete-current.tar.gz rm -f dahdi-linux-complete-current.tar.gz cd dahdi-linux-complete-* make all make install make config cd /usr/src tar xvfz libpri-1.4-current.tar.gz rm -f libpri-1.4-current.tar.gz cd libpri-* make make install |
Compile and install pjproject
cd /usr/src tar -xjvf pjproject-2.4.5.tar.bz2 rm -f pjproject-2.4.5.tar.bz2 cd pjproject-2.4.5 CFLAGS=’-DPJ_HAS_IPV6=1′ ./configure –enable-shared –disable-sound –disable-resample –disable-video –disable-opencore-amr make dep make make install |
Compile and Install jansson
cd /usr/src tar vxfz jansson.tar.gz rm -f jansson.tar.gz cd jansson-* autoreconf -i ./configure make make install |
Compile and install Asterisk
cd /usr/src tar xvfz asterisk-13-current.tar.gz rm -f asterisk-13-current.tar.gz cd asterisk-* contrib/scripts/get_mp3_source.sh contrib/scripts/install_prereq install ./configure make menuselect |
You will be prompted at the point to pick which modules to build. Most of them will already be enabled, but if you want to have MP3 support (eg, for Music on Hold), you need to manually turn on ‘format_mp3’ on the first page. You might also want to make sure that the meetme and confbridge modules are selected.
After selecting ‘Save & Exit’ you can then continue
make make install make config ldconfig update-rc.d -f asterisk remove |
Install Asterisk Soundfiles.
The ‘make install’ above installs a standard low-quality base sound file by default. This is suitable if you are on a small, underpowered system (such as a Raspberry Pi), but on a larger system you should install higher quality soundfiles. Note that this installs the (8khz) ‘wav’ soundfiles and G722 (High Definition ‘Wideband’) audio.
cd /var/lib/asterisk/sounds wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-wav-current.tar.gz wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz tar xvf asterisk-core-sounds-en-wav-current.tar.gz rm -f asterisk-core-sounds-en-wav-current.tar.gz tar xfz asterisk-extra-sounds-en-wav-current.tar.gz rm -f asterisk-extra-sounds-en-wav-current.tar.gz # Wideband Audio download wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-g722-current.tar.gz wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz tar xfz asterisk-extra-sounds-en-g722-current.tar.gz rm -f asterisk-extra-sounds-en-g722-current.tar.gz tar xfz asterisk-core-sounds-en-g722-current.tar.gz rm -f asterisk-core-sounds-en-g722-current.tar.gz |
Install and Configure FreePBX
Create the Asterisk user and set base file permissions.
useradd -m asterisk chown -R asterisk. /etc/asterisk chown -R asterisk. /var/{lib,log,spool}/asterisk chown -R asterisk. /usr/lib/asterisk rm -rf /var/www/html |
A few small modifications to Apache.
sed -i ‘s/(^upload_max_filesize = ).*/120M/’ /etc/php5/apache2/php.ini cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig sed -i ‘s/^(User|Group).*/1 asterisk/’ /etc/apache2/apache2.conf sed -i ‘s/AllowOverride None/AllowOverride All/’ /etc/apache2/apache2.conf service apache2 restart |
Configure ODBC
Edit /etc/odbcinst.ini and add the following. Note that this command assumes you are installing to a new machine, and that the file is empty. If this is not a freshly installed machine, please manually verify the contents of the file, rather than just copying and pasting the lines below. The ‘EOF’ does no go in the file, it simply signals to the ‘cat’ command that you have finished pasting.
cat >> /etc/odbcinst.ini << EOF [MySQL] Description = ODBC for MySQL Driver = /usr/lib/arm-linux-gnueabi/odbc/libmyodbc.so Setup = /usr/lib/arm-linux-gnueabi/odbc/libodbcmyS.so FileUsage = 1 EOF |
Edit or create /etc/odbc.ini and add the following section. Note that, again, this command assumes you are installing to a new machine, and the file is empty. Please manually verify the contents of the files if this is not the case.
cat >> /etc/odbc.ini << EOF [MySQL-asteriskcdrdb] Description=MySQL connection to ‘asteriskcdrdb’ database driver=MySQL server=localhost database=asteriskcdrdb Port=3306 Socket=/var/run/mysqld/mysqld.sock option=3 EOF |
Download and install FreePBX.
cd /usr/src wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-13.0-latest.tgz tar vxfz freepbx-13.0-latest.tgz rm -f freepbx-13.0-latest.tgz cd freepbx ./start_asterisk start chown asterisk. /var/run/asterisk ./install -n |
That’s it!
You can now start using FreePBX. Open up your web browser and connect to the IP address or hostname of your new FreePBX server. You will see the Admin setup page, which is where you set your ‘admin’ account password, and configure an email address to receive update notifications.
There are (at the time of writing) approximately 50 additional modules that can be installed to enhance the usability of your FreePBX machine – you can install these via Module Admin.
We hope you enjoy using FreePBX 13!
Automatic Startup
Please note you need to set up FreePBX to start asterisk (and it’s associated services) on bootup.
As most distributions have moved to systemd, here’s an example startup script that you may customize for your installation.
[Unit] Description=FreePBX VoIP Server After=mysql.service [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/sbin/fwconsole start ExecStop=/usr/sbin/fwconsole stop [Install] WantedBy=multi-user.target |
From there you can enable it so it starts automatically
[root@firewall ~]# systemctl enable freepbx.service ln -s ‘/etc/systemd/system/freepbx.service’ ‘/etc/systemd/system/multi-user.target.wants/freepbx.service’ [root@firewall ~]# |
And then start it yourself if you haven’t already
[root@firewall ~]# systemctl start freepbx [root@firewall ~]# |
You can check the output of the startup with the ‘systemctl status’ command
Reference
http://wiki.freepbx.org/display/FOP/Installing+FreePBX+13+on+Debian+8.1
http://wiki.freepbx.org/display/FOP/Example+systemd+startup+script+for+FreePBX