FreeSWITCH学习笔记1——编译FreeSWITCH

最近搞FreeSWITCH,这个开源的软switch做得不错,如果有做语音的,应该都多少会知道吧。我之前有听说,但是也没怎么去看。这次刚好有需要用到其中的一个模块。所以就把学习笔记记录一下吧。本文主要是描述下编译FreeSWITCH的过程吧。

首先是下载下最新的源码:

wget http://files.freeswitch.org/freeswitch-1.4.6.tar.gz
tar -xf freeswitch-1.4.6.tar.gz && cd freeswitch-1.4.6

安装需要一些头文件:

sudo apt-get install libjpeg-dev libspeex-dev libspeexdsp-dev libldns-dev libedit-dev pkg-config libsqlite3-dev libcurl4-openssl-dev libpcre3-dev

可能会有一些遗漏,我本来是在我自己的kubuntu14.04上编译的,后来在debian的虚拟机上,又要装几个头文件,毕竟我的电脑已经之前有安装过一些编译头文件了。

先进行初步的编译:(我只是把pid文件的目录给置换了。其他先用默认了)

./configure --with-rundir=/var/run/freeswitch
make

configure执行完的配置如下:

-------------------------- FreeSWITCH configuration --------------------------

  Locations:
      FHS enabled:     no

      prefix:          /usr/local/freeswitch
      exec_prefix:     ${prefix}
      bindir:          ${exec_prefix}/bin
      sysconfdir:      /usr/local/freeswitch/conf
      libdir:          ${exec_prefix}/lib

      certsdir:        /usr/local/freeswitch/certs
      dbdir:           /usr/local/freeswitch/db
      grammardir:      /usr/local/freeswitch/grammar
      htdocsdir:       /usr/local/freeswitch/htdocs
      logfiledir:      /usr/local/freeswitch/log
      modulesdir:      /usr/local/freeswitch/mod
      pkgconfigdir:    ${exec_prefix}/lib/pkgconfig
      recordingsdir:   /usr/local/freeswitch/recordings
      runtimedir:      /var/run/freeswitch
      scriptdir:       /usr/local/freeswitch/scripts
      soundsdir:       /usr/local/freeswitch/sounds
      storagedir:      /usr/local/freeswitch/storage

------------------------------------------------------------------------------

make编译完,竟然还有个大大的LOGO,吓了我一跳。

freeswitch1

安装的话,可以直接使用

sudo make install

但是这样要卸载的话,只能通过

sudo make uninstall

这样其实不是很方便管理,可以使用ubuntu/debian自带的checkinstall来管理,我觉得会更好一些(后面发现使用checkinstall安装的话,部分配置文件会没装全,下文就是用checkinstall安装的,所以还是用make install吧)。

使用checkinstall的话,需要安装checkinstall

sudo apt-get install checkinstall
sudo checkinstall

checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
本软件以 GNU GPL 版权协议颁布


The package documentation directory ./doc-pak does not exist. 
Should I create a default set of package docs?  [y]: 

准备软件包的文档……OK

请为这个软件包写一个描述。
用一个空行或 EOF 来结束你的描述。
>> 

*****************************************
**** Debian package creation selected ***
*****************************************

软件包将用下面的值来创建:

0 -  Maintainer: [ root@debian ]
1 -  Summary: [ Package created with checkinstall 1.6.2 ]
2 -  Name:    [ freeswitch ]
3 -  Version: [ 1.4.6 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ amd64 ]
8 -  Source location: [ freeswitch-1.4.6 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
11 - Provides: [ freeswitch ]
12 - Conflicts: [  ]
13 - Replaces: [  ]

输入一个数字来改变它们,或按回车键继续:

看了FreeSWITCH对于debian系列的还是很友好的,基本上都不需要进行修改,一路回车了。

好了,基本上编译就这样了。

安装完,打算运行一下,freeswitch,竟然没有命令,无语啊。直接执行编译出来的freeswitch

sudo -s
root@GE60-Kubuntu ~/source/freeswitch-1.4.6 # freeswitch
zsh: command not found: freeswitch
127 root@GE60-Kubuntu ~/source/freeswitch-1.4.6 # ./freeswitch                                                                                                                                                  :(
2014-06-18 11:01:05.492009 [INFO] switch_event.c:669 Activate Eventing Engine.
2014-06-18 11:01:05.502397 [WARNING] switch_event.c:651 Create additional event dispatch thread 0
2014-06-18 11:01:05.502516 [ERR] switch_xml.c:1379 Couldnt open /usr/local/freeswitch/conf/freeswitch.xml (No such file or directory)
Cannot Initialize [Cannot Open log directory or XML Root!]
255 root@GE60-Kubuntu ~/source/freeswitch-1.4.6 # ll /usr/local/freeswitch/conf                                                                                                                                 :(
总用量 4
-rw------- 1 root root 13  6月 18 10:06 freeswitch.serial

原来缺少配置文件,这打包脚本,做得一般,看来可能还是得用make install才行。先把配置拷贝一下吧。然后再执行一下。

cp -r conf /usr/local/freeswitch 
./freeswitch

freeswitch2

运行成功,又是大大的LOGO。按下TAB键试试。

freeswitch@GE60-Kubuntu> 

[                 ...]  [                 acl]  [               alias]  [              banner]
[           bg_system]  [               bgapi]  [               break]  [             cdr_csv]
[                chat]  [            cluechoo]  [            coalesce]  [            complete]
[                cond]  [          conference]  [             console]  [    console_complete]
[console_complete_xml]  [         create_uuid]  [                  db]  [            db_cache]
[       domain_exists]  [                echo]  [                enum]  [           enum_auto]
[              escape]  [                eval]  [          event_sink]  [              expand]
[                expr]  [                fifo]  [   fifo_add_outbound]  [   fifo_check_bridge]
[         fifo_member]  [         file_exists]  [       find_user_xml]  [               fsctl]
[             gethost]  [       global_getvar]  [       global_setvar]  [               group]
[          group_call]  [                hash]  [           hash_dump]  [         hash_remote]
[                help]  [         host_lookup]  [            hostname]  [              httapi]
[    hup_local_stream]  [              hupall]  [            in_group]  [        interface_ip]
[         is_lan_addr]  [                json]  [    limit_hash_usage]  [limit_interval_reset]
[         limit_reset]  [        limit_status]  [         limit_usage]  [          list_users]
[                load]  [                 log]  [                 lua]  [              luarun]
[                 md5]  [       module_exists]  [              msleep]  [             nat_map]
[           originate]  [                page]  [               pause]  [            presence]
[     quote_shell_arg]  [             reg_url]  [               regex]  [              reload]
[ reload_local_stream]  [           reloadacl]  [           reloadxml]  [             replace]
[          say_string]  [           sched_api]  [     sched_broadcast]  [           sched_del]
[        sched_hangup]  [      sched_transfer]  [                show]  [   show_local_stream]
[            shutdown]  [               sofia]  [       sofia_contact]  [     sofia_count_reg]
[           sofia_dig]  [  sofia_gateway_data]  [ sofia_presence_data]  [   sofia_username_of]
[          sql_escape]  [  start_local_stream]  [    start_tdd_detect]  [   start_tone_detect]
[              status]  [   stop_local_stream]  [     stop_tdd_detect]  [    stop_tone_detect]
[            strepoch]  [            strftime]  [         strftime_tz]  [       strmicroepoch]
[                stun]  [          switchname]  [              system]  [           time_test]
[          timer_test]  [         tone_detect]  [              unload]  [         unsched_api]
[          url_decode]  [          url_encode]  [           user_data]  [         user_exists]
[         uuid_answer]  [          uuid_audio]  [          uuid_break]  [         uuid_bridge]
[      uuid_broadcast]  [        uuid_buglist]  [           uuid_chat]  [    uuid_debug_media]
[        uuid_deflect]  [       uuid_displace]  [        uuid_display]  [  uuid_dual_transfer]
[           uuid_dump]  [       uuid_early_ok]  [         uuid_exists]  [        uuid_fileman]
[     uuid_flush_dtmf]  [         uuid_getvar]  [           uuid_hold]  [   uuid_jitterbuffer]
[           uuid_kill]  [          uuid_limit]  [  uuid_limit_release]  [       uuid_loglevel]
[          uuid_media]  [    uuid_media_reneg]  [uuid_outgoing_answer]  [           uuid_park]
[          uuid_pause]  [    uuid_phone_event]  [     uuid_pre_answer]  [     uuid_preprocess]
[         uuid_record]  [uuid_recovery_refresh] [      uuid_recv_dtmf]  [     uuid_ring_ready]
[      uuid_send_dtmf]  [      uuid_send_info]  [   uuid_send_message]  [       uuid_send_tdd]
[uuid_session_heartbeat]        [uuid_set_media_stats]  [         uuid_setvar]  [   uuid_setvar_multi]
[       uuid_simplify]  [       uuid_transfer]  [  uuid_video_refresh]  [    uuid_zombie_exec]
[          valet_info]  [             version]  [         vm_boxcount]  [           vm_delete]
[  vm_fsdb_auth_login]  [   vm_fsdb_msg_count]  [  vm_fsdb_msg_delete]  [   vm_fsdb_msg_email]
[ vm_fsdb_msg_forward]  [     vm_fsdb_msg_get]  [    vm_fsdb_msg_list]  [   vm_fsdb_msg_purge]
[    vm_fsdb_msg_save]  [vm_fsdb_msg_undelete]  [vm_fsdb_pref_greeting_get]     [vm_fsdb_pref_greeting_set]
[vm_fsdb_pref_password_set]     [vm_fsdb_pref_recname_set]      [           vm_inject]  [             vm_list]
[            vm_prefs]  [             vm_read]  [           voicemail]  [    voicemail_inject]
[     xml_flush_cache]  [          xml_locate]  [            xml_wrap]  [        uuid_warning]


freeswitch@GE60-Kubuntu>

运行到这里,如何退出?输入”…”,退出cli!后面还一大把的log就不贴上来了。

freeswitch@GE60-Kubuntu> ...

+OK

2014-06-18 11:10:54.156568 [INFO] switch_core.c:2492 Shutting down

好了,笔记就先到这边了。

转载请注明: 转载自elkPi.com

本文链接地址: FreeSWITCH学习笔记1——编译FreeSWITCH

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Scroll to top