1、安装Ubuntu18.04系统
进入root用户,(后续操作都需要在root用户中)
su root
2、下载ubuntu系统中常用的基础软件
openssh-server、vim、net-tools
sudo apt-get install -y openssh-server vim net-tools
3、下载freeswitch编译和运行的编译环境
apt-get update
sudo apt install --yes build-essential pkg-config uuid-dev zlib1g-dev libjpeg-dev libsqlite3-dev libcurl4-openssl-dev libpcre3-dev libspeexdsp-dev libldns-dev libedit-dev libtiff5-dev yasm libopus-dev libsndfile1-dev unzip libavformat-dev libswscale-dev libavresample-dev liblua5.2-dev liblua5.2 cmake libpq-dev unixodbc-dev autoconf automake ntpdate libxml2-dev libpq-dev libpq5 sngrep git libmp3lame-dev libshout3-dev libmpg123-dev sqlite3
4、传输编译vpbx所需的软件
软件包包含的内容如下图所示:
4.1 编译安装fcgi
tar -zvxf fcgi-2.4.1-SNAP.tar.gz
cd fcgi-2.4.1-SNAP
./configure
make
make install
cd ..
4.2 编译安装openssl1.1.1
tar -zvxf openssl-1.1.1t.tar.gz
cd openssl-1.1.1t
./config
make
make install
cd ..
4.3 编译安装spawn-fcgi
tar -zvxf spawn-fcgi-1.6.4.tar.gz
cd spawn-fcgi-1.6.4/
./configure
make
make install
cd ..
4.4 编译安装libxml
tar -zvxf libxml2-2.9.10.tar.gz
cd libxml2-2.9.10/
./configure
make
make install
cd ..
4.5 编译安装zlib
tar -zvxf zlib-1.2.11.tar.gz
cd zlib-1.2.11/
./configure
make
make install
cd ..
4.6 编译安装pcre
tar -zvxf pcre2-10.32.tar.gz
cd pcre2-10.32/
./configure
make
make install
cd ..
4.7 编译安装nginx
4.7.1 编译nginx的基础环境
tar -zvxf nginx-1.16.1.tar.gz
cd nginx-1.16.1
./configure
make
make install
cd ..
4.7.2 更换nginx.conf配置文件
vim /usr/local/nginx/conf/nginx.conf
4.7.2.1 呼叫中心项目配置文件
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#vpbx-cgiweb界面
server {
listen 80;
server_name localhost;
location / {
root /var/www/vpbx;
index login.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ ^/vpbx\.cgi$ {
root /var/www/vpbx;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index login.html;
include fastcgi.conf;
}
location /xml {
root /var/www/vpbx;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index login.html;
include fastcgi.conf;
}
location /record {
alias /usr/local/freeswitch/recordings/;
index index.html;
autoindex on;
autoindex_exact_size off;
}
}
#呼叫中心web界面
server {
listen 8888;
server_name localhost;
location / {
root /var/www/callcenter/dist;
index index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
4.7.2.2 监狱项目配置文件
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8090;
server_name 127.0.0.1;
location / {
root /var/www/dist;
index index.html index.html;
}
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /var/www/vpbx;
index login.html;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ ^/vpbx\.cgi$ {
root /var/www/vpbx;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index login.html;
include fastcgi.conf;
}
location /xml {
root /var/www/vpbx;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index login.html;
include fastcgi.conf;
}
location /record {
alias /usr/local/freeswitch/recordings/;
index index.html;
autoindex on;
autoindex_exact_size off;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
}
4.8 安装Redis
4.8.1 安装Redis基本环境
tar -zvxf redis-4.0.11.tar.gz
mv redis-4.0.11 redis
cd /usr/local/src/redis/
make &make install
cd ..
4.8.2 设置Redis开机自启动
4.8.2.1 创建配置文件夹
mkdir /etc/redis/
cp /usr/local/src/redis/redis.conf /etc/redis
cp /etc/redis/redis.conf /etc/redis/6379.conf
4.8.2.2 使用启动脚本
cat /usr/local/src/redis/utils/redis_init_script
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
4.8.2.3 将启动脚本复制到/etc/init.d目录下,命名为redisd
cp -r /usr/local/src/redis/utils/redis_init_script /etc/init.d
mv /etc/init.d/redis_init_script /etc/init.d/redisd
4.8.2.4 注册开启服务
update-rc.d redisd defaults
4.9 安装hiredis
1、打开hosts文件
sudo vim /etc/hosts
2、在添加github.com域名(localhost下添加即可)
140.82.114.4 github.com
git clone https://github.com/redis/hiredis.git/ /usr/local/src/hiredis
cd /usr/local/src/hiredis
make & make install
cd ..
4.9 安装Freeswitch所需的数据库环境
4.9.1 安装MySQL-server-5.7
apt-get install -y mysql-server-5.7
mysql -u root -p
Enter password:
#直接单击回车,即可进入MySQL
修改MYSQL密码为hctel,并修改root用户的权限
use mysql;
update user set plugin='mysql_native_password' where user='root';
#修改root用户密码为hctel
update user set authentication_string=PASSWORD('hctel') where user='root';
update user set host = '%' where user = 'root';
flush privileges;
quit;
重启MYSQL验证密码是否生效
mysql -u root -p
Enter password:
#输入密码hctel,即可进入MySQL
关闭MYSQL的远程关闭连接限制
vim /etc/mysql/mysql.conf.d/mysqld.cnf
#修改bind-address为 0.0.0.0
#重启mysql服务
service mysql restart
4.9.2 创建freeswitch数据库
数据库名freeswitch
、字符集utf8mb4、排序规则默认
指定freeswitch.sql文件
点击开始
执行成功
4.9.3 配置odbc-mysql环境
官网地址: https://downloads.mysql.com/archives/c-odbc/
解压并重命名为mysql
tar -zvxf mysql-connector-odbc-5.3.12-linux-ubuntu18.04-x86-64bit.tar.gz
mv mysql-connector-odbc-5.3.12-linux-ubuntu18.04-x86-64bit mysql
复制lib的相关配置文件复制到lib和lib64文件夹下
cp -r mysql/lib/* /usr/lib/
mkdir /usr/lib64
cp -r mysql/lib/* /usr/lib64
修改ODBC的配置文件
vim /etc/odbc.ini
[freeswitch]
Driver = MYSQL
Description = connection to MYSQL
Server = 192.168.11.137
Host = 192.168.11.137
Port = 3306
Database = freeswitch
CHARSET = UTF8
User = root
Password = hctel
SSLMODE = DISABLED
vim /etc/odbcinst.ini
[MYSQL]
Description = ODBC for Mysql
Driver = /usr/lib/libmyodbc5a.so
Setup = /usr/lib/libmyodbc5s.so
Driver64 = /usr/lib64/libmyodbc5a.so
Setup64 = /usr/lib64/libmyodbc5s.so
FileUsage = 1
下载安装unixodbc
apt install unixodbc
测试连通性
isql -v freeswitch
5、编译Freeswitch
5.1 安装前置环境和相关依赖
提示:如若遇到Failed to connect to github.com port 443: 连接超时错误,解决方法如下
sudo vim /etc/hosts
选择一个进行配置
140.82.113.3 github.com
140.82.114.4 github.com
5.1.1 安装libks2
git clone https://github.com/signalwire/libks.git /usr/local/src/libks
cd /usr/local/src/libks
cmake .
make && make install
cd ..
验证libks是否安装成功
ldconfig && ldconfig -p | grep libks
打印返回
libks2.so.2 (libc6,x86-64) => /usr/lib/libks2.so.2
libks2.so (libc6,x86-64) => /usr/lib/libks2.so
libksba.so.8 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libksba.so.8
5.1.2 安装signalwire
git clone https://github.com/signalwire/signalwire-c.git /usr/local/src/signalwire-c
cd /usr/local/src/signalwire-c
cmake .
make && make install
cd ..
验证signalwire是否安装成功
ldconfig && ldconfig -p | grep signalwire
打印返回
libsignalwire_client2.so.2 (libc6,x86-64) => /usr/local/lib/libsignalwire_client2.so.2
libsignalwire_client2.so (libc6,x86-64) => /usr/local/lib/libsignalwire_client2.so
5.1.3 安装Sofia-Sip
git clone https://github.com/freeswitch/sofia-sip /usr/local/src/sofia-sip
cd /usr/local/src/sofia-sip
./bootstrap.sh
./configure
make && make install
cd ..
验证Sofia-SIp是否安装成功
ldconfig && ldconfig -p | grep sofia
打印返回
libsofia-sip-ua.so.0 (libc6,x86-64) => /usr/local/lib/libsofia-sip-ua.so.0
libsofia-sip-ua.so (libc6,x86-64) => /usr/local/lib/libsofia-sip-ua.so
libsofia-sip-ua-glib.so.3 (libc6,x86-64) => /usr/local/lib/libsofia-sip-ua-glib.so.3
libsofia-sip-ua-glib.so (libc6,x86-64) => /usr/local/lib/libsofia-sip-ua-glib.so
5.1.4 安装SpanDSP
git clone https://github.com/freeswitch/spandsp /usr/local/src/spandsp
直接编译报错
切换版本
cd spandsp
git checkout -b finecode20230705 0d2e6ac65e0e8f53d652665a743015a88bf048d4
编译安装
cd /usr/local/src/spandsp
./bootstrap.sh -j
./configure
make && make install
cd ..
ldconfig
验证SpanDSP是否安装成功
ldconfig -p | grep spandsp
打印返回
libspandsp.so.3 (libc6,x86-64) => /usr/local/lib/libspandsp.so.3
libspandsp.so (libc6,x86-64) => /usr/local/lib/libspandsp.so
5.2 安装FreeSwitch
5.2.1 安装Freeswitch本体
wget -c https://files.freeswitch.org/releases/freeswitch/freeswitch-1.10.8.-release.tar.gz -P /usr/local/src
若报错
错误: 无法验证 files.freeswitch.org 的由 “CN=ZeroSSL RSA Domain Secure Site CA,O=ZeroSSL,C=AT” 颁发的证书:
无法本地校验颁发者的权限。
使用:
wget --no-check-certificate https://files.freeswitch.org/releases/freeswitch/freeswitch-1.10.8.-release.tar.gz -P /usr/local/src
tar -zvxf freeswitch-1.10.8.-release.tar.gz
mv freeswitch-1.10.8.-release freeswitch
cd /usr/local/src/freeswitch/
5.2.2 修改模块配置文件
vim modules.conf
modules.conf
#applications/mod_abstraction
applications/mod_av
#applications/mod_avmd
#applications/mod_bert
#applications/mod_blacklist
#applications/mod_callcenter
#applications/mod_cidlookup
#applications/mod_cluechoo
applications/mod_commands
applications/mod_conference
applications/mod_curl
#applications/mod_cv
applications/mod_db
#applications/mod_directory
#applications/mod_distributor
applications/mod_dptools
#applications/mod_easyroute
applications/mod_enum
applications/mod_esf
applications/mod_esl
applications/mod_expr
applications/mod_fifo
#applications/mod_fsk
applications/mod_fsv
applications/mod_hash
#applications/mod_hiredis
#applications/mod_httapi
applications/mod_http_cache
#applications/mod_ladspa
#applications/mod_lcr
#applications/mod_memcache
#applications/mod_mongo
#applications/mod_mp4
#applications/mod_mp4v2
#applications/mod_nibblebill
#applications/mod_oreka
#applications/mod_osp
#applications/mod_prefix
#applications/mod_rad_auth
#applications/mod_redis
#applications/mod_rss
#applications/mod_signalwire
applications/mod_sms
#applications/mod_sms_flowroute
#applications/mod_snapshot
#applications/mod_snom
#applications/mod_sonar
#applications/mod_soundtouch
applications/mod_spandsp
#applications/mod_spy
#applications/mod_stress
applications/mod_test
#applications/mod_translate
applications/mod_valet_parking
#applications/mod_video_filter
#applications/mod_vmd
applications/mod_voicemail
#applications/mod_voicemail_ivr
#asr_tts/mod_cepstral
#asr_tts/mod_flite
#asr_tts/mod_pocketsphinx
#asr_tts/mod_tts_commandline
codecs/mod_amr
#codecs/mod_amrwb
codecs/mod_b64
#codecs/mod_bv
#codecs/mod_clearmode
#codecs/mod_codec2
#codecs/mod_com_g729
#codecs/mod_dahdi_codec
codecs/mod_g723_1
codecs/mod_g729
codecs/mod_h26x
#codecs/mod_ilbc
#codecs/mod_isac
#codecs/mod_mp4v
codecs/mod_opus
#codecs/mod_sangoma_codec
#codecs/mod_silk
#codecs/mod_siren
#codecs/mod_theora
#databases/mod_mariadb
databases/mod_pgsql
dialplans/mod_dialplan_asterisk
#dialplans/mod_dialplan_directory
dialplans/mod_dialplan_xml
#directories/mod_ldap
#endpoints/mod_alsa
#endpoints/mod_gsmopen
#endpoints/mod_h323
#endpoints/mod_khomp
endpoints/mod_loopback
#endpoints/mod_opal
#endpoints/mod_portaudio
endpoints/mod_rtc
#endpoints/mod_rtmp
endpoints/mod_skinny
endpoints/mod_sofia
#endpoints/mod_verto
#event_handlers/mod_amqp
event_handlers/mod_cdr_csv
#event_handlers/mod_cdr_mongodb
#event_handlers/mod_cdr_pg_csv
event_handlers/mod_cdr_sqlite
#event_handlers/mod_erlang_event
#event_handlers/mod_event_multicast
event_handlers/mod_event_socket
#event_handlers/mod_fail2ban
#event_handlers/mod_format_cdr
#event_handlers/mod_json_cdr
#event_handlers/mod_radius_cdr
#event_handlers/mod_odbc_cdr
#event_handlers/mod_kazoo
#event_handlers/mod_rayo
#event_handlers/mod_smpp
#event_handlers/mod_snmp
#event_handlers/mod_event_zmq
#formats/mod_imagick
formats/mod_local_stream
formats/mod_native_file
formats/mod_png
#formats/mod_portaudio_stream
#formats/mod_shell_stream
#formats/mod_shout
formats/mod_sndfile
#formats/mod_ssml
formats/mod_tone_stream
#formats/mod_vlc
#formats/mod_opusfile
#languages/mod_basic
#languages/mod_java
languages/mod_lua
#languages/mod_managed
#languages/mod_perl
#languages/mod_python
#languages/mod_python3
#languages/mod_v8
#languages/mod_yaml
loggers/mod_console
#loggers/mod_graylog2
loggers/mod_logfile
loggers/mod_syslog
#loggers/mod_raven
#say/mod_say_de
say/mod_say_en
#say/mod_say_es
#say/mod_say_es_ar
#say/mod_say_fa
#say/mod_say_fr
#say/mod_say_he
#say/mod_say_hr
#say/mod_say_hu
#say/mod_say_it
#say/mod_say_ja
#say/mod_say_nl
#say/mod_say_pl
#say/mod_say_pt
#say/mod_say_ru
#say/mod_say_sv
#say/mod_say_th
say/mod_say_zh
#timers/mod_posix_timer
#timers/mod_timerfd
xml_int/mod_xml_cdr
#xml_int/mod_xml_curl
#xml_int/mod_xml_ldap
#xml_int/mod_xml_radius
xml_int/mod_xml_rpc
xml_int/mod_xml_scgi
#mod_freetdm|https://github.com/freeswitch/freetdm.git -b master
## Experimental Modules (don't cry if they're broken)
#../../contrib/mod/xml_int/mod_xml_odbc
修改完成后,执行配置和编译工作
./rebootstrap.sh
./configure
make & make install
cd /usr/local/freeswitch
5.2.3 创建软连接
ln -s /usr/local/freeswitch/conf /etc/freeswitch
ln -s /usr/local/freeswitch/bin/fs_cli /usr/bin/fs_cli
ln -s /usr/local/freeswitch/bin/freeswitch /usr/sbin/freeswitch
5.2.4 设置开机自启动
创建并修改/etc/systemd/system/freeswitch.service
vim /etc/systemd/system/freeswitch.service
[Unit]
Description=FreeSWITCH open source softswitch
Wants=network-online.target Requires=network.target local-fs.target
After=network.target network-online.target local-fs.target
[Service]
; service
Type=forking
PIDFile=/usr/local/freeswitch/run/freeswitch.pid
Environment="DAEMON_OPTS=-nonat"
Environment="USER=freeswitch"
Environment="GROUP=freeswitch"
EnvironmentFile=-/etc/default/freeswitch
ExecStartPre=/bin/chown -R ${USER}:${GROUP} /usr/local/freeswitch
ExecStart=/usr/local/freeswitch/bin/freeswitch -u ${USER} -g ${GROUP} -ncwait ${DAEMON_OPTS}
TimeoutSec=45s
Restart=always
[Install]
WantedBy=multi-user.target
重启daemon-reload
systemctl daemon-reload
开启Freeswitch服务
systemctl start freeswitch
查看Freeswitch服务状态
systemctl status freeswitch
5.2.5 安装ESL安装环境编译VPBX
cd /usr/local/src/freeswitch/libs/esl/
make & make install
5.2.6 修改安装版FreeSwitch的配置文件
将conf文件夹下的文件复制到/usr/local/freeswitch/conf/路径下
5.2.7 修改Freeswitch的主配置文件vars.xml
vim /usr/local/freeswitch/conf/vars.xml
修改为对应的IP地址
6、编译Vpbx-cgi的Web界面和Vpbx的相关代码
6.1 解压
tar -zxvf vpbx.tar.gz
6.2 编译vpbx-cgi
cd /usr/local/src/vpbx/vpbxcgi
make & make install
cd /usr/local/src
6.3 编译vpbx
cd /usr/local/src/vpbx/fs_mod/mod_event_local
make &make install
cd /usr/local/src
6.4 复制vpbx前端html页面
tar -zvxf ivx1000b-ubuntu.tar.gz
cd ivx1000b/
cp -r vpbx/ /var/www/
6.4、启动Freeswitch进行测试
freeswitch
开启Freeswitch服务
systemctl start freeswitch
查看Freeswitch服务状态
systemctl status freeswitch