FreeSWITCH 1.2
上QQ阅读APP看书,第一时间看更新

Compiling FreeSWITCH for Linux/Unix/Mac OS X

The install procedure is essentially the same for Linux, Unix, or Mac OS X. However, make sure that your system has met the prerequisites listed in the previous section.

Compiling FreeSWITCH

Compiling FreeSWITCH requires just a few steps, although it will take some time depending upon the speed of your system. The basic procedure for compiling FreeSWITCH is as follows:

  1. Run the bootstrap.sh script.
  2. Edit the modules.conf file to customize which modules are compiled by default.
  3. Run the configure script.
  4. Run the make and make install utilities to compile and install.
  5. Edit modules.conf.xml to customize which modules are loaded by default.
  6. Install the sound and music files.

Following are detailed step-by-step instructions for compiling FreeSWITCH.

Step 1 – edit modules.conf

The modules.conf file contains a list of the various FreeSWITCH modules that will be configured and compiled. The default modules.conf file has a sensible set of modules pre-selected to be compiled. However, there is one optional module that we will enable now. You should have a new subdirectory named freeswitch-1.2.x, where 1.2.x is the version number. For example, if the latest stable version is 1.2.1 then your source directory will be /usr/src/freeswitch-1.2.1. Perform the following steps:

  1. Change the directory into the new FreeSWITCH source directory:
    #>cd /usr/src/freeswitch-1.2.x
    
  2. Open modules.conf in a text editor. Scroll down to the following line:
    #asr_tts/mod_flite
    
  3. Remove the # character from the beginning of the line, then save and exit. The mod_flite module enables FreeSWITCH to use the open source Festival Lite text-to-speech (TTS) engine. (The Flite TTS engine does not produce a particularly high quality speech synthesis. However, it is very handy for doing TTS testing.)
    Note

    More information about Festival Lite can be found at http://www.speech.cs.cmu.edu/flite/.

After editing modules.conf, we are ready to start the build process.

Note

Removing the # character at the beginning of a line in modules.conf will cause the module on that line to automatically be built when issuing the make command. Likewise, adding a # at the beginning of the line will prevent the corresponding module from being built automatically.

Step 2 – run the configure script

Like many open source projects, FreeSWITCH in UNIX-like environments makes use of the now famous configure script. From within the FreeSWITCH source directory, launch the configure script, as follows:

#>./configure -C

The configure script performs many tasks, including making sure that the prerequisites have been met. If a prerequisite has not been met then the configure script will exit and tell you which dependency has not been met. If this occurs then you must resolve the issue and rerun the configure script. You will need to make sure that all of the prerequisites have been met before the configure script will run to completion. The -C argument tells the configure module to create a config.cache file that will be used by subsequent configure scripts with the various libraries included in the source tree.

Tip

The configure script is a common tool in building open source software in the Linux/Unix environment. It has many options to modify the behavior. Launch configure with the --help argument to see a complete list.

During the configuration process, you will see the configure script run multiple times. FreeSWITCH makes use of many libraries like Apache Portable Runtime (APR) and Perl Compatible Regular Expressions (PCRE). Each of these elements has its own specific configure script that is customized to its own needs.

After some time, the configure script finishes and returns you to the system prompt. You will undoubtedly see a lot of output on the screen from the configuration process, but if you do not see any errors then you may proceed to the compilation process.

Step 3 – run the make and make install utilities

The configuration process in the previous step actually creates what is called a Makefile for FreeSWITCH, its libraries, and its various modules. The compilation and installation of FreeSWITCH are both handled by the make utility. First run make, and then run make install. Many users will run them both with one command line, which is as follows:

#>make && make install

Like the configure script, the make process takes a while, and it will stop if there are any errors. Usually things go well, and at the end of the compilation and installation, you are greeted with the following message:

+-------- FreeSWITCH install Complete ----------+
+ FreeSWITCH has been successfully installed. +
+ +
+ Install sounds: +
+ (uhd-sounds includes hd-sounds, sounds) +
+ (hd-sounds includes sounds) +
+ ------------------------------------ +
+ make cd-sounds-install +
+ make cd-moh-install +
+ +
+ make uhd-sounds-install +
+ make uhd-moh-install +
+ +
+ make hd-sounds-install +
+ make hd-moh-install +
+ +
+ make sounds-install +
+ make moh-install +
+ +
+ Install non english sounds: +
+ replace XX with language +
+ (ru : Russian) +
+ ------------------------------------ +
+ make cd-sounds-XX-install +
+ make uhd-sounds-XX-install +
+ make hd-sounds-XX-install +
+ make sounds-XX-install +
+ +
+ Upgrade to latest: +
+ ---------------------------------- +
+ make current +
+ +
+ Rebuild all: +
+ ---------------------------------- +
+ make sure +
+ +
+ Install/Re-install default config: +
+ ---------------------------------- +
+ make samples +
+ +
+ +
+ Additional resources: +
+ ---------------------------------- +
+ http://www.freeswitch.org +
+ http://wiki.freeswitch.org +
+ http://jira.freeswitch.org +
+ http://lists.freeswitch.org +
+ +
+ irc.freenode.net / #freeswitch +
+ +
+-----------------------------------------------+

If you see a message like the last one then you have successfully compiled FreeSWITCH, and can proceed to the next step. If an error occurs then the compilation process will stop and report it. You will need to correct the problem before you can continue. If the error message is unfamiliar to you then you should contact the FreeSWITCH community using the resources listed in Appendix A, The FreeSWITCH Online Community.

Step 4 – edit modules.conf.xml

The modules.conf.xml file contains a list of modules that FreeSWITCH will load when it is launched. The default modules.conf.xml file corresponds with the default modules.conf file. The modules that are built by default in modules.conf are also enabled by default in modules.conf.xml. As we enabled mod_flite to be built in modules.conf, we need to enable mod_flite in modules.conf.xml so that it will be loaded automatically when FreeSWITCH starts. As a rule of thumb, any module that you wish to load automatically when FreeSWITCH starts must be enabled in modules.conf.xml.

The modules.conf.xml file is located in the conf/autoload_configs subdirectory. The default location is /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml. Open the file in a text editor and locate the following line near the end of the file:

<!-- <load module="mod_flite"/> -->

Remove the <!-- and --> tags so that it looks like the following:

<load module="mod_flite"/>

Save the file and exit. You are almost ready to start the FreeSWITCH application.

Note

What's the difference between modules.conf and modules.conf.xml files? The modules.conf file is found in the source directory, and is used to control FreeSWITCH modules that are compiled when running make. It is a simple text file that uses a leading # character to denote a comment. The modules.conf.xml file is part of the example XML configuration, and is found in the FreeSWITCH autoload_configs subdirectory. It uses standard XML <!-- and --> pairs to denote a comment. It controls which modules are loaded when FreeSWITCH is launched.

Step 5 – install sound and music files

Sound and music files are not absolutely required. However, they are highly recommended. Without them, you will not have music on hold, and features like voicemail and the sample IVR will not be functional. FreeSWITCH has sample sound and music files available in four different sampling rates. We recommend installing all of them so that you can take advantage of high quality audio connections wherever possible.

To install the sound files, just issue the following command in the FreeSWITCH source directory:

#>make cd-sounds-install

To install the music files, issue the following command:

#>make cd-moh-install

These commands will download and install the sound and music files in 8 kHz, 16 kHz, 32 kHz, and 48 kHz sampling rates. FreeSWITCH will use the appropriate sampling rate when playing a sound or music file to a caller.

You are now ready to start FreeSWITCH. The next section covers compiling FreeSWITCH in the Windows environment, so skip down to the Starting FreeSWITCH section.