juanbrunette
Member
Asterisk with FreePBX - all my settings and steps
I have been battling to get a cost effective and easy PBX for months now - I tried anything from a RaspberryPI, www.pbxes.org to an old workstation with CentOS 6.5. After a lot of reading and struggling I created this installation procedure and I hope it will help you in some way. This solution is based on a server in the cloud in South Africa for about R40 a month. And if you take an annual package then it becomes even cheaper. Thanks to WarwickW for all your input and help along the way.
Setup an account with www.host1plus.com and choose the South African Server in Johannesburg. You can get a trial for 14 days at http://trial.host1plus.com
I chose:
-1 Core
-512Mb Memory
-Centos 6 64Bit
-TUN/TAP
Total of about $4 a month.
Download Putty and use it to SSH to your server.
---------------------------------------------------------------------------------------
Phase 1: Initial Requirements
---------------------------------------------------------------------------------------
1) Log into your server with SSH with the details that they provide you via email.
2) Once logged in copy and paste into your SSH Console:
# Start
# Does all the YUM updates and installs needed
yum -y update
yum -y groupinstall core
yum -y groupinstall base
yum -y install gcc gcc-c++ lynx bison mysql-devel mysql-server php php-mysql php-pear php-mbstring tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-nameserver sox
yum -y install newt-devel ntp libxml2-devel tunctl libtiff-devel audiofile-devel gtk2-devel subversion kernel-devel git subversion kernel-devel php-process crontabs cronie cronie-anacron wget vim php-xml yum-cron
# Installs the REPOS needed for Asterisk
cd /etc/yum.repos.d
wget http://packages.asterisk.org/centos/centos-asterisk-12.repo
wget http://packages.asterisk.org/centos/centos-asterisk-11.repo
wget http://packages.asterisk.org/centos/centos-asterisk.repo
wget http://packages.digium.com/centos/centos-digium-12.repo
wget http://packages.digium.com/centos/centos-digium-11.repo
wget http://packages.digium.com/centos/centos-digium-1.8-certified.repo
wget http://packages.digium.com/centos/centos-digium-1.8.repo
wget http://packages.digium.com/centos/centos-digium.repo
# Enables the necessary services to start after a reboot
chkconfig --level 345 mysqld on
service mysqld start
chkconfig --level 345 httpd on
service httpd start
chkconfig --level 345 iptables on
chkconfig --level 345 yum-cron on
chkconfig --level 345 ntpd on
# Sets up a weekly reboot
touch /etc/cron.weekly/reboot.cron
echo reboot >> /etc/cron.weekly/reboot.cron
chmod 777 /etc/cron.weekly/reboot.cron
ls
# Update and Install Pear
pear channel-update pear.php.net
pear install db
# Reboot the server
reboot
# Stop
---------------------------------------------------------------------------------------
Phase 2: Setup and Config
---------------------------------------------------------------------------------------
1) Log into your server with SSH with the details that they provide you via email.
2) Once logged in copy and paste into your SSH Console:
# Start
# Add the Asterisk user to your OS
adduser asterisk -M -c "Asterisk User"
# Install Asterisk
yum -y install asterisk asterisk-configs asterisk-addons --enablerepo=asterisk-12
yum -y install asterisk-sounds*
# Get the GIT for FreePBX
export VER_FREEPBX=12.0
cd /usr/src
git clone http://git.freepbx.org/scm/freepbx/framework.git freepbx
cd freepbx
git checkout release/${VER_FREEPBX}
# Set security needs
chown asterisk /var/run/asterisk
chown -R asterisk /etc/asterisk
chown -R asterisk /var/{lib,log,spool}/asterisk
chown -R asterisk /usr/lib/asterisk
chown -R asterisk /usr/lib64/asterisk
chown -R asterisk /var/www/
chown -R asterisk /var/www/*
rm -Rf /var/www/html
# Update HTTPD settings
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php.ini
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf_orig
cp /var/www/html/admin/.htaccess /var/www/html/recordings/.htaccess
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/httpd/conf/httpd.conf
sed -i 's|AllowOverride None|AllowOverride All|g' /etc/httpd/conf/httpd.conf
# Setup MySQL
cd /usr/src/freepbx
export ASTERISK_DB_PW=amp109
mysqladmin -u root create asterisk
mysqladmin -u root create asteriskcdrdb
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;"
# Does the Install - please read and answer any questions the install might ask. If not sure press enter to accept the defaults
# If there are any errors with the install part then just run these three lines again
# If you are asked to overwrite any files then choose all
cd /usr/src/freepbx
./start_asterisk start
./install_amp --installdb --username=asteriskuser --password=${ASTERISK_DB_PW}
---------------------------------------------------------------------------------------
Phase 3: Setup and Config continues
---------------------------------------------------------------------------------------
# After the install finished without errors then continue to copy and past the following lines into the SSH console
# Start
cd /usr/src/freepbx
service httpd restart
./install_amp --update-links
amportal chown
amportal a ma installall
amportal chown
amportal a reload
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
cd /var/lib/asterisk/moh
chmod 777 *
chown asterisk /var/run/asterisk
chown -R asterisk /etc/asterisk
chown -R asterisk /var/{lib,log,spool}/asterisk
chown -R asterisk /usr/lib/asterisk
chown -R asterisk /usr/lib64/asterisk
chown -R asterisk /var/www/
chown -R asterisk /var/www/*
chown -R asterisk /var/www/html/*
chmod 777 /etc/asterisk/indications.conf
amportal start
# Installs the commercial repos
wget -P /etc/yum.repos.d/ -N http://yum.schmoozecom.net/schmooze-commercial/schmooze-commercial.repo
yum clean all
yum -y install php-5.3-zend-guard-loader sysadmin fail2ban incron ImageMagick
service httpd restart
chkconfig --level 345 fail2ban on
amportal a ma installall
amportal a ma download sysadmin
amportal a ma install sysadmin
amportal a ma download cos
amportal a ma install cos
amportal a ma download cdr
amportal a ma install cdr
echo load = cdr_mysql.so >> /etc/asterisk/modules.conf
ls
# Configures IPTables
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
iptables -A INPUT -p udp --dport 5060 -j ACCEPT
iptables -A INPUT -p udp --dport 10000:20000 -j ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P INPUT DROP
iptables -L -n
iptables-save | sudo tee /etc/sysconfig/iptables
/sbin/service iptables save
service iptables restart
# Stop
--------------------------------------------------------------------------------------
Phase 4: Login to FreePBX Website
---------------------------------------------------------------------------------------
1) Login on http://yourserverIPaddress with the details that they provide you via email.
2) Create an Admin Username and Password
3) Login to the Administrator Page for FreePBX with the username and password created
4) Click on the Red Apply Config button on the top
5) Goto Settings - Advanced Settings
6) Change the Asterisk Manager Password then click on the tick and then press apply, ignore the error and do step 6.
Via SSH on the server:
7) vim /etc/amportal.conf look for (AMPMGRPASS) and make password same as in step 5
8) amportal restart
Back in the website:
9) Retry the Apply Config in FreePBX. Should apply fine.
10) Goto Admin - Asterisk Modules and check for cdr_mysql.so under Manually Loaded Modules (this is for CDR to work and Recordings to show)
11) Goto Admin - Module Admin (this is optional)
Uninstall:
Announcements
Call Flow Control
Custom Applications
Digium Addons
iSymphony
Directory
Follow Me
Digium Phones Config
Sipstation
Fax Configuration
---------------------------------------------------------------------------------------
Phase 5: Setup Trunks
---------------------------------------------------------------------------------------
1) Goto www.fnbconnect.co.za and create your FNB Number there or www.nexus.co.za and create a number there. I used FNB for my numbers.
2) Login on http://yourserverIPaddress
3) Go to Connectivity then Trunks and create a Trunk there.
4) SIP Settings for FNB:
Peer Details (Call it FNB-087322XXXX):
host=voice.fnbconnect.co.za
username=087322XXXX
authname=087322XXXX
secret=YYYYYY
type=peer
auth=md5
nat=no
disallow=all
allow=g729
context=from-trunk
insecure=port,invite
timezone=Africa/Johannesburg
trunkfreq=20
trunk=yes
qualify=yes
qualifysmoothing=yes
User Details (User Context must be the FNB Number: 087322XXXX):
secret=YYYYYY (same as secret above)
type=user
context=from-trunk
register string:
087322XXXX:YYYYYY(same as secret above)@voice.fnbconnect.co.za/087322XXXX
Same as the FNB number above. YYYYYY same as the secret above.
Create an Outbound Route - this is needed to dial out.
1) Connectivity - Outbound Routes
2) Give it a name like FNB-087322XXXX
3) Route CID 087322XXXX
4) Create 1 dial pattern that has the +27X. in match pattern
5) Create 1 dial pattern that has the X. in match pattern
6) Choose your FNB-087322XXXX trunk under trunk sequence
Follow my next phases in the next post/reply.
I have been battling to get a cost effective and easy PBX for months now - I tried anything from a RaspberryPI, www.pbxes.org to an old workstation with CentOS 6.5. After a lot of reading and struggling I created this installation procedure and I hope it will help you in some way. This solution is based on a server in the cloud in South Africa for about R40 a month. And if you take an annual package then it becomes even cheaper. Thanks to WarwickW for all your input and help along the way.
Setup an account with www.host1plus.com and choose the South African Server in Johannesburg. You can get a trial for 14 days at http://trial.host1plus.com
I chose:
-1 Core
-512Mb Memory
-Centos 6 64Bit
-TUN/TAP
Total of about $4 a month.
Download Putty and use it to SSH to your server.
---------------------------------------------------------------------------------------
Phase 1: Initial Requirements
---------------------------------------------------------------------------------------
1) Log into your server with SSH with the details that they provide you via email.
2) Once logged in copy and paste into your SSH Console:
# Start
# Does all the YUM updates and installs needed
yum -y update
yum -y groupinstall core
yum -y groupinstall base
yum -y install gcc gcc-c++ lynx bison mysql-devel mysql-server php php-mysql php-pear php-mbstring tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-nameserver sox
yum -y install newt-devel ntp libxml2-devel tunctl libtiff-devel audiofile-devel gtk2-devel subversion kernel-devel git subversion kernel-devel php-process crontabs cronie cronie-anacron wget vim php-xml yum-cron
# Installs the REPOS needed for Asterisk
cd /etc/yum.repos.d
wget http://packages.asterisk.org/centos/centos-asterisk-12.repo
wget http://packages.asterisk.org/centos/centos-asterisk-11.repo
wget http://packages.asterisk.org/centos/centos-asterisk.repo
wget http://packages.digium.com/centos/centos-digium-12.repo
wget http://packages.digium.com/centos/centos-digium-11.repo
wget http://packages.digium.com/centos/centos-digium-1.8-certified.repo
wget http://packages.digium.com/centos/centos-digium-1.8.repo
wget http://packages.digium.com/centos/centos-digium.repo
# Enables the necessary services to start after a reboot
chkconfig --level 345 mysqld on
service mysqld start
chkconfig --level 345 httpd on
service httpd start
chkconfig --level 345 iptables on
chkconfig --level 345 yum-cron on
chkconfig --level 345 ntpd on
# Sets up a weekly reboot
touch /etc/cron.weekly/reboot.cron
echo reboot >> /etc/cron.weekly/reboot.cron
chmod 777 /etc/cron.weekly/reboot.cron
ls
# Update and Install Pear
pear channel-update pear.php.net
pear install db
# Reboot the server
reboot
# Stop
---------------------------------------------------------------------------------------
Phase 2: Setup and Config
---------------------------------------------------------------------------------------
1) Log into your server with SSH with the details that they provide you via email.
2) Once logged in copy and paste into your SSH Console:
# Start
# Add the Asterisk user to your OS
adduser asterisk -M -c "Asterisk User"
# Install Asterisk
yum -y install asterisk asterisk-configs asterisk-addons --enablerepo=asterisk-12
yum -y install asterisk-sounds*
# Get the GIT for FreePBX
export VER_FREEPBX=12.0
cd /usr/src
git clone http://git.freepbx.org/scm/freepbx/framework.git freepbx
cd freepbx
git checkout release/${VER_FREEPBX}
# Set security needs
chown asterisk /var/run/asterisk
chown -R asterisk /etc/asterisk
chown -R asterisk /var/{lib,log,spool}/asterisk
chown -R asterisk /usr/lib/asterisk
chown -R asterisk /usr/lib64/asterisk
chown -R asterisk /var/www/
chown -R asterisk /var/www/*
rm -Rf /var/www/html
# Update HTTPD settings
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php.ini
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf_orig
cp /var/www/html/admin/.htaccess /var/www/html/recordings/.htaccess
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/httpd/conf/httpd.conf
sed -i 's|AllowOverride None|AllowOverride All|g' /etc/httpd/conf/httpd.conf
# Setup MySQL
cd /usr/src/freepbx
export ASTERISK_DB_PW=amp109
mysqladmin -u root create asterisk
mysqladmin -u root create asteriskcdrdb
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;"
# Does the Install - please read and answer any questions the install might ask. If not sure press enter to accept the defaults
# If there are any errors with the install part then just run these three lines again
# If you are asked to overwrite any files then choose all
cd /usr/src/freepbx
./start_asterisk start
./install_amp --installdb --username=asteriskuser --password=${ASTERISK_DB_PW}
---------------------------------------------------------------------------------------
Phase 3: Setup and Config continues
---------------------------------------------------------------------------------------
# After the install finished without errors then continue to copy and past the following lines into the SSH console
# Start
cd /usr/src/freepbx
service httpd restart
./install_amp --update-links
amportal chown
amportal a ma installall
amportal chown
amportal a reload
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
cd /var/lib/asterisk/moh
chmod 777 *
chown asterisk /var/run/asterisk
chown -R asterisk /etc/asterisk
chown -R asterisk /var/{lib,log,spool}/asterisk
chown -R asterisk /usr/lib/asterisk
chown -R asterisk /usr/lib64/asterisk
chown -R asterisk /var/www/
chown -R asterisk /var/www/*
chown -R asterisk /var/www/html/*
chmod 777 /etc/asterisk/indications.conf
amportal start
# Installs the commercial repos
wget -P /etc/yum.repos.d/ -N http://yum.schmoozecom.net/schmooze-commercial/schmooze-commercial.repo
yum clean all
yum -y install php-5.3-zend-guard-loader sysadmin fail2ban incron ImageMagick
service httpd restart
chkconfig --level 345 fail2ban on
amportal a ma installall
amportal a ma download sysadmin
amportal a ma install sysadmin
amportal a ma download cos
amportal a ma install cos
amportal a ma download cdr
amportal a ma install cdr
echo load = cdr_mysql.so >> /etc/asterisk/modules.conf
ls
# Configures IPTables
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
iptables -A INPUT -p udp --dport 5060 -j ACCEPT
iptables -A INPUT -p udp --dport 10000:20000 -j ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P INPUT DROP
iptables -L -n
iptables-save | sudo tee /etc/sysconfig/iptables
/sbin/service iptables save
service iptables restart
# Stop
--------------------------------------------------------------------------------------
Phase 4: Login to FreePBX Website
---------------------------------------------------------------------------------------
1) Login on http://yourserverIPaddress with the details that they provide you via email.
2) Create an Admin Username and Password
3) Login to the Administrator Page for FreePBX with the username and password created
4) Click on the Red Apply Config button on the top
5) Goto Settings - Advanced Settings
6) Change the Asterisk Manager Password then click on the tick and then press apply, ignore the error and do step 6.
Via SSH on the server:
7) vim /etc/amportal.conf look for (AMPMGRPASS) and make password same as in step 5
8) amportal restart
Back in the website:
9) Retry the Apply Config in FreePBX. Should apply fine.
10) Goto Admin - Asterisk Modules and check for cdr_mysql.so under Manually Loaded Modules (this is for CDR to work and Recordings to show)
11) Goto Admin - Module Admin (this is optional)
Uninstall:
Announcements
Call Flow Control
Custom Applications
Digium Addons
iSymphony
Directory
Follow Me
Digium Phones Config
Sipstation
Fax Configuration
---------------------------------------------------------------------------------------
Phase 5: Setup Trunks
---------------------------------------------------------------------------------------
1) Goto www.fnbconnect.co.za and create your FNB Number there or www.nexus.co.za and create a number there. I used FNB for my numbers.
2) Login on http://yourserverIPaddress
3) Go to Connectivity then Trunks and create a Trunk there.
4) SIP Settings for FNB:
Peer Details (Call it FNB-087322XXXX):
host=voice.fnbconnect.co.za
username=087322XXXX
authname=087322XXXX
secret=YYYYYY
type=peer
auth=md5
nat=no
disallow=all
allow=g729
context=from-trunk
insecure=port,invite
timezone=Africa/Johannesburg
trunkfreq=20
trunk=yes
qualify=yes
qualifysmoothing=yes
User Details (User Context must be the FNB Number: 087322XXXX):
secret=YYYYYY (same as secret above)
type=user
context=from-trunk
register string:
087322XXXX:YYYYYY(same as secret above)@voice.fnbconnect.co.za/087322XXXX
Same as the FNB number above. YYYYYY same as the secret above.
Create an Outbound Route - this is needed to dial out.
1) Connectivity - Outbound Routes
2) Give it a name like FNB-087322XXXX
3) Route CID 087322XXXX
4) Create 1 dial pattern that has the +27X. in match pattern
5) Create 1 dial pattern that has the X. in match pattern
6) Choose your FNB-087322XXXX trunk under trunk sequence
Follow my next phases in the next post/reply.
Last edited: