Page tree
Skip to end of metadata
Go to start of metadata

Initial System Setup

When installing the machine, at package selection make sure you pick - at least - OpenSSH Server, and 'LAMP Packages'.  This installs the base packages required.

Configure your root password.

sudo passwd root

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 command to switch to an interactive root shell.

sudo -i

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 php-db php5-gd curl sox\
  libncurses5-dev libssl-dev libmysqlclient-dev mpg123 libxml2-dev libnewt-dev sqlite3\
  libsqlite3-dev pkg-config automake libtool autoconf git subversion unixodbc-dev uuid uuid-dev\
  libasound2-dev libogg-dev libvorbis-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp0-dev\
  libspandsp-dev libmyodbc
 

Reboot server

reboot

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

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-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-12-current.tar.gz
git clone https://github.com/akheron/jansson.git
git clone https://github.com/asterisk/pjproject.git

Compile and install DAHDI.

If you don't have any physical hardware you don't need to run these commands

cd /usr/src
tar xvfz dahdi-linux-complete-current.tar.gz
cd dahdi-linux-complete-*
make all
make install 
make config

Compile and install LIBPRI.

If you don't have any physical hardware you don't need to run these commands

cd /usr/src
tar xvfz libpri-current.tar.gz
cd libpri-*
make
make install

 

Compile and install pjproject

cd /usr/src/pjproject
./configure --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr
make dep
make
make install

Compile and Install jansson

cd /usr/src/jansson
autoreconf -i
./configure
make
make install

Compile and install Asterisk

cd /usr/src
tar xvfz asterisk-12-current.tar.gz
cd asterisk-*
./configure
contrib/scripts/get_mp3_source.sh
make menuselect

You will be prompted at the point to pick which modules to build. Most of them will be enabled, but if you want to have MP3 support, you need to manually turn on 'format_mp3' on the first page.

After selecting 'Save & Exit' you can then continue

make
make install
make config
ldconfig

 

Install Asterisk-Extra-Sounds

Note that this installs the (8khz) 'wav' soundfiles. If you're planning on running G722 (High Definition 'Wideband') audio, you also want to download the 722 codec pack, which is the second part. If you're not planning on using Wideband, you can skip that part.

cd /var/lib/asterisk/sounds
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-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-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

Install and Configure FreePBX

Download and extract FreePBX.

wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-12.0-latest.tgz
tar vxfz freepbx-12-latest.tgz
cd freepbx

Now create the Asterisk user and set ownership permissions.

useradd -m asterisk
chown asterisk. /var/run/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
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/x86_64-linux-gnu/odbc/libmyodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1
 
EOF

You may need to verify these paths, if you're not on a x86_64 machine. You can use the command `find / -name libmyodbc.so` to verify the location

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

Prepare MySQL

You now need to generate a secure password for FreePBX to use to talk to MySQL.

export ASTERISK_DB_PW=`dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 - | cut -c2-18`

That will generate a quasi-random 16 character long password, which should be secure enough for most things.  If you had set the MySQL 'root' password to be something when you were installing the machine, you will need to add a -pyourpassword flag to the following lines

Configure Asterisk database in MYSQL. 

mysqladmin -u root create asterisk
mysqladmin -u root create asteriskcdrdb

Set permissions on MYSQL database.

mysql -u root -e "GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
mysql -u root -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
mysql -u root -e "flush privileges;"

Restart Asterisk and install FreePBX.

./start_asterisk start
./install_amp --installdb --username=asteriskuser --password=${ASTERISK_DB_PW}
amportal chown
amportal a ma installall
amportal a reload
amportal a ma refreshsignatures
amportal chown

Finally, one last mod and start FreePBX.

ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
amportal restart

Start FreePBX

Navigate: 

Now FreePBX is installed, it will be available via Apache. Open up your web browser and visit:

    http://Address.Of.FreePBX.Server/admin

 

10 Comments

  1. The sed line above didn't work on Ubuntu 14.04.  I also had to change the following in php.ini , otherwise when I selected very large dial pattern the page didn't update.

    max_input_vars = 1000

    to 

    max_input_vars = 10000

    1. If you have very large dialpatterns you should think about turning on "enable old dial patterns" in advanced settings

  2. You may have to manually set the password in /etc/freepbx.conf if you get errors during the freepbx installation, specifically, when you run the command:

    amportal a ma installall

    You may get errors such as:

    Please wait...
    /usr/local/sbin/amportal: line 47: [FATAL]: command not found
    /var/lib/asterisk/bin/freepbx_engine: line 98: [FATAL]: command not found
    **** WARNING: ERROR IN CONFIGURATION ****
    astrundir in '/etc/asterisk' is set to but the directory does not exists. Attempting to create it with: 'mkdir -p ' mkdir: missing operand Try 'mkdir --help' for more information. **** ERROR: COULD NOT CREATE **** Attempt to execute 'mkdir -p ' failed with an exit code of 1 You must create this directory and the try again.

     

     

  3.  

    Hello everyone

    I am setting freepbx. but I could not set the D. B. asteriskcdrdb, since this is in another mysql server. /etc/amportal.conf modify the file in the following values:

    # --- CATEGORY: Remote CDR Database ---
    #
    # Remote CDR DB Host
    # Default Value:
    CDRDBHOST =10.100.1.XX

    # Remote CDR DB Name
    # Default Value:
    CDRDBNAME =asteriskcdrdb

    # Remote CDR DB Password
    # Default Value:
    CDRDBPASS =xxxxxxx

    # Remote CDR DB Port
    # Default Value:
    CDRDBPORT =3306

    # Remote CDR DB Table
    # Default Value:
    CDRDBTABLENAME =cdr

    # Remote CDR DB Type
    # Default Value:
    CDRDBTYPE=mysql


    # Remote CDR DB User
    # Default Value:
    CDRDBUSER =freepbx

    How do I do this? to make it permanent, and that freepbx module (cdr records) also take these values. Because whenever I restart the service (amportal restart) it changes the values to default.


    regards


    Ing. julio cesar Arevalo

    1. Change this in advanced settings in the GUI. Please use the forum for future support.

  4. Every command fine till I get to: 

    Restart Asterisk and install FreePBX.

    ./start_asterisk start

    I get an error. 

    -bash: ./start_asterisk: No such file or directory

    what folder is it at?? or any suggestions.

     

    I would also kindly ask for the code to insert mysql password. I tried running in with password and I got stuck on how to insert it.

     

    Thanks in advance for your time and attention.

     

    Jorge

    1. Ok, found error:

      On following step

      Install and Configure FreePBX

      Download and extract FreePBX.

       

      cd /
      wget http://mirror.freepbx.org/freepbx-12.0.3.tgz
      tar vxfz freepbx-12.0.3.tgz

      before ./start_asterisk start

      do cd  /freepbx/

      then

      ./start_asterisk start

      continue

  5. I am getting an error in this line:

    cd /var/lib/asterisk/sounds

     

    -bash: cd: /var/lib/asterisk/sounds: No such file or directory

     

    Any idea ?

  6. Running into an error doing this onto an existing Asterisk installation. All commands are being ran as root, any help? (Passwords have been changed to protect the innocent) Yes, I read the previous comment about the freepbx.conf file, see below for contents.


    root@server:/usr/src/freepbx#./install_amp --installdb --username=asterisk --password=password
    Checking for PEAR DB..OK
    Checking for PEAR Console::Getopt..OK
    Using username: asterisk
    Using password: ********
    Checking user..OK
    Checking if Asterisk is running..running with PID: 2243..OK
    Checking for /etc/amportal.conf..OK
    Reading /etc/amportal.conf..parsed amp_conf variables from /etc/amportal.conf:
    amp_conf [AMPDBHOST] => [localhost]
    amp_conf [AMPDBENGINE] => [mysql]
    amp_conf [AMPENGINE] => [asterisk]
    amp_conf [AMPMGRUSER] => [admin]
    amp_conf [AMPMGRPASS] => [amp111]
    amp_conf [AMPBIN] => [/var/lib/asterisk/bin]
    amp_conf [AMPSBIN] => [/usr/local/sbin]
    amp_conf [AMPWEBROOT] => [/var/www/html]
    amp_conf [AMPCGIBIN] => [/var/www/cgi-bin ]
    amp_conf [FOPWEBROOT] => [/var/www/html/panel]
    amp_conf [FOPPASSWORD] => [passw0rd]
    amp_conf [AUTHTYPE] => [database]
    amp_conf [AMPEXTENSIONS] => [extensions]
    amp_conf [AMPDBUSER] => [asterisk]
    amp_conf [AMPDBPASS] => [asterisk]
    amp_conf [AMPWEBADDRESS] => [172.16.10.40]
    amp_conf [AMPDBNAME] => [asterisk]
    amp_conf [ASTETCDIR] => [/etc/asterisk]
    amp_conf [ASTMODDIR] => [/usr/lib/asterisk/modules]
    amp_conf [ASTVARLIBDIR] => [/var/lib/asterisk]
    amp_conf [ASTAGIDIR] => [/usr/share/asterisk/agi-bin]
    amp_conf [ASTSPOOLDIR] => [/var/spool/asterisk]
    amp_conf [ASTRUNDIR] => [/var/run/asterisk]
    amp_conf [ASTLOGDIR] => [/var/log/asterisk]
    OK
    Checking for /etc/asterisk/asterisk.conf..OK
    Reading /etc/asterisk/asterisk.conf..OK
    Using asterisk as PBX Engine
    Checking for Asterisk version..11.5.0
    Checking for selinux..OK
    Connecting to database..OK
    Checking state of FreePBX DB...FreePBX DB is already populated skipping
    Checking state of FreePBX CDRDB...FAILED TO INSTALL CDR
    Checking current version of FreePBX..no version information
    Assuming new installation
    Installing new FreePBX files../etc/asterisk/musiconhold.conf has been changed from the original version.
    Overwrite (y=yes/a=all/n=no/d=diff/s=shell/x=exit)? n
    /etc/asterisk/cdr_mysql.conf has been changed from the original version.
    Overwrite (y=yes/a=all/n=no/d=diff/s=shell/x=exit)? n
    /etc/asterisk/phone.conf has been changed from the original version.
    Overwrite (y=yes/a=all/n=no/d=diff/s=shell/x=exit)? n
    /etc/asterisk/indications.conf has been changed from the original version.
    Overwrite (y=yes/a=all/n=no/d=diff/s=shell/x=exit)? n
    /etc/asterisk/queues.conf has been changed from the original version.
    Overwrite (y=yes/a=all/n=no/d=diff/s=shell/x=exit)? n
    /etc/asterisk/meetme.conf has been changed from the original version.
    Overwrite (y=yes/a=all/n=no/d=diff/s=shell/x=exit)? n
    /etc/asterisk/manager.conf has been changed from the original version.
    Overwrite (y=yes/a=all/n=no/d=diff/s=shell/x=exit)? n
    /etc/asterisk/modules.conf has been changed from the original version.
    Overwrite (y=yes/a=all/n=no/d=diff/s=shell/x=exit)? n
    /etc/asterisk/enum.conf has been changed from the original version.
    Overwrite (y=yes/a=all/n=no/d=diff/s=shell/x=exit)? n
    OK (1 files copied, 1004 skipped)
    amportal..no fpbx..freepbx_engine..freepbx_setting..gen_amp_conf.php..done
    /var/lib/asterisk/bin/freepbx_engine: line 98: [FATAL]: command not found
    mkdir: missing operand
    Try `mkdir --help' for more information.
    apply username/password changes to conf files:
    running apply_conf.sh from /etc/amportal.conf
    Reading /etc/amportal.conf
    Updating configuration...
    /etc/asterisk/cdr_mysql.conf user: [asterisk] password: [asterisk] hostname: [localhost]
    /etc/asterisk/manager.conf user: [admin] secret: [amp111]
    Adjusting File Permissions..


    SETTING FILE PERMISSIONS................Done
    Removing any dangling symlinks
    Dangling symlinks removed
    Done
    done with apply_conf.sh
    creating missing #include files..OK
    Module 'manager' reloaded successfully.
    Setting permissions on files..OK
    Loading Bootstrap..OK
    Checking for upgrades..57 found
    Upgrading to 1.10.007beta1..
    -> Running SQL script /usr/src/freepbx/upgrades/1.10.007beta1/tables.sql
    [FATAL] ALTER TABLE `sip` CHANGE `id` `id` BIGINT( 11 ) DEFAULT "-1" NOT NULL [nativecode=1146 ** Table 'asterisk.sip' doesn't exist]" while running tables.sql

     ******

    Freepbx.conf

    <?php
    $amp_conf['AMPDBUSER'] = 'asterisk';
    $amp_conf['AMPDBPASS'] = 'asterisk';
    $amp_conf['AMPDBHOST'] = 'localhost';
    $amp_conf['AMPDBNAME'] = 'asterisk';
    $amp_conf['AMPDBENGINE'] = 'mysql';
    $amp_conf['datasource'] = ''; //for sqlite3

    require_once('/var/www/html/admin/bootstrap.php');

  7. In the "Install and Configure FreePBX" - "Download and extract FreePBX." section.

    What directory should you be in?  If you continue from the previous step, you'd be in the  "/var/lib/asterisk/sounds" directory, which doesn't seem like the proper place.