Cài đặt Freepbx 12 và Asterisk 13 trên Centos 6.5

Cài đặt Freepbx 12 và Asterisk 13 trên Centos 6.5

1. Cài đặt Centos 6.5
- Cài đặt bình thường. Chọn chế độ cài đặt Basic Server.

2. Initial System Setup

2.1. Disable selinux
 - vi /etc/sysconfig/selinux
   sửa dòng sau: SELINUX=disabled
 - Restart server: reload
 - Kiểm tra trạng thái selinux:  
   sestatus

2.2. Update Your System
  yum -y update
  yum groupinstall core
  yum groupinstall base

2.3. Install Additional Required Dependencies
yum 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 newt-devel libxml2-devel libtiff-devel audiofile-devel gtk2-devel subversion kernel-devel git subversion kernel-devel php-process crontabs cronie cronie-anacron wget vim php-xml uuid-devel libtool sqlite-devel

2.4. 
IPTables
You must disable the default iptables.  You can re-enable it later, once you have made the appropriate changes.  Information on iptables can be found with a quick Google search.  If iptables is left running, it will (at very least) block you from accessing the web interface.
See the current status:
chkconfig iptables --list
Disable iptables:
chkconfig --level 0123456 iptables off
Stop the service (this skips rebooting again):
service iptables stop

2.5 
Auto Start MySQL

You must have mysql running for freepbx to operate normally.  You need to set it to start at boot time. with the following command:

chkconfig --level 345 mysqld on
Then start mysqld if you don't plan on rebooting during the installation phase:
service mysqld start

2.6. 
Auto Start Apache
You will want Apache running, so you can access the FreePBX admin interface,  You need to set it to start at boot time. with the following command:
chkconfig --level 345 httpd on
Then start apache if you don't plan on rebooting during the installation phase:
service httpd start

2.7. 
Install PearDB
pear channel-update pear.php.net
pear install db-1.7.14
You may receive a warning:
WARNING: "pear/DB" is deprecated in favor of "pear/MDB2"
At this time it is safe to ignore that message

2.8. Reboot server
reboot

3. 
Install Dependencies for Google Voice (If needed/wanted)

3.1. 
Install iksemel
cd /usr/src
wget https://iksemel.googlecode.com/files/iksemel-1.4.tar.gz
tar xf iksemel-*.tar.gz
cd iksemel-*
./configure
make
make install

4. 
Add the Asterisk User
adduser asterisk -M -c "Asterisk User"

5. 
Install and Configure Asterisk
5.1. 
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
git clone https://github.com/akheron/jansson.git
wget http://www.pjsip.org/release/2.2.1/pjproject-2.2.1.tar.bz2

5.2. 
Compile and install DAHDI and LibPRI
If you don't have any physical hardware you don't need to run these commands, however, it is still suggested to compile the modules, to allow you to add hardware later.
cd /usr/src
tar xvfz dahdi-linux-complete-current.tar.gz
tar xvfz libpri-1.4-current.tar.gz
rm -f dahdi-linux-complete-current.tar.gz libpri-1.4-current.tar.gz
cd dahdi-linux-complete-*
make all
make install
make config
cd /usr/src/libpri-1.4.*
make
make install

5.3. 
Compile and install pjproject
If you are doing this on a 64 bit system, please note that you MUST set the following during configure:
--libdir=/usr/lib64

cd
 /usr/src
tar -xjvf pjproject-2.2.1.tar.bz2
cd pjproject-2.2.1
CFLAGS='-DPJ_HAS_IPV6=1' ./configure --prefix=/usr --enable-shared --disable-sound
  --disable-resample --disable-video --disable-opencore-amr --libdir=/usr/lib
make dep
make
make install
5.4. Compile and Install jansson
If you are doing this on a 64 bit system, please note that you MUST set the following during configure:
--libdir=/usr/lib64

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

5.5. 
Compile and install Asterisk
If you are doing this on a 64 bit system, please note that you MUST set the following during configure:
--libdir=/usr/lib64

cd /usr/src
tar xvfz asterisk-13-current.tar.gz
rm -f asterisk-13-current.tar.gz
cd asterisk-*
contrib/scripts/install_prereq install
./configure --libdir=/usr/lib
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

5.6. 
Install Asterisk-Extra-Sounds
Note that this installs the (8khz) 'wav' soundfiles and G722 (High Definition 'Wideband') audio.
mkdir -p /var/lib/asterisk/sounds
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
# Wideband Audio download G729
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g729-current.tar.gz
tar xfz asterisk-extra-sounds-en-g729-current.tar.gz
rm -f asterisk-extra-sounds-en-g729-current.tar.gz

6. 
Install and Configure FreePBX
6.1. 
Download and extract FreePBX.
wget http://mirror.freepbx.org/freepbx-12.0.3.tgz
tar vxfz freepbx-12.0.3.tgz

6.2. 
Set ownership permissions.
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
mkdir /var/www/html
chown -R asterisk. /var/www/

6.3. 
A few small modifications to Apache.
sed -i 's/(^upload_max_filesize = ).*/120M/' /etc/php.ini
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf_orig
sed -i 's/^(User|Group).*/1 asterisk/' /etc/httpd/conf/httpd.conf
service httpd restart

6.4. 
Configure Asterisk database in MYSQL. 
cd /usr/src/freepbx
export ASTERISK_DB_PW=amp109
mysqladmin -u root create asterisk 
mysqladmin -u root create asteriskcdrdb 

6.5. 
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;"

6.6. 
Restart Asterisk and install FreePBX.
cd /usr/src/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

If you see an error about "Uncaught exception 'RuntimeException' with message 'gpg took too long to run.'" it is safe to run "amportal a ma installall" again.

6.7. Finally, one last mod and start FreePBX.
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
amportal restart

7. 
Start FreePBX
Navigate: 

http://yourlocalipaddress/html or if you prefer http://localhost/admin

8. Install and Setup Commercial Modules

8.1. Enable the FreePBX Commercial yum repos
wget -P /etc/yum.repos.d/ -N http://yum.schmoozecom.net/schmooze-commercial/schmooze-commercial.repo

8.2. 
yum clean all to clean out yum cache so it will find out new RPMs
yum clean all

8.3. 
yum install needed RPMs for Commercial Modules
yum -y install php-5.3-zend-guard-loader sysadmin fail2ban incron ImageMagick

8.4. Restart Apache and Install Sysadmin
service httpd restart
amportal a ma download sysadmin
amportal a ma install sysadmin
9. Troubleshooting Problem

9.1. CDR not working...

I fiddled with this a bit without knowing a huge amount about what was going on with the adaptive CDRs.  Apparently just writing to mySQL is being deprecated, and adaptive CDR is what you want. Who knew.  Anyway: I had to install the mysql connector to ODBC:

yum install mysql-connector-odbc

Then, I made the /etc/odbc.ini file to point to the database that the instructions had created:

[root@pbx asterisk]# cat /etc/odbc.ini

#
# ODBC connection to CDR database
#
[MySQL-asteriskcdrdb]
description     = MySQL-asteriskcdrdb
Trace           = Off
TraceFile       = stderr
Driver          = MySQL
SERVER          = localhost
PORT            = 3306
DATABASE        = asteriskcdrdb
#
socket          = /var/lib/mysql/mysql.sock
option          = 3

 

You can test that you have gotten this far with isql:

isql MySQL-asteriskcdrdb asteriskuser <thepasswordyoupicked-which-might-be-amp109>

SQL>

Type "help" and if you see the cdr (call data records) and cel (channel event logs) databases, then you're pretty far along.

There was no /etc/asterisk/cdr_adaptive_odbc.conf created, so I created one:

[asteriskcdrdb]
connection=asteriskcdrdb
loguniqueid=yes
table=cdr
alias start => calldate

Then a restart and a CLI> cdr show status and an example call showed that it was all working.

9.2. Khi đăng nhập vào giao diện web freepbx gặp lỗi: 
Problem: Security Issue

.htaccess files are disable on this webserver. Please enable them
.
This is a critical issue and should be resolved urgently

Solve:
Open httpd.conf in your favorite text editor (normally in /etc/httpd/conf/httpd.conf)
Look for the context "<Directory "/var/www/html">"
Within that context make sure "AllowOverride" is uncommented and set to "All"

Restart Apache by running:
service httpd restart

Leave a Reply

* Name:
* E-mail: (Not Published)
   Website: (Site url withhttp://)
* Comment:
Type Code