软件 |
版本 |
文件名称 |
备注 |
|||||||||||||||||||||||||||||
CentOS |
6.5 |
CentOS-6.5-i386-bin-DVD1.iso |
||||||||||||||||||||||||||||||
Asterisk |
11.0.1 |
|||||||||||||||||||||||||||||||
Asterisk 运行需求(列表即是按照顺序,可选安装根据个人需求而定)
|
||||||||||||||||||||||||||||||||
VMware |
10 |
有可能无法识别PCI设备 |
说明:本文档中所有黑体均表示CentOS下的相关终端命令。
1. 下载CentOS 6.5
国内高速下载
http://www.centoscn.com/plus/download.php?open=2&id=2196&uhash=4882f31be69e25a9c044f020
2. Windows XP/2003/Win7上用VMware 10安装CentOS 6.5
虚拟机安装部分略过
3. 下载 Asterisk,dahdi,libpri,libsrtp。
切换至文件目录存放目录 /usr/src/
su -
cd /usr/src
4. 下载Asterisk 11.0.1
wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-11.0.1.tar.gz
5. 下载dahdi
wget http://downloads.Asterisk.org/pub/telephony/dahdi-linux-complete/releases/dahdi-linux-complete-2.10.0.1+2.10.0.1.tar.gz
6. 下载libpri
wget http://downloads.Asterisk.org/pub/telephony/libpri/releases/libpri-1.4.11.4.tar.gz
7. 下载libsrtp
wget http://sourceforge.net/projects/srtp/files/srtp/1.4.4/srtp-1.4.4.tgz/download
8. 安装相关的依赖软件
yum -y install kernel-devel gcc make gcc-c++ libxml2-devel pkgconfig zlib-devel
yum -y install openssl-devel ncurses-devel autoconf automake libtool zip unzip
yum -y install sqlite-devel sqlite3-ruby
9. tar -xzvf asterisk-11.0.1.tar.gz
10. tar �Cxzvf dahdi-linux-complete-2.10.0.1+2.10.0.1.tar.gz
11. tar -xzvf libpri-1.4.11.4.tar.gz
12. tar -xzvf srtp-1.4.4.tgz
13. 编译srtp,dahdi,libpri,Asterisk (注意编译的顺序)
------------------------------------------------------------------------------------------------------------------------------------------------
编译srtp
cd /usr/src/srtp
CFLAGS="-Wall-O4 -fexpensive-optimizations -funroll-loops -fPIC"
./configure --prefix=/usr
make
vi /root/.bash_profile
修改PATH=$PATH:$HOME/bin为 PATH=$PATH:$HOME/bin:.
su -
cd/usr/src/srtp
否则make runtest报错:rtpw_test.sh:line 27: rtpw: command not found
makeruntest
makeinstall
make clean
-----------------------------------------------------------------------------------------------------------------------------------------------
编译dahdi
cd ../dahdi-linux-complete-2.5.0.2+2.5.0.2
makeall
连接无法更新解决方案:
sudo fc-cache -fv 2>&1 | grep failed| cut -f1 -d":" | xargs -i sudo touch {} && sudo fc-cache �Cfv
出错处理:(务必对应当前的CentOS版本)
You do notappear to have the sources for the 2.6.32-431.el6.i686 kernel installed.
uname -r
2.6.32-431.el6.i686
cd /lib/modules/
看到下面有 2.6.32-431.el6.i686 2.6.32-504.1.3.el6.i686(这个是我执行yum update出现的,同样启动菜单里面也会多出这一项内核版本启动选项)
解决办法1:
使用ISO镜像安装对应的rpm安装包,至于如何挂载详解我的另一篇文章:CentOS配置Asterisk + FreePBX + mysql +PHP 一些问题的说明
进入kernel-devel-2.6.32-431.el6.i686.rpm对应的目录,执行以下的命令
rpm -i kernel-devel-2.6.32-431.el6.i686.rpm
解决办法2:
yum -y install kernel-devel-`uname -r`
make install
-----------------------------------------------------------------------------------------------------------------------------------------------
安装dahdi(可以根据dahdi文件下的ReadMe提示进行安装)
make all
make install
make config
屏幕提示:(已安装硬件)
/sbin/chkconfig--add dahdi
DAHDI hasbeen configured.
List ofdetected DAHDI devices:
pci:0000:03:07.0 wctdm24xxp+ d161:8005 Wildcard TDM410P提示检测到硬件Wildcard TDM410P
run'dahdi_genconf modules' to load support for only
the DAHDIhardware installed in this system. By
defaultsupport for all DAHDI hardware is loaded at
DAHDI start.
若出现提示:(未安装硬件)
List of detected DAHDI devices:
No hardware found
则表示需要对应的硬件
-----------------------------------------------------------------------------------------------------------------------------------------------
编译libpri
cd ../libpri-1.4.11.4
make
make install
-----------------------------------------------------------------------------------------------------------------------------------------------
编译Asterisk
make menuconfig前置包安装
yum -y install ncurses-devel
cd asterisk-11.0.1
contrib/scripts/install_prereq install
注意:如要mp3,需要执行下面操作
yum-y install subversion
contrib/scripts/get_mp3_source.sh
注意:如要ilbc codec,需要执行下面操作
contrib/scripts/get_ilbc_source.sh
cdcodec/ilbc/
看到里面只有几个文件
extract-cfile.awkrfc3951.txt
拷贝 http://ilbcfreeware.org/documentation/extract-cfile.txt内容到extract-cfile.awk
awk -f extract-cfile.awk rfc3951.txt
这将在这个目录下面产生几十个文件。
cd ../../
./configure --with-bluetooth
make menuconfig
(add-on 选择chan_mobile, format_mp3, 其余的根据需要自己选择 )
准备工作完成后进入asterisk正式编译步骤
make
make install
make config
make samples
(生成Asterisk相关的例子配置文件位于/etc/Asterisk/文件夹中)
-----------------------------------------------------------------------------------------------------------------------------------------------
14. 启动dahdi
service dahdi restart
15. 启动asterisk
service asterisk restart
16. 查看端口5060使用情况来判定asterisk服务是否已经启动
netstat -na|grep 5060
udp 0 0 0.0.0.0:5060 0.0.0.0:*
17. 添加AMR codec的支持(可选,因为用的1.8.0的版本存在不兼容的情况,目前暂时没有添加该功能)
开始配置Asterisk前,需要添加一些工具。用到工具有ARM-NB codec编码方式支持移动电话从而能得到最好的音质。
先停止Asterisk服务
service asterisk stop
进入/usr/src文件夹,下载Asterisk-amr补丁。
cd /usr/src/
wget http://sourceforge.net/projects/asterisk-amr/files/1.8.0-rc2_asterisk_amr_patch.diff/download
cd asterisk-11.0.1/ && patch -p2< ../1.8.0-rc2_asterisk_amr_patch.diff
cd ../asterisk-11.0.1/codecs/amr/
从3GPP网站下载AMR codec
wget http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-700.zip
unzip -j 26104-700.zip
unzip -j 26104-700_ANSI_C_source_code.zip
回到asterisk-11.0.1目录
cd ../.. /..
wget http://sourceforge.net/projects/asterisk-amr/files/1.8.0-rc2_crypto_offer.diff/download
cd asterisk-11.0.1/&& patch -p2 < ../1.8.0-rc2_crypto_offer.diff 补丁未打成功
切换至asterisk-11.0.1/目录
cd asterisk-11.0.1
重新编译asterisk-11.0.1
make ; make install
启动asterisk
asterisk -rvvvvvvvvvvv
core show codecs
2048 (1<< 11) (0x800) audio g726 (G.726 RFC3551)
4096 (1<< 12) (0x1000) audio g722 (G722)
8192 (1<< 13) (0x2000) audio amr (AMR NB)
-----------------------------------------------------------------------------------------------------------------------------------------------
18. 以下为可选步骤
19. 设置runlevel 3
编辑/etc/inittab(根据需要配置为自己需要的启动方式,我未更改此选项,3表示console)
id:3:initdefault:
20. 安装vncserver
yum -y install vnc
------------------------------------------------------------------------------------------------------------------------------------------------
每小时reboot一次:
cd /etc/cron.hourly/
touch reboot
chmod 777 reboot
#!/bin/sh
/sbin/reboot
------------------------------------------------------------------------------------------------------------------------------------------------
关闭Ubuntu防火墙
# service iptables save
#service iptables stop
#chkconfig iptables off
------------------------------------------------------------------------------------------------------------------------------------------------
21. 启用amr codec(17步成功后设置)
vi sip_general_additional.conf
修改
disallow=all
allow=ulaw
allow=alaw
为
allow=all
可选步骤到此为止
22. 重新启动Asterisk
service asteriskrestart
23. 安装FreePBX-2.11.0
------------------------------------------------------------------------------------------------------------------------------------------------
1) 查看系统中是否缺少以下服务,缺少将用 ”yum install服务名“来安装
安装bind,httpd,sendmail,mysql,mysql-server
yum -y install bind httpdsendmail mysql mysql-server
------------------------------------------------------------------------------------------------------------------------------------------------
2) 禁用Selinux
说明:这个是安全级别和防火墙的东西,启用的话会影响我们的freepbx的安装。
vi /etc/sysconfig/selinux
把 SELINUX=enforcing
改成 SELINUX=disabled
保存:wq
重启
reboot
3) 安装需要的扩展包
yum -y install e2fsprogs-devel keyutils-libs-devel krb5-devel libogg libselinux-devel libsepol-devel libxml2-devel
yum -y install libtiff-devel gmp php-pear php-pear-DB php-gd php-mysql php-pdo php-posix kernel-devel ncurses-devel audiofile-devel
yum -y install libogg-devel openssl-devel mysql-server mysql-devel zlib-devel perl-DateManip sendmail-cf sox
------------------------------------------------------------------------------------------------------------------------------------------------
4) 安装 phpmyadmin(可选)
------------------------------------------------------------------------------------------------------------------------------------------------
① 下载phpMyAdmin-2.11.11.2-english.zip
wget http://jaist.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/2.11.11/phpMyAdmin-2.11.11-english.zip
unzip phpMyAdmin-2.11.11-english.zip
mv phpMyAdmin-2.11.11-english phpmyadmin
chown asterisk:asterisk -R phpmyadmin/
chmod777 -R phpmyadmin/
mv phpmyadmin /var/www/html
cd /var/www/html/phpmyadmin/libraries/
vi config.default.php
$cfg['blowfish_secret']= 'xxxx';
$cfg['Servers'][$i]['password']= 'password';
service mysqld start
mysqladmin -u root password "password"
vi /etc/httpd/conf/httpd.conf
加入 ServerName asterisk1101
修改
User asterisk
Group asterisk
chmod 777 /var/lib/php/session/
chmod 777 -R /var/lib/php/session/* ――有可能提示没有这个目录,不用理会
service mysqld restart
/etc/init.d/httpd restart
在浏览器中输入后面的网址http://asterisk1101/phpmyadmin/测试访问结果(我登录是用http://localhost/ phpmyadmin/,或者是http://你的IP/ phpmyadmin/,似乎ServerName没有解析对)
排错:
Forbidden
You don't have permission toaccess /phpmyadmin/ on this server.
原因1:没有关闭SE Linux,或者关闭了SE Linux配置但是没有reboot Linux
原因2:phpmyadmin的owner不是asterisk,mode不是777
-------------------------------------------------------------------------------------------------------------------------------------------
② 安装lame
wget http://sourceforge.net/projects/lame/files/lame/3.99/lame-3.99.5.tar.gz/download或
wget http://nchc.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar -zxvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure
make
make install
5) 安装FreePBX
这个必须在asterisk 完全安装后才能装
下载地址:http://www.freepbx.org(官方)
wgethttp://mirror.freepbx.org/freepbx-2.11.0.38.tgz
tar-xvf freepbx-2.11.0.38.tar.gz
cd freepbx-2.11.0.38
./start_asteriskstart
PS:把mysql密码设置为空,方便运行以下命令(建立相关asterisk 数据库)
/etc/init.d/mysqld start
mysql -u root �Cp password
mysql>set password for root@localhost=password('');
mysql>exit;
mysql -u root (测试可以通过空口令登录)
mysqladmin create asterisk
mysqladmin create asteriskcdrdb
mysql asterisk < SQL/newinstall.sql
mysql asteriskcdrdb < SQL/cdr_mysql_table.sql
mysql �Cu root
mysql> GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY'password';
mysql> GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY 'password';
mysql> flush privileges;
mysql> quit;
把mysql密码设置不能为空
mysqladmin -u root password "password"
再运行以下命令
./install_amp --username=root --password=password //这里我的mysql用名为root,密码是password
提示:PEAR must be installed (requires DB.php)
则执行pear install DB即可。
以下是终端的一些输出提示:
Checking for PEAR DB..OK
Checking for PEARConsole::Getopt..OK
Using username: root
Using password: ********
Checking user..OK
Checking if Asterisk isrunning..running with PID: 4173..OK
Checking for/etc/amportal.conf../etc/amportal.conf does not exist, copying defaultCreatingnew /etc/amportal.conf
Enter your USERNAME to connect tothe 'asterisk' database:
[root]Enter your PASSWORDto connect to the 'asterisk' database:
[passw0rd]
Enter the hostname of the 'asterisk' database:
[localhost]
Enter a USERNAME to connect to the Asterisk Manager interface:
[admin]
Enter a PASSWORD to connect to the Asterisk Manager interface:
[amp111]
Enter the path to use for your AMP web root:
[/var/www/html]
Enter the IP ADDRESS or hostname used to access the AMP web-admin:
[xx.xx.xx.xx] asterisk1101
Enter a PASSWORD to perform call transfers with the Flash Operator Panel:
[passw0rd]
Use simple Extensions [extensions] admin or separate Devices and Users[deviceanduser]?
[extensions]
Created /var/lib/asterisk/bin
Enter directory in which to store super-user scripts:
[/usr/local/sbin]
# echo "/usr/local/sbin/amportalstart" >> /etc/rc.local
chkconfig httpd on
chkconfig mysqld on
OK 安装完成重启
reboot
6) 后续一些权限修改
-------------------------------------------------------------------------------------------------------------------------------------------
chmod 777/var/www/html -R
cd/var/lib/asterisk/
chmod 777 bin
chmod -R 777bin/*
chmod 777/var/lib/php/session/
chmod 777 -R/var/lib/php/session/*
-------------------------------------------------------------------------------------------------------------------------------------------
登录至FreePBX测试
http://192.168.x.xxx (你的本机IP地址)
用户名:admin
口令:admin
第一次登陆管理界面,需要进行配置。
现在可以创建SIP号码。
-------------------------------------------------------------------------------------------------------------------------------------------
一些排错信息:
-------------------------------------------------------------------------------------------------------------------------------------------
日志:
tail -f /var/log/httpd/access_log
tail -f /var/log/httpd/error_log
/var/log/mysqld.log
asterisk日志
tail -f /var/log/asterisk/full
tail -f /var/log/asterisk/freepbx.log
-------------------------------------------------------------------------------------------------------------------------------------------
排错:检查数据访问
mysql -h localhost -u root -p password
use asterisk;
-------------------------------------------------------------------------------------------------------------------------------------------
排错:
http://192.168.x.xxx/phpmyadmin/
-------------------------------------------------------------------------------------------------------------------------------------------
提示:
/etc/amportal.conf
控制谁能用amp管理协议访问asterisk服务器
/etc/asterisk/manager.conf
7) FreePBX忘记口令
修改口令为freepbx后,登录FreePBX Administration页面并修改口令。