AsteriskAsterisk入门


备注

本节概述了星号是什么,以及开发人员可能想要使用它的原因。

它还应该提到星号内的任何大型主题,并链接到相关主题。由于星号文档是新的,您可能需要创建这些相关主题的初始版本。

Asterisk 14安装在Ubuntu 16.04 LTS上

以sudo身份运行以下bash脚本

#!/bin/bash

# get deps
apt -y install build-essential libncurses5-dev libxml2-dev libsqlite3-dev libssl-dev libsrtp0-dev uuid-dev libjansson-dev

# download
cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-14-current.tar.gz
tar -zxvf asterisk-14-current.tar.gz
rm asterisk-14-current.tar.gz
cd asterisk-14*

# Install pre-requisites
./contrib/scripts/install_prereq install
./contrib/scripts/install_prereq install-unpackaged
./contrib/scripts/get_mp3_source.sh

# Install
make clean
./configure
make menuselect
make
make install
make samples
make config

# Uncomment and edit the following lines to setup a snakeoil SSL cert
#mkdir /etc/asterisk/keys
#cd contrib/scripts/
# Change the following IP address to you server IP address 
#./ast_tls_cert -C 192.168.254.2 -O "My company name" -d /etc/asterisk/keys

# Edit the following to adjust locale of sounds
cd /var/lib/asterisk/sounds
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en_GB-wav-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en_GB-wav-current.tar.gz

tar -xzf asterisk-core-sounds-en_GB-wav-current.tar.gz
tar -xzf asterisk-extra-sounds-en_GB-wav-current.tar.gz
rm *.tar.gz
 

CentOS 6.X上的星号安装

Asterisk是一个用于构建通信应用程序的开源框架。您可以将它用于以下任何一项:

  1. IP PBX系统
  2. VoIP网关
  3. ISDN / 3G IVVR

这是在Redhat / centos上逐步安装asterisk 1.8 (或者你可以为最新版本做)的简要说明(对于其他linux版本,命令类似:))。

步骤1:从以下位置获取星号源代码文件: Asterisk下载

第2步:以root身份登录并运行命令:

yum update

yum install joe gcc-c++ gcc-gnat gcc-g77 gcc-objc gcc autoconf automake bison flex cvs rpm-build openssl-devel SDL-devel 

yum install redhat-rpm-config sox sox-devel curl-devel  ncurses-devel net-snmp net-snmp-libs net-snmp-utils libxml2-devel gd-devel libpng-devel doxygen

yum install mysql-server mysql-devel // if needed 
chkconfig --level 345 mysqld on
service mysqld start
yum install php php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-pecl-apc php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy //optional for web application 

yum install bind caching-nameserver
yum install system-config-date

cd /path/to/asterisk/
make clean
./configure
 

现在环境已准备好安装星号。

make menuselect // here from Add-ons check the app-mysql, cdr-mysql, res-config-mysql
make
make install

make config
chkconfig asterisk on
 

第3步:连接到星号

asterisk -vvvvvvvvvvvvvvvvvvvc
stop now
service asterisk start
 

步骤4:现在在/etc/asterisk/cdr.conf 文件中添加以下内容(动态CDR数据插入到DB)

;csv
[mysql]
usegmtime=yes    ; log date/time in GMT.  Default is "no"
loguniqueid=yes  ; log uniqueid.  Default is "no"
loguserfield=yes ; log user field.  Default is "no"


and add the following in cdr_mysql.conf


[global]
hostname=localhost
dbname=your_asterisk_db
table=cdr
password=your_ast_pass
user=your_ast_user
;port=3306
;sock=/tmp/mysql.sock
;userfield=1
 

步骤5:创建数据库并创建CDR表:

create table cdr( uniqueid varchar(32) NOT NULL default '', userfield varchar(255) NOT NULL default '', accountcode varchar(20) NOT NULL default '', src varchar(80) NOT NULL default '', dst varchar(80) NOT NULL default '', dcontext varchar(80) NOT NULL default '', clid varchar(80) NOT NULL default '', channel varchar(80) NOT NULL default '', dstchannel varchar(80) NOT NULL default '', lastapp varchar(80) NOT NULL default '', lastdata varchar(80) NOT NULL default '', calldate datetime NOT NULL default '0000-00-00 00:00:00', duration int(11) NOT NULL default '0', billsec int(11) NOT NULL default '0', disposition varchar(45) NOT NULL default '', amaflags int(11) NOT NULL default '0' );

第6步:最后重启服务器

现在使用: asterisk -rvvvvv 连接到星asterisk -rvvvvv