Wednesday, February 6, 2013

FiskIT Cheat Sheet - Asterisk 11, FreePBX 2.10.0 on Amazon EC2 Cloud Small Instance

Building a state of the art business VoIP phone system using linux, free software and Amazon EC2 Cloud services. No hardware needed. To learn more about this and other amazing I.T. services, contact FiskIT today! www.fiskinfotech.com

Install initially based on instructions from these sites
http://www.freepbx.org/trac/wiki/UbuntuServer
http://wiki.freepbx.org:8090/pages/viewpage.action?pageId=1409028
http://ubuntuforums.org/showthread.php?t=1986217

Create new instance
     In AWS Console EC2 Dashboard   
          Launch Instance
          Choose Classic Wizard and continue
          Select Ubuntu Server 12.04.1 LTS 64bit
          Change instance type to M1 Small (T1 Micro does not have enough umpf for ivr and whatnot) and continue
          Check box Prevention against accidental termination and continue
          Edit the Storage Device Configuration, uncheck Delete on Termination, hit Save then continue
          Under Name, add a server name for the value
          Choose an existing key pair or create a new key (save this to your desktop and also save a copy somewhere safe.  If you loose it, you wont be able to gain access to the vm ever again)
          Create a new security group
               Group name: voip server
               Group description: voip server rules
               Rules to add:
                    http: 0.0.0.0/0
                    https: 0.0.0.0/0
                    ssh: 0.0.0.0/0
                    udp 5060-5061: 0.0.0.0/0
                    udp 10000-20000: 0.0.0.0/0
               Continue, Launch, Close
Connect to the instance
     In AWS Console, EC2 Dashboard, Instances, right click on the instance and choose Connect
          For private key path, enter the path to the pem file you saved when you created a new key in the previous steps
          Launch ssh client
Update your system:
     apt-get update && sudo apt-get upgrade -y
     reboot
Install the packages
     apt-get -y install php5-mysql php-db mysql-server libapache2-mod-php5 php5-gd php-pear php-DB sox curl build-essential linux-headers-`uname -r` openssh-server apache2 mysql-client bison flex php5 php5-curl php5-cli libncurses5-dev libssl-dev libmysqlclient15-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git subversion gcc
          Set mysql root passwd when prompted
     pear install db
Download Software
     cd /usr/src/
     wget https://iksemel.googlecode.com/files/iksemel-1.4.tar.gz
     wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-11-current.tar.gz
     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
Install dependencies for google voice
     cd /usr/src
     tar xf iksemel-1.4.tar.gz
     cd iksemel-1.4
     ./configure
     make all install 
For the localization to work properly you may have to edit /etc/php5/apache2/php.ini and modify as follow (leny/sid):
     ; PHP's built-in default is text/html
     default_mimetype = "text/html"
     ;default_charset = "ISO-8859-1"
     default_charset = "utf8";
Compile and install DAHDI.
     cd /usr/src
     tar xvfz dahdi-linux-complete-current.tar.gz
     cd dahdi-linux-complete-2.6.1+2.6.1
     make all
     make install
     make config
Compile and install LIBPRI.
     cd /usr/src
     tar xvfz libpri-1.4-current.tar.gz
     cd libpri-1.4.14
     make
     make install
Compile and install Asterisk
     cd /usr/src
     tar xvfz asterisk-11-current.tar.gz
     cd asterisk-11.2.1
     ./configure
     contrib/scripts/get_mp3_source.sh
     make menuselect
     make
     make install
     make config
Install Asterisk-Extra-Sounds
     cd /var/lib/asterisk/sounds
     wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-gsm-current.tar.gz
     tar xfz asterisk-extra-sounds-en-gsm-current.tar.gz
     rm asterisk-extra-sounds-en-gsm-current.tar.gz
Setup permissions for asterisk.asterisk
     adduser asterisk --disabled-password --no-create-home --gecos "Asterisk User"
     chown asterisk. /var/run/asterisk
     chown -R asterisk. /etc/asterisk
     chown -R asterisk. /var/{lib,log,spool}/asterisk
     chown -R asterisk. /usr/lib/asterisk
     mkdir /var/www/html
     chown -R asterisk. /var/www/
Modify 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
     service apache2 restart
     nano /etc/apache2/sites-enabled/000-default
     Change /var/www to /var/www/html
Download and untar FrePBX
     cd /usr/src
     wget http://mirror.freepbx.org/freepbx-2.10.0.tar.gz
     tar zxvf freepbx-2.10.0.tar.gz
     cd freepbx-2.10.0
Configure Asterisk database in MYSQL and set permissions
     export ASTERISK_DB_PW=amp109
     mysqladmin -u root -p create asterisk
     mysqladmin -u root -p create asteriskcdrdb
     mysql -u root -p asterisk < SQL/newinstall.sql
     mysql -u root -p asteriskcdrdb < SQL/cdr_mysql_table.sql
     mysql -u root -p -e "GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
     mysql -u root -p -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
     mysql -u root -p -e "flush privileges;"
     nano /etc/asterisk/manager.conf
          make sure password for admin is amp109
Patch safe_asterisk script
     sed -i "s|#!/bin/sh|#!/bin/bash|" /usr/sbin/safe_asterisk
#     nano /usr/sbin/safe_asterisk
#          SAFE_AST_BACKGROUND=1
Start asterisk
./start_asterisk start
Create symbolic link for agi-bin
ln -s /usr/share/asterisk/agi-bin /var/lib/asterisk/agi-bin
Install FreePBX
     ./install_amp
     log into fbpx portal via http://host/
     Go into advanced settings, make sure password for admin is amp109
     Apply
Wrapping up
     purchase an elastic IP and assign to the instance
     point a domain voip.domain.com to your IP
     log into freepbx via http:// with the username admin and password admin
Install FreePBX Modules
     Under administration, module admin, install the additional modules you want/need, upgrade already installed if available
Setup Extensions, groups, ivr, etc
Setup trunks
    

2 comments:

Ramen Networks said...

If you cant start Asterisk
Program received signal SIGILL, Illegal instruction.
__ast_calloc_with_stringfields (num_structs=1, struct_size=96, field_mgr_offset=72, field_mgr_pool_offset=24, pool_size=, file=, lineno=1486, func=0x5baf6e "ast_log_full")
at utils.c:1967
1967 *p++ = __ast_string_field_empty;

Do the following:
"make menuselect" -> "Compiler flags" and disable "BUILD_NATIVE" optio

Ramen Networks said...

STARTING ASTERISK
Asterisk ended with exit status 132
Asterisk exited on signal 4.
Automatically restarting Asterisk.
Asterisk ended with exit status 132
Automatically restarting Asterisk.
killall -9 safe_asterisk
root@ip-172-31-2-91:/usr/src/freepbx# killall -9 safe_asterisk
safe_asterisk: no process found
root@ip-172-31-2-91:/usr/src/freepbx# killall -9 safe_asterisk^C
root@ip-172-31-2-91:/usr/src/freepbx#
root@ip-172-31-2-91:/usr/src/freepbx# gdb --args /usr/sbin/asterisk -f
The program 'gdb' is currently not installed. You can install it by typing:
apt-get install gdb
root@ip-172-31-2-91:/usr/src/freepbx# apt-get install gdb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
gdb-doc gdbserver
The following NEW packages will be installed:
gdb
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 2,308 kB of archives.
After this operation, 6,694 kB of additional disk space will be used.
Get:1 http://us-west-2.ec2.archive.ubuntu.com/ubuntu/ precise-updates/main gdb amd64 7.4-2012.04-0ubuntu2.1 [2,308 kB]
Fetched 2,308 kB in 0s (8,927 kB/s)
Selecting previously unselected package gdb.
(Reading database ... 56925 files and directories currently installed.)
Unpacking gdb (from .../gdb_7.4-2012.04-0ubuntu2.1_amd64.deb) ...
Processing triggers for man-db ...
Setting up gdb (7.4-2012.04-0ubuntu2.1) ...
root@ip-172-31-2-91:/usr/src/freepbx# gdb --args /usr/sbin/asterisk -f
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
...
Reading symbols from /usr/sbin/asterisk...done.
(gdb) run
Starting program: /usr/sbin/asterisk -f
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff7fea700 (LWP 1886)]
[New Thread 0x7ffff7f6e700 (LWP 1887)]
[New Thread 0x7ffff7ef2700 (LWP 1888)]
[New Thread 0x7ffff5e68700 (LWP 1889)]

Program received signal SIGILL, Illegal instruction.
__ast_calloc_with_stringfields (num_structs=1, struct_size=96, field_mgr_offset=72, field_mgr_pool_offset=24, pool_size=, file=, lineno=1489, func=0x5bb1ce "ast_log_full")
at utils.c:1969
1969 *p++ = __ast_string_field_empty;
(gdb)