注,所有命令建议逐条执行,不需要的已标出。
1,安装Linux系统
参考:http://www.linuxdiyf.com/linux/19973.html
2,更改root密码
sudo passwd root
3,切换到root用户
sudo -i
4,更新系统源
一定要注意联网同步系统的时间
apt-get update
apt-get update -y(可选)
5,安装依赖
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 libmysqlclient-dev mpg123 libxml2-dev libnewt-dev sqlite3\
libsqlite3-dev pkg-config automake libtool autoconf git subversion unixodbc-dev uuid uuid-dev\
libasound2-dev libogg-dev libvorbis-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp0-dev\
libspandsp-dev libmyodbc
6,重启
reboot
7,安装配置Asterisk
cd /usr/src
在此目录下下载五个文件,已下载好,见附件,后两个为文件夹。可将文件直接复制进相应的目录即可:cp 源文件 目标文件路径
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-12-current.tar.gz
下面两步可能会失败,成功最好,如果失败,附解决办法
git clone https://github.com/akheron/jansson.git
git clone https://github.com/asterisk/pjproject.git
错误如下:
通常是缓存不足造成的,解决方法如下:
前两行的命令,成功的话结果在下面
8,对步骤七所下文件进行编译安装
编译安装DAHDI,如果没有物理硬件的话,可与选择不安装此模块
cd /usr/src
tar xvfz dahdi-linux-complete-current.tar.gz
cd dahdi-linux-complete-*
make all
make install
make config
9,编译安装LIBPRI
如果没有物理硬件的话可以不安装此模块
cd /usr/src
tar xvfz libpri-current.tar.gz
cd libpri-*
make
make install
10,编译安装pjproject
cd /usr/src/pjproject
./configure --enable-shared --disable-sound --disable-resample --disable-video –disable- opencore-amr
make dep
make
make install
11,编译安装jansson
cd /usr/src/jansson
autoreconf -i
./configure
make
make install
12,编译安装Asterisk
cd /usr/src
tar xvfz asterisk-12-current.tar.gz
cd asterisk-*
./configure
contrib/scripts/get_mp3_source.sh
make menuselect
配置加载的模块,第一个大项全选吧,然后save&exit
编译安装加载配置
make
make install
make config
ldconfig
13,安装Asterisk-Extra-Sounds
下载两个语音包(可以采用命令在线安装),已下载好,见附件
cd /var/lib/asterisk/sounds
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz
tar xfz asterisk-extra-sounds-en-wav-current.tar.gz
rm -f asterisk-extra-sounds-en-wav-current.tar.gz
# Wideband Audio download
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz
tar xfz asterisk-extra-sounds-en-g722-current.tar.gz
rm -f asterisk-extra-sounds-en-g722-current.tar.gz
14,安装配置FreePBX
下载
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-12.0-latest.tgz
解压
tar vxfz freepbx-12-latest.tgz
cd freepbx
15,创建asterisk用户及赋予权限
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
16,配置apach2服务器
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php5/apache2/php.ini
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
service apache2 restart
17,配置ODBC
先
cat >> /etc/odbcinst.ini << EOF
再粘贴进去下面,全部粘贴
[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
EOF
18,配置ODBC连接
注意数据库名和表名
cat >> /etc/odbc.ini << EOF
粘贴进去下面,全部粘贴
[MySQL-asteriskcdrdb]
Description=MySQL connection to 'asteriskcdrdb' database
driver=MySQL
server=localhost
database=asteriskcdrdb
Port=3306
Socket=/var/run/mysqld/mysqld.sock
option=3
EOF
19,配置mysql
export ASTERISK_DB_PW=`dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 - | cut -c2-18`
20,建立mysql的数据库及表
mysqladmin -u root create asterisk
mysqladmin -u root create asteriskcdrdb
也可以进入mysql客户端,直接执行相应命令
21,配置mysq
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;"
22,重启Asterisk并且安装FreePBX
./start_asterisk start
./install_amp --installdb --username=asteriskuser --password=${ASTERISK_DB_PW}
amportal chown
以下会进行联网校验更新,重新加载等操作,可以将联网需联网更新的步骤打断,即一步步执行
amportal a ma installall
amportal a reload
amportal a ma refreshsignatures
amportal chown
23,最后,重启FreePBX
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
amportal restart
24,运行检验
1),检验Asterisk
执行命令
asterisk -vvgc
2),检验FreePBX
打开浏览器,访问http://127.0.0.1,出现FreePBX管理界面,安装FreePBX成功。