Ubuntu18.04 安装Asterisk16.10 + FreePBX15.0

2020-12-03 11:33:19 浏览数 (1)

Ubuntu18.04 安装Asterisk16.10 FreePBX15.0

1.首先需要先更新一下ubuntu的apt源

代码语言:javascript复制
cp /etc/apt/sources.list /etc/apt/sources.list.bak
echo > /etc/apt/sources.list
vim /etc/apt/sources.list
#然后将下面的内容粘贴到sources.list文件中
deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe

还需要添加ppa源,因为在第二步安装依赖的时候需要安装php5.6,如果不添加的话apt-get install的时候会提示找不到该包。

代码语言:javascript复制
apt-get install -y language-pack-en-base
LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
add-apt-repository ppa:ondrej/php

执行更新镜像列表.

代码语言:javascript复制
apt update

2.安装依赖包

代码语言:javascript复制
apt-get install -y build-essential linux-headers-`uname -r` openssh-server apache2 mysql-server mysql-client bison flex php5.6 php5.6-curl php5.6-cli php5.6-xml php5.6-mysql php-pear php5.6-gd libapache2-mod-php5.6 curl sox libncurses5-dev libssl-dev libmysqlclient-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libicu-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp0-dev libspandsp-dev sudo subversion libtool-bin python-dev

在安装mysql的时候会有几次提示设置密码的窗口弹出,在这里我们直接回车即可,默认设置空密码,避免后续安装asterisk的时候出现问题 在安装php5.6、php-pear、libssl-dev、libxml2-dev、libicu-dev、libneon27-dev这几个包的时候下载速度会比较的慢

安装完了之后,将php切换到php5.6。

代码语言:javascript复制
sudo a2dismod php7.1
sudo a2enmod php5.6
sudo service apache2 restart
sudo update-alternatives --set php /usr/bin/php5.6

3.安装nodejs

代码语言:javascript复制
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs

4.安装及配置Asterisk

下载源码包

代码语言:javascript复制
cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz

编译安装dahdi

代码语言:javascript复制
tar -zxvf dahdi-linux-complete-current.tar.gz
cd dahdi-linux-complete*
make all
make install
make config
tar -zxvf tar -zxvf libpri-current.tar.gz
cd libpri*
make
make install

编译安装Asterisk

代码语言:javascript复制
tar -zxvf asterisk-16-current.tar.gz 
cd asterisk*
contrib/scripts/get_mp3_source.sh
contrib/scripts/install_prereq install
#这里有个弹窗需要用户填入国家的电话代码,中国为86
./configure  --with-pjproject-bundled --with-jansson-bundled
make menuselect
#这里会出现一个弹窗,会询问你需要启用哪些模块,按回车则启用对应模块,默认即可
make
make install
make config
ldconfig
update-rc.d -f asterisk remove

5.安装和配置FreePBX

创建Asterisk用户并设置基本文件权限

代码语言:javascript复制
useradd -m asterisk
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib/asterisk
rm -rf /var/www/html

修改apache2配置文件

代码语言:javascript复制
sed -i 's/(^upload_max_filesize = ).*/120M/' /etc/php/5.6/apache2/php.ini
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak
sed -i 's/^(User|Group).*/1 asterisk/' /etc/apache2/apache2.conf
sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
service apache2 restart

配置ODBC

代码语言:javascript复制
#编辑/etc/odbcinst.ini并添加以下内容。
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1

#编辑或创建/etc/odbc.ini并添加以下部分。
[MySQL-asteriskcdrdb]
Description=MySQL connection to 'asteriskcdrdb' database
driver=MySQL
server=localhost
database=asteriskcdrdb
Port=3306
Socket=/var/run/mysqld/mysqld.sock
option=3

正式编译安装FreePBX

代码语言:javascript复制
cd /usr/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-15.0-latest.tgz
tar vxfz freepbx-15.0-latest.tgz
cd freepbx
touch /etc/asterisk/ari.conf
./start_asterisk start
./install -n

重新启动apache

代码语言:javascript复制
a2enmod rewrite
service apache2 restart

6.最后在浏览器输入freepbx服务器的ip地址就可以看到后台界面了

0 人点赞