前言
有一说一,asterisk的环境是开源项目中难得比较好搭的环境,不必担心,错啥少啥搜索一下补齐就好,有的包版本编译出错,也别深究换个版本重新编就完事了。
个人环境
ubuntu16.04(桌面版) 装的是asterisk16 pjsip2.6
安装步骤
1.基础包安装(就照着官方文档装,一个都别漏,装不成功一直搜原因,千万别跳步,一般ubuntu自带的软件库都会有,只是名字需要变一下比如包的名字后面加个-dev)
官方需要包:https://wiki.asterisk.org/wiki/display/AST/System+Libraries
我残留的安装记录(残留是重点,最重要的还是对好官方文档)
libjansson包:
wget http://www.digip.org/jansson/releases/jansson-2.13.1.tar.gz
tar -zxvf jansson-2.13.1.tar.gz
./configure --prefix=/usr --disable-static
make
make install
libsqlite3:
apt-get install sqlite3
libxml2:
sudo apt-get install libxml2-dev
sudo apt-get install libxml2
libxslt:
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.28.tar.gz
tar -xvf libxslt-1.1.28.tar.gz
cd libxslt-1.1.28
./configure --build=arm-pc-linux # x86架构的build一般为i686-pc-linux
make
sudo make install
ncurses:
sudo apt-get install libncurses5-dev
uuid:
Sudo apt-get install uuid
2.核心包安装
DAHDI
Wget https://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
[root@server src]# cd dahdi-linux-complete-2.X.Y+2.X.Y
[root@server dahdi-linux-complete-2.X.Y+2.X.Y]# make
[root@server dahdi-linux-complete-2.X.Y+2.X.Y]# make install
[root@server dahdi-linux-complete-2.X.Y+2.X.Y]# make install-config
PJSIP(2.6不行就换2.3,版本那么多都能用):
Wget https://github.com/pjsip/pjproject/archive/refs/tags/2.6.tar.gz
./configure
Make dep
make
make install
libsrtp:
https://blog.csdn.net/cgs1999/article/details/89704359
SPEEX(去下面这个链接找两个安装包):
https://www.speex.org/downloads/
后面都同理 ubuntu有拿Ubuntu的 没有自己去git找
sudo apt-get install libsamplerate-dev
sudo apt-get install libcurl3-dev
apt-get install libvorbis-dev
apt-get install libogg-dev
apt-get install libical-dev
apt-get install libiksemel-dev
apt-get install libneon27-dev
sudo apt-get install libgmime-2.6-dev
apt-get install libunbound-dev
apt-get install libsrtp-dev
apt install libncurses5-dev uuid-dev libjansson-dev libxml2-dev libsqlite3-dev
sudo apt install libedit-dev
3.编译asterisk
从这里找一个你想要的版本https://www.asterisk.org/downloads/,wget一下解压一下进去安装
编译可以参考这篇:
https://cxymm.net/article/tugouxp/120494909
注意make samples要执行,不然会漏掉配置文件的生成。
配置通话:
参考这篇:
http://www.asterisk.org.cn/asterisk-cn-doc/doc/295240.html
注意配置文件中的//注释都要删掉,不然pjsip的进程无法正常运行
配置实现分机拨打100 得到回复hello world
pjsip.conf文件的配置
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
[6002]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
auth=6002
aors=6002
[6002]
type=auth
auth_type=userpass
password=aaa
username=6002
[6002]
type=aor
max_contacts=1
extensions.conf的配置
[from-internal]
exten = 100,1,Answer()
same = n,Wait(1)
same = n,Playback(hello-world)
same = n,Hangup()
重启生效配置:
asterisk -rx “core restart now”
asterisk -rvvvvv
其余参考文档:
https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions
http://www.jian-jie.com/a/jszc/ji-shu-fu-wu/2018/1101/asterisk-pjsip-centos.html
http://www.ctiforum.com/news/guonei/558289.html