Академический Документы
Профессиональный Документы
Культура Документы
Sections:
Asterisk
Changes in this guide include Asterisk 11 which requires at least FreePBX v2.11. Also
cdr_mysql module has been deprecated so FreePBX 2.11 adds support for the ODBC
method. This install guide adds configurations to enable the new method. You can continue to
use the old method for as long as the cdr_mysql module is included in Asterisk and still
functional. It's just no longer being maintained by the people at Asterisk. There are a lot of other
little changes to this guide too numerous to mention.
yum install gcc gcc-c++ wget bison mysql-devel mysql-server php php-mysql
php-process php-pear php-mbstring tftp-server httpd make ncurses-devel
libtermcap-devel sendmail sendmail-cf caching-nameserver sox newt-devel
libxml2-devel libtiff-devel php-gd audiofile-devel gtk2-devel subversion nano
kernel-devel selinux-policy sqlite-devel openssl-devel libuuid-devel libcurl-
devel tzdata
chan_gtalk, chan_motif, and res_xmpp will not compile unless iksemel-devel and it's
dependencies are installed. res_fax_spandsp will not compile unless spandsp dependency is
installed. For CentOS 6, iksemel and spandsp are in the EPEL repository.
Install pear DB
pear install db
Firewall
Check if the firewall (iptables) is enabled by default and if the RHEL v6 default configuration
blocks the FreePBX web GUI. If you know what services/ports are required you can run
system-config-firewall-tui and configure the firewall as required. At a minimum, the
following ports need to be opened:
TCP 80 (www)
TCP 4445 (Flash Operator Panel)
UDP 5060-5061 (SIP)
UDP 10,000 - 20,000 (RTP)
?UDP 4569 (IAX)
Another option is to remove existing settings from the firewall and save.
Selinux
Selinux is not required or recommended. This will create the required file if it does not already
exist. If it already exists set SELINUX=disabled.
nano /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
# SETLOCALDEFS= Check local definition changes
SETLOCALDEFS=0
setenforce 0
TFTP
If you plan to use hardware SIP phones you will probably want to enable the tftp server.
nano /etc/xinetd.d/tftp
change
server_args = -s /var/lib/tftpboot
to
server_args = -s /tftpboot
change
disable=yes
to
disable=no
mkdir /tftpboot
chmod 777 /tftpboot
service xinetd restart
Set Timezone
Copy your timezone from this link or use tzselect
tzselect
PHP Settings
PHP timezone (Optional)
If not set and using php v5.3+ (the version included with RHEL6) it will revert to the default
timezone of the Operating System. FreePBX v2.9+ used to complain about this but FreePBX
v2.11 does not seem to complain so I don't think this setting is necessary anymore and will not
have any consequences.
Memory Limit
The recommended setting is 128M otherwise you may get warnings in FreePBX.
Get FreePBX
Check if this is the latest released version.
cd /usr/src
wget http://mirror.freepbx.org/freepbx-2.11.0.tar.gz
tar zxvf freepbx-2.11*
Do NOT run make samples. If you do it causes some problems you will have to clean up later
on. If you run make samples on an already running FreePBX system you are upgrading it will
break FreePBX. You will then have to manually change back user/password in
/etc/asterisk/manager.conf and probably some other things to get it working again.
cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-11-
current.tar.gz
tar zxvf asterisk-11-current.tar.gz
cd /usr/src/asterisk-11*/
make clean && make distclean
------------------------------------------------------
Make sure to choose the correct version of the following command otherwise Asterisk v11 will
not work properly even thought it may indicate it's running.
-------------------------------------------------------
Asterisk v11 compiles with CFLAGS=-match=native which appears to compile for CPU features
that are not necessarily available on a virtual machine and can cause errors. CFLAGS=-
mtune=native appears to be more compatible across various configurations.
If you want to be more precise and optimal for your cpu you can try cat /proc/cpuinfo then
find your cputype from the gcc cpu options manual and use CFLAGS=-mtune=mycputype. The
downside is that it may not work if you move it to different hardware or if you are using a virtual
machine. If none of those work try CFLAGS=-mtune=generic which is probably the least
optimal but most compatible across different CPU types.
Select format_mp3 in addons if you are going to be doing anything with mp3 files. For
backwards compatibility and fall back in case ODBC doesn't work you may as well install the
deprecated cdr_mysql as well. When you select format_mp3 above as an addon you must run a
script before going any further otherwise the install will fail.
./contrib/scripts/get_mp3_source.sh
FreePBX does not use Asterisk realtime but if you are thinking of using A2Billing then also
select res_config_mysql. Select Core and Extra sounds. I suggest ulaw as they sound better
than gsm especially if you are using ulaw as your default codec. I usually just check both. Then
make sure to press the save button afterwards.
Now compile and install Asterisk. DO NOT run make samples even though the install script
suggests you do. It will cause conflicts with FreePBX config files.
Music on Hold
The Asterisk default moh directory is "/moh" and the Freepbx default moh directory is
"/mohmp3". If we create a symbolic link everything is in one place and can still be found by
both FreePBX and Asterisk.
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
The recommended music on hold behaviour for Asterisk and Freepbx is to only use wav files due
to transcoding overhead and Asterisk stability issues with mp3's. So we want to install mpg123
for converting uploaded mp3's to wav automagically. If you won't be uploading mp3's or don't
want them converted then you probably don't need to install mpg123. If not sure then install.
cd /usr/src
wget http://sourceforge.net/projects/mpg123/files/mpg123/1.16.0/mpg123-
1.16.0.tar.bz2/download
tar -xjvf mpg123*
cd mpg123*/
./configure && make && make install
Freepbx php script cannot find mpg123 by default so we need to create a symbolic link.
ln -s /usr/local/bin/mpg123 /usr/bin/mpg123
MySQL Setup
Before you can do anything to MySQL, you need to make sure it's running: NOTE: If running
RHEL/CENTOS/SL 6 you may need to run this first. mysql_install_db Try without and see if it
starts first.
Now, to configure the databases for freePBX: Note: If mysql admin password is already
configured, add "-p" after the command and enter password when asked. For example,
mysqladmin -p create asterisk
cd /usr/src/freepbx-2.11*/
mysqladmin create asterisk
mysqladmin create asteriskcdrdb
mysql asterisk < SQL/newinstall.sql
mysql asteriskcdrdb < SQL/cdr_mysql_table.sql
They also need to be secured. FreePBX will prompt you for a database username/password
when you do the install. You need to pick that now. We'll assume that you've picked
asteriskuser and amp109 If you use these well know defaults and your server is not firewalled
make sure to set bind-address = 127.0.0.1 further down in this procedure so that MySQL
only listens to localhost.
Security check: It's very important to check that Allow Login With DB Credentials is set to
FALSE in FreePBX Advanced Settings GUI. This is the default setting. If it were set to TRUE and
you were using the default credentials of asteriskuser/amp109 and your FreePBX GUI were
exposed to the internet (ie. the http port), anyone could log into your FreePBX GUI as
administrator using those credentials.
mysql
mysql> \q
Bye
Now, after all of this, you need to pick a root 'mysql' password. We'll make it 'abcdef' just for
this example. You should use a reasonably strong password. If you need to do anything else
with mysql, you'll need to provide this password.
Install FreePBX
/usr/sbin/safe_asterisk
cd /usr/src/freepbx-2.11*/
------------------------------------
For 64bit Operating systems and Asterisk v11 do the following. If you don't do this before
running install_amp you can make 2 changes manually afterwards in
/etc/asterisk/asterisk.confand in FreePBX advanced settings GUI as explained further
down in this procedure:
------------------------------------
Now run the FreePBX install script. Select all defaults for now by hitting the ENTER key at
each prompt.
./install_amp
-----------------------------
64bit OS Check:
For 64bit Operating Systems and Asterisk v11 check that the following is
true: /etc/asterisk/asterisk.conf contains astmoddir =>
/usr/lib64/asterisk/modules and not astmoddir => /usr/lib/asterisk/modules
-----------------------------
Default username is: admin Default pw is: admin Or create your own which is the new
default behaviour on FreePBX v1.11.
chkconfig httpd on
chkconfig mysqld on
Now reboot at which point you should be able to access FreePBX with your web browser. The
very first thing you need to do when you enter the FreePBX Admin GUI for the first time is
Apply Configuration Changes which is a button or bar that shows up at the top of the GUI.
This generates all the *.conf files.
It may also be necessary to reboot again or amportal restart from command prompt.
If you have pre-existing *.conf files in /etc asterisk because your ran make samples or are
upgrading from older versions of Asterisk/FreePBX you will get symlink fail error messages
in FreePBX system staus page. Just delete or rename those files. The next time you Apply
Configuration Changes in the FreePBX GUI the symlinks will be created and the errors
should be gone.
----------------------
64bit OS Check:
If Asterisk v11 on 64bit go into FreePBX GUI>Advanced settings, enable Display Readonly
Settings and Override Readonly Settings. Make sure the Asterisk Modules Dir setting
is /usr/lib64/asterisk/modules and NOT /usr/lib/asterisk/modules.
----------------------
CDR ODBC
This is optional if you selected the deprecated cdr_mysql module in Asterisk menu at compile
time. This is the new recommended way of connecting to the CDR DB. Eventually this will be
required when cdr_mysql no longer works or is no longer included with Asterisk.
nano /etc/odbc.ini
[MySQL-asteriskcdrdb]
Description = MySQL ODBC Driver
Driver = MySQL
Socket = /var/lib/mysql/mysql.sock
Server = localhost
Database = asteriskcdrdb
Option = 3
should result in[MySQL-asteriskcdrdb] Check the following file which Asterisk uses to
connect to the CDR DB
nano /etc/asterisk/res_odbc_additional.conf
[odbccdr]
enabled => yes
dsn => MySQL-asteriskcdrdb
username => asteriskuser
password => amp109
Now using the above username/password, test that it can can connect to the DB via odbc
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| |
| |
+---------------------------------------+
>quit
SQL>
Type quit to exit
If you used a different username/password when setting up cdr DB use those and duplicate file
res_odbc_additional.conf to res_odbc_custom.conf substituting in the different
username/password. Lastly create or add the following. Note connection=odbcdr matches
[odbcdr] in res_odbc_additional.conf. Calldate does not exist any more in
cdr_adaptive_odbc.so. To have the behaviour the same as standard cdr functions we add
the alias start line.
nano /etc/asterisk/cdr_adaptive_odbc.conf
[first]
connection=odbcdr
table=cdr
alias start => calldate
-------------------------------------------------------------------------
Edit Apache web server for GUI access using a port other than 80:
change Listen 80 to Listen 8888 or whatever port you want Change default Apache setting of
AllowOverride None to All so that Apache obeys directives in .htaccess files which by default
prevents viewing sensitive directories on Freepbx.
Setup external sip extensions if going through NAT. Alternatively the new and improved way of
doing this is using the Asterisk SIP settings module
nano /etc/asterisk/sip_nat.conf
nat=yes
externip= or
;externhost=yourdns.com
localnet=192.168.1.0/255.255.255.0
;change the above to whatever your local subnet is
externrefresh=10
When adding external SIP extensions in FreePBX, make sure to change the nat=no default in the
configuration to nat=yes for the extension that will be external. Change that default globally in
the Advanced Settings menu.
nano /etc/asterisk/logger_logfiles_custom.conf
console =>
full => notice,warning,error
logrotate setup
Set up configuration to rotate log files otherwise they get too big after a short while. Create the
following file.
nano /etc/logrotate.d/asterisk
Now add the following to make sure the asterisk log files are rotated weekly along with all the
other log files.
nano /etc/logrotate.d/freepbx
?/var/log/asterisk/freepbx_dbug /var/log/asterisk/freepbx_debug {
missingok
notifempty
sharedscripts
create 0640 asterisk asterisk
postrotate
/usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null
endscript
}
nano etc/asterisk/vm_email.inc
Change the template to what you want the voicemail emails to look like. Check
thathttp://ipaddress_of_Freepbx_server is correct
Root alias
Edit/etc/aliases file and add an email address to forward ‘root’ messages to your personal
email address. At the very bottom you should see a commented example. Copy it and replace
with your email address
root: some_email@somedomain.com
Then run
/usr/bin/newaliases
after saving the file to rebuild the aliases database and have the change take effect. Test if you
can receive emails via sendmail which we are assuming is installed and running as is standard on
RHEL 5 and 6.
cp /etc/postfix/main.cf /etc/postfix/main.cf.original
nano /etc/postfix/main.cf
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = localhost
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 127.0.0.0/8
home_mailbox = Maildir/
nano /etc/my.cnf
[mysqld]
.
.
. skip-innodb
nano /etc/my.cnf
[mysqld]
.
.
.
bind-address = 127.0.0.1
mkdir -p /usr/local/apache/passwd
htpasswd -c /usr/local/apache/passwd/wwwpasswd NewUserName
Apache will prompt you for a new password for the user name you've just indicated New
password: Apache will prompt you to retype your new password Re-type new password: Apache
will then confirm the new user Adding password for user NewUserName Now you have to add
the user name you've just created to the httpd.conf file. To edit that file in nano type:
nano +587 /etc/httpd/conf/httpd.conf
Now do a CTRL-W to search for AuthUser and you'll find the area where all the users are listed
(for example: "maint", your AMP user). If you don't find any try around line 587 right after the
cgi-bin
To delete an Apache user, type in the following and then remove the user from the
httpd.conf file.