本人在安装FreeSWITCH的时候遇到了相当多的坑,网上很多方法都模棱两可,经常装失败,最后终于装成功后做一下总结
最顺利的安装方式
1. 下载压缩文件
下载地址:http://files.freeswitch.org/freeswitch-releases/ 我选择的下载版本是freeswitch-1.8.5.tar.xz ,下载完成后解压缩
2. 安装依赖包
apt-get update apt-get install -y autoconf git libtool g++ zlib1g-dev libjpeg-dev libsqlite3-dev libcurl4-openssl-dev libpcre3-dev libspeex-dev libspeexdsp-dev libldns-dev libedit-dev libssl-dev pkg-config yasm liblua50-dev libopus-dev libsndfile1-dev libpq-dev libreadline-dev lua5.2 lua5.2-doc liblua5.2-dev libtiff5 libtiff5-dev sudo apt-get install -y vim sudo apt-get install -y g++ sudo apt-get install -y zlib1g-dev sudo apt-get install -y libjpeg-dev sudo apt-get install -y libsqlite3-dev sudo apt-get install -y libcurl4-gnutls-dev sudo apt-get install -y libpcre3-dev sudo apt-get install -y libspeexdsp-dev sudo apt-get install -y libedit-dev sudo apt-get install -y libssl-dev sudo apt-get install -y libopus-dev sudo apt-get install -y liblua5.2-dev sudo apt-get install -y libldns-dev sudo apt-get install -y libsndfile1-dev
3. 编译安装
# 切换路径到第一步解压缩的文件夹下 ./configure make
make install
4. 安装声音文件
# 安装声音文件 make sounds-install make moh-install # 以下高质量的声音文件可选择安装 make cd-sounds-install make cd-moh-install
如果一切顺利的话就安装好了,但是事实往往不那么容易,之后会列举几个会遇到的问题及解决方案
制作软连接
ln -sf /usr/local/freeswitch/bin/freeswitch /usr/bin/ ln -sf /usr/local/freeswitch/bin/fs_cli /usr/bin/
启动FreeSWITCH
freeswitch
关闭FreeSWITCH
shutdown
可能遇到的问题及解决方案
问题一:
报错:
make[4]: Entering directory '/home/root/code/freeswitch-1.8.5/src/mod/applications/mod_signalwire' Makefile:930: *** You must install libks to build mod_signalwire. Stop. make[4]: Leaving directory '/home/root/code/freeswitch-1.8.5/src/mod/applications/mod_signalwire' Makefile:683: recipe for target 'mod_signalwire-all' failed make[3]: *** [mod_signalwire-all] Error 1 make[3]: Leaving directory '/home/root/code/freeswitch-1.8.5/src/mod' Makefile:591: recipe for target 'all-recursive' failed make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory '/home/root/code/freeswitch-1.8.5/src' Makefile:3494: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/root/code/freeswitch-1.8.5' Makefile:1255: recipe for target 'all' failed make: *** [all] Error 2
- 解决步骤如下:
# (1)自己下载编译好的cmake直接用 https://cmake.org/files/v3.13/cmake-3.13.3-Linux-x86_64.tar.gz ''' 解压后配置好即可。值得注意的是,cmake不能单独拷贝出来使用,只能将解压后的bin目录下的cmake等可执行文件链接到系统环境变量PATH包含的目录下,否则会报错。 ''' # (2)下载并编译libks cd /usr/local/src git clone https://github.com/signalwire/libks.git cd libks cmake .
问题二:
报错:
-- Checking for module 'uuid' -- No package 'uuid' found CMake Error at /home/root/tools/cmake-3.13.3-Linux-x86_64/share/cmake-3.13/Modules/FindPkgConfig.cmake:452 (message): A required package was not found Call Stack (most recent call first): /home/root/tools/cmake-3.13.3-Linux-x86_64/share/cmake-3.13/Modules/FindPkgConfig.cmake:622 (_pkg_check_modules_internal) cmake/FindUUID.cmake:15 (pkg_check_modules) CMakeLists.txt:294 (include) -- Configuring incomplete, errors occurred! See also "/home/root/code/libks/CMakeFiles/CMakeOutput.log". See also "/home/root/code/libks/CMakeFiles/CMakeError.log".
- 解决步骤如下
# 解决方法1: apt-get install uuid # 或 dpkg - i libuuid1_2.20.1-5.1ubuntu20.9_amd64.deb #### 错误依旧. # 解决方法2:下载并编译libuuid源码 https://jaist.dl.sourceforge.net/project/libuuid/libuuid-1.0.3.tar.gz ./configure make make install # 重新执行libks的 cmake . #### 问题解决。然后执行 make make install # 解决方法3:下载并编译signalwire-c cd /usr/local/src git clone https://github.com/signalwire/signalwire-c.git cd signalwire-c cmake .
问题3:
报错:
CMake Error at CMakeLists.txt:168 (string): string sub-command REPLACE requires at least four arguments. -- Configuring incomplete, errors occurred! See also "/home/root/code/signalwire-c/CMakeFiles/CMakeOutput.log".
- 解决方法如下
# 阅读CMakeLists.txt,发现出问题的地方是使用git命令生成changelog的。对编译代码无影响。注释掉相关内容: # Get git log info #execute_process(COMMAND ${GIT_EXECUTABLE} log --no-merges --pretty=format:"%n [%an]%n * %s" --since="last month" # OUTPUT_VARIABLE CHANGELOG # WORKING_DIRECTORY . # OUTPUT_STRIP_TRAILING_WHITESPACE) #string(REPLACE "\"" "" CHANGELOG ${CHANGELOG}) ## Create changelog #file(WRITE changelog.Debian ${CHANGELOG_HEADER}\n${CHANGELOG}\n\n${CHANGELOG_FOOTER}) #execute_process(COMMAND ${GZIP_CMD} -f -9 -n changelog.Debian) # Install changelog #install(FILES "${CMAKE_BINARY_DIR}/changelog.Debian.gz" COMPONENT "runtime" DESTINATION "share/doc/${CPACK_DEBIAN_PACKAGE_NAME}") # 重新执行 cmake . make make install make clean # 清除上次编译的中间文件 # 重新执行FreeSWITCH的 ./configure make make install
其他安装方法
这里列举另一种安装方法,可能因为本人操作不当的原因未能成功,若读者使用最上面的方法安装失败的话可以尝试用此方法
1、apt-get update 2、apt-get upgrade 3、apt-get install -y git build-essential automake autoconf libtool g++ zlib1g-dev libjpeg-dev libncurses5-dev libsqlite3-dev libcurl4-openssl-dev libpcre3-dev libspeex-dev libspeexdsp-dev libspeex-dev libldns-dev libedit-dev libssl-dev pkg-config yasm liblua5.2-dev liblua5.2 libopus-dev libsndfile-dev libtool libpq-dev pkg-config libtiff5-dev libtiff5 libvpx-dev libvpx3 libvpx3 libopus-dev uuid-dev libsndfile-dev 4、git clone -b v1.8 https://freeswitch.org/stash/scm/fs/freeswitch.git 5、cd freeswitch 6、./bootstrap.sh -j 7、./configure 8、cd src/ 9、wget https://cmake.org/files/v3.13/cmake-3.13.3.tar.gz 10、tar zxvf cmake-3.13.3.tar.gz 11、cd cmake-3.13.3/ 12、./bootstrap 13、make 14、make install 15、cd .. 16、git clone https://github.com/signalwire/libks.git 17、cd libks/ # 到这里为止都成功
报错:
-- Checking for module 'uuid' -- No package 'uuid' found CMake Error at /home/root/tools/cmake-3.13.3-Linux-x86_64/share/cmake-3.13/Modules/FindPkgConfig.cmake:452 (message): A required package was not found Call Stack (most recent call first): /home/root/tools/cmake-3.13.3-Linux-x86_64/share/cmake-3.13/Modules/FindPkgConfig.cmake:622 (_pkg_check_modules_internal) cmake/FindUUID.cmake:15 (pkg_check_modules) CMakeLists.txt:294 (include) -- Configuring incomplete, errors occurred! See also "/home/root/code/libks/CMakeFiles/CMakeOutput.log". See also "/home/root/code/libks/CMakeFiles/CMakeError.log".
解决方法:
下载并编译libuuid源码:https://jaist.dl.sourceforge.net/project/libuuid/libuuid-1.0.3.tar.gz
./configure make make install # 重新执行libks的 cmake .
make
继续
20、make install 21、cd .. 22、git clone https://github.com/signalwire/signalwire-c.git 23、cd signalwire-c/ 24、cmake . 25、make 26、make install 27、cp /usr/local/lib/pkgconfig/*.pc /usr/lib/pkgconfig/ # 到这里为止,后面的就失败了 28、cp -rf /usr/local/lib/ /lib64/ 29、cd .. 30、make
顺利的安装方法参考:https://blog.csdn.net/shzwfq/article/details/88716584
另一种安装方法参考:https://blog.51cto.com/14291809/2378924