查看: 4721|回复: 3
收起左侧

在pcduino上构建自己的电话局–voip服务器

2013-6-25 16:16:45 | 显示全部楼层 |阅读模式
                        现在大家有时会收到电信运营商的推销短信,例如什么彩铃5月每月,一些收费服务。
这里给大家介绍一个开源项目,在pcduino实现免费的电话局,可以在这个电话局上实现彩铃,电话转接,来电显示等等一些功能。
这里采用的用的是3G+asterisk+freepbx方案,这里3G是电话局的物理前端,freepbx是电话局的图形界面操作后台,asterisk就是开源的voip服务器,具体的开发过程如下:
一,下载安装asterisk
1,首先在官网上下载asterisk11源码:下载地址http://www.asterisk.org/downloads
2,安装环境
sudo apt-get install sqlite3 libsqlite3-dev  libxml2-dev g++ ncurses-dev
tar xvfz asterisk-11-current.tar.gz
cd asterisk-*
./configure
contrib/scripts/get_mp3_source.sh
make menuselect
make
make install
make config
安装完成之后可以执行:
asterisk  -vr
来启动asterisk命令模式,如果执行命令提示什么打不开,需要执行asterisk start 来启动服务器。
安装成功后,会有以下命令行模式:
root@ubuntu:/home/ubuntu# asterisk -vr
Asterisk 11.3.0, Copyright (C) 1999 – 2012 Digium, Inc. and others.
Created by Mark Spencer <[email]markster@digium.com[/email]>
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.
=========================================================================
Connected to Asterisk 11.3.0 currently running on ubuntu (pid = 847)
ubuntu*CLI>

2,安装3G上网卡在asterisk上面的驱动
首先要保证3G上网卡可以在pcduino上可以上网,具体的实现过程详见文章
http://www.linksprite.com/cnblog/?p=794
然后要保证你的3G上网卡有打电话的功能,此项目中用的是华为E1752
具体的有哪些型号可以用请参加华为的官网说明。
下面开始安装3G上网卡连接asterisk的驱动:
安装asterisk的3G上网卡的驱动
wget http://кушеев.рф/wp-content/uploads/asterisk-chan-dongle-asterisk11.zip
unzip asterisk-chan-dongle-asterisk11.zip
cd asterisk-chan-dongle-asterisk11
aclocal
autoconf
automake -a
./configure
make
make install
cp etc/dongle.conf /etc/asterisk
安装成功后,下面可以测试可以测试一下:
1》检测物理设备
http://www.linksprite.com/cnblog/wp-content/uploads/2013/06/1-300x13.png

2》给上网卡打电话
http://www.linksprite.com/cnblog/wp-content/uploads/2013/06/2-300x16.png

3》给上网卡发短信
http://www.linksprite.com/cnblog/wp-content/uploads/2013/06/3-300x30.png

可以看到我发的短信的内容。
可以看到3G和asterisk都已经安装完成。
二,安装voip图形化管理界面freepbx
1,安装依赖文件
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 libmysqlclient15-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git subversion
这里会提示linux-headers-`uname -r`这个命令的包找不到,没有关系,下面将会为你解决这个问题。
2,安装PearDB
pear install db
这里会提示WARNING: "pear/DB" is deprecated in favor of "pear/MDB2",可以忽略这个警告
安装后reboot重启一下。
3,安装iksemel
[b]wget https://iksemel.googlecode.com/files/iksemel-1.4.tar.gz[/b]tar xf iksemel-1.4.tar.gz
cd iksemel-1.4
./configure
make
make install
4,安装DAHDI
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
tar xvfz dahdi-linux-complete-current.tar.gz
cd dahdi-linux-complete-2.6.1+2.6.1
make all
make install
make config
当make all的时候会提示你没有安装kenral源码,然后就打印出错误信息,下面就介绍如果解决这个问题。
出现这个错误的主要原因是我们开发的内核源码没有提供安装包,只要我们把内核源码放在指定位置就可以了,但是源码有600M,很显然我们不能放到板子上,如果是用的是531的系统,那就恭喜你,你直接拷贝过来就行了。
为了解决空间问题,我们可以把在X86上搭建NFS服务器,把源码挂载到板子上。具体的在搭建NFS服务器的步骤我就不介绍了。
首先在板子上安装nfs文件支持。
sudo apt-get intall nfs-common
然后执行命令,挂载NFS网络文件系统。
root@ubuntu:/home/ubuntu# mount -t nfs -o nolock 192.168.3.115:/usr/src/linuxsunxi /lib/modules/3.4.29+/build/
http://www.linksprite.com/cnblog/wp-content/uploads/2013/06/4-300x77.png


挂载成功后需要在pcduino上配置,编译源码,比较慢,大概3个小时的样子。由于需要编译生成uImage,需要mkimage。这里不能把X86的拷贝过来直接用,需要在pcduino上编译生成ARM架构的
然后拷贝到/usr/bin目录下。
由于我们的需要用到源码对应的内核,所以需要把内核和驱动都换掉,具体的不知道怎么的换,请参考我前面的帖子《pcduino内核开发指南》。换驱动比较简单。在make uImage之后,执行
make  modules_install install就可以了。换掉内核和驱动之后重启一下。
5,安装libpri

wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
tar xvfz libpri-1.4-current.tar.gzcd libpri-1.4.14
make
make install
6,安装Asterisk-Extra-Sounds
cd /var/lib/asterisk/soundswget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-gsm-current.tar.gz
tar xfz asterisk-extra-sounds-en-gsm-current.tar.gz
rm asterisk-extra-sounds-en-gsm-current.tar.gz
7,安装配置freepbx
export VER_FREEPBX=2.11cd /usr/src
svn co http://www.freepbx.org/v2/svn/freepbx/branches/${VER_FREEPBX} freepbx
cd freepbx
[b][b]adduser asterisk --disabled-password --no-create-home --gecos "Asterisk User"[/b][/b]chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib/asterisk
mkdir /var/www/html
chown -R asterisk. /var/www/
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php5/apache2/php.inicp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
service apache2 restart
配置数据库
export ASTERISK_DB_PW=amp109 mysqladmin -u root create asterisk
mysqladmin -u root create asteriskcdrdb
mysql -u root asterisk < SQL/newinstall.sql
mysql -u root asteriskcdrdb < SQL/cdr_mysql_table.sql
设置数据库
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;"
开始安装freepbx
./start_asterisk start./install_amp --webroot /var/www/freepbx
amportal a ma installall
amportal a reload
./install_amp --username=asteriskuser --password=$ASTERISK_DB_PW --webroot /var/www/freepbx
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
amportal start
cd /etc/asteriskrm ccss.conf confbridge.conf features.conf sip.conf iax.conf logger.conf extensions.conf sip_notify.conf
现在可以在win7上打开http://192.168.3.114/admin/config.php这个网址,前面的IP就是pcduino的IP。
如果出现错误,请检测两个地方:
第一,这是基于web服务器的网页,检测web服务器的状态。
/etc/init.d/apache2 status
第二,检测web服务器的目录是不是/var/www/freepbx/
http://www.linksprite.com/cnblog/wp-content/uploads/2013/06/5-300x143.png
这就是登录界面,选择管理员,这里可能你设置的用户名和密码会失效,直接用户名和密码都是admin就可以了,下面是登录进去的界面。
http://www.linksprite.com/cnblog/wp-content/uploads/2013/06/6-300x285.png
如果你对freepbx很熟悉,这个你应该会感觉很亲切。这里为止服务器已经搭建好了,你可以去设置你想要的功能。前提条件是对freebpx比较熟,下面一篇文章介绍一个入门,教大家设置彩铃。










                                       

回复

使用道具 举报

2013-6-26 17:04:20 | 显示全部楼层
好东西,谢谢。
回复 支持 反对

使用道具 举报

2013-9-12 17:20:01 | 显示全部楼层
好东西,谢谢。
回复 支持 反对

使用道具 举报

2014-4-9 19:44:48 | 显示全部楼层
感谢楼主分享
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

热点推荐

关注我们,了解更多

官方微信

服务时间:10:00-16:00

13714503811

公司地址:深圳市龙岗区南湾街道东门头路8号

Copyright © 2012-2020 Powered by 树莓派论坛 2019.4  粤ICP备15075382号-1
快速回复 返回列表 返回顶部