Install Asterisk 1.4/1.6/1.8 on Linux

    版本為 22:15, 20 Nov 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    系統環境介紹:

    • Debian (Lenny)
    • Asterisk 1.6.2.14
    • dahdi-linux-2.4.0
    • FreePBX 2.8

     

    安裝開始

    安裝需要的相依套件
    apt-get install build-essential linux-headers-`uname -r`
    apt-get install bison festival festival-dev libssl-dev zlib1g-dev libnewt-dev
    apt-get install libvorbis-dev automake mysql-server mysql-client mysql-admin libmysqlclient15-dev
    apt-get install php5 php5-cli php5-common php5-dev
    apt-get install curl libgnutls26 libgnutls-dev libtiff4-dev libtiff-tools
    apt-get install libasound2-dev portaudio19-dev libportaudio2 jackd
    apt-get install unixodbc unixodbc-bin unixodbc-dev
    apt-get install libbluetooth-dev libxml2-dev
    apt-get install sox
    

    NOTE:

    安裝過程中會提示:需設定 MySQL 的 root 密碼。

    安裝 Speex codec(optional)
    cd /usr/src
    wget http://downloads.xiph.org/releases/speex/speex-1.2rc1.tar.gz
    tar xzf speex-1.2rc1.tar.gz
    cd speex-1.2rc1
    ./configure --prefix=/usr
    make
    make install
    ldconfig -v 
    
    安裝 SpanDSP module 用於傳真(optional)
    cd /usr/src
    wget http://www.soft-switch.org/downloads/spandsp/spandsp-0.0.6pre17.tgz
    tar xzf spandsp-0.0.6pre17.tgz
    cd spandsp-0.0.6
    ./configure --prefix=/usr
    make
    make install
    ldconfig -v
    
    安裝 googletalk module(optional)
    cd /usr/src
    wget http://iksemel.googlecode.com/files/iksemel-1.4.tar.gz
    cd iksemel-1.4
    ./configure --prefix=/usr
    make
    make check
    make install
    ldconfig -v
    
    安裝 dahdi 驅動程式(若需要 MeetMe 功能,這是必要的)
    cd /usr/src
    wget http://downloads.asterisk.org/pub/telephony/dahdi-linux/dahdi-linux-current.tar.gz
    cd dahdi-linux-*
    make
    make install
    
    cd /usr/src
    wget http://downloads.asterisk.org/pub/telephony/dahdi-tools/dahdi-tools-current.tar.gz
    cd dahdi-tools-*
    ./configure
    make
    make install
    make config 
    

    啟動 dahdi 服務試試

    /etc/init.d/dahdi start
    Loading DAHDI hardware modules:
       wct4xxp: done   wcte12xp: done   wct1xxp: done   wcte11xp: done   wctdm24xxp: done   wcfxo: done   wctdm: done   wcb4xxp: done   wctc4xxp: done   xpp_usb: done
    No hardware timing source found in /proc/dahdi, loading dahdi_dummy
    Running dahdi_cfg: done. 
    

    若沒有出現任何錯誤訊息,表示安裝順利完成。

    安裝 Asterisk 主程式
    cd /usr/src
    wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-1.6.2-current.tar.gz
    tar xzf asterisk-1.6.2-current.tar.gz
    cd asterisk-1.6.2*

    若需要使用 iLBC codec 時,請執行以下的步驟,否則跳過此步驟

    contrib/scripts/get_ilbc_source.sh
    -> 按 Enter 繼續 (NOTE: 此 shell 必須在主程式根目錄下執行)
     
    ***
    The iLBC source code download is complete.
    ***
    -> 出現這表示完成
    -> 請在 menuconfig 選擇 codec_ilbc
    ./configure
    make menuselect 或 make menuconfig
    

    Codec Translators -> codec_ilbc (optional)
    Extras Sound Packages -> EXTRA-SOUNDS-EN-GSM (optional)
    Save & Exit

    繼續對 Asterisk 作編譯安裝

    make
    make install
    make samples
    make config 
    

    安裝 asterisk-addons

    cd /usr/src
    wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-addons-1.6.2-current.tar.gz
    tar xzf asterisk-addons-1.6.2-current.tar.gz
    cd asterisk-1.6.2*
    ./configure
    make menuselect
    

    Applications

    -> app_addon_sql_mysql ;連接 MySQL
    -> app_saycountpl

    Call Detail Recording

    -> cdr_addon_mysql ;CDR 使用 MySQL

    Channel Drivers

    -> chan_mobile ;藍牙手機連接(optional)
    -> chan_ooh323 ;H.323 protocol 支援(optional)

    Format Interpreters

    -> format_mp3 ;MP3 檔案格式支援(optional)

    Resource Modules

    -> res_config_mysql ; Asterisk Realtime Mode

    Save & Exit

    make
    make install
    make samples 
    

    Asterisk 安裝完成。

    設定 Asterisk 的權限
    addgroup --system asterisk
    adduser --system --ingroup asterisk --home /var/lib/asterisk --no-create-home asterisk
    

    編輯 /etc/init.d/asterisk

    # 刪除註解
    AST_USER="asterisk"
    AST_GROUP="asterisk"
    

    設定相關目錄

    chown -R asterisk:asterisk /var/run/asterisk
    chown -R asterisk:asterisk /etc/asterisk
    chown -R asterisk:asterisk /var/log/asterisk
    chown -R asterisk:asterisk /var/spool/asterisk
    chown -R asterisk:asterisk /var/lib/asterisk 
    chown  -R asterisk:asterisk  /dev/dahdi
    adduser asterisk audio (增加 asterisk 到 group audio)
    

    啟動 Asterisk 服務試試

    /etc/init.d/asterisk start
    
    設定 CDR 資料庫
    mysqladmin -uroot -p create asteriskcdrdb
    mysql -uroot -p asteriskcdrdb 
    
    mysql> CREATE TABLE cdr (
        calldate datetime NOT NULL default '0000-00-00 00:00:00',
        clid varchar(80) NOT NULL default '',
        src varchar(80) NOT NULL default '',
        dst varchar(80) NOT NULL default '',
        dcontext varchar(80) NOT NULL default '',
        channel varchar(80) NOT NULL default '',
        dstchannel varchar(80) NOT NULL default '',
        lastapp varchar(80) NOT NULL default '',
        lastdata varchar(80) NOT NULL default '',
        duration int(11) NOT NULL default '0',
        billsec int(11) NOT NULL default '0',
        disposition varchar(45) NOT NULL default '',
        amaflags int(11) NOT NULL default '0',
        accountcode varchar(20) NOT NULL default '',
        uniqueid varchar(32) NOT NULL default '',
        userfield varchar(255) NOT NULL default ''
        );
    
    mysql> CREATE USER 'astuser'@'localhost' IDENTIFIED BY 'mypass';
    mysql> GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO 'astuser'@'localhost';
    mysql> flush privileges;
    mysql> quit
    

    編輯 /etc/asterisk/cdr_mysql.conf

    [global]
    hostname=localhost
    dbname=asteriskcdrdb
    table=cdr
    password=mypass
    user=astuser
    port=3306
    sock=/var/run/mysqld/mysqld.sock
    

    安裝 FreePBX 管理介面

    設定 Asterisk Manager

    編輯 /etc/asterisk/manager.conf

    ; 將 no 改成 yes
    [general]
    enabled = yes
    

    在最底下加上這幾行

    [admin]
    secret = amp123
    deny=0.0.0.0/0.0.0.0
    permit=127.0.0.1/255.255.255.0
    read = system,call,log,verbose,command,agent,user
    write = system,call,log,verbose,command,agent,user
    
    安裝 LAMP 環境
    apt-get install apache2 libapache2-mod-php5 mysql-common mysql-server-5.0 mysql-client-5.0 php5-mysql php-pear php-db php5-gd
    
    設定 PHP

    編輯 /etc/php5/apache2/php.ini

    ; 將 On 改成 Off
    magic_quotes_gpc = Off
    
    設定 Apache

    編輯 /etc/apache2/envvars

    export APACHE_RUN_USER=asterisk
    export APACHE_RUN_GROUP=asterisk

    重啟 apache 服務

    /etc/init.d/apache2 restart
    
    下載/安裝 FreePBX

    http://www.freepbx.org/download-freepbx

    cd /usr/src
    wget http://mirror.freepbx.org/freepbx-2.8.0.tar.gz
    tar xzf freepbx-2.8.0.tar.gz 
    

    建立資料庫 asterisk

    mysqladmin -uroot -p create asterisk
    mysqladmin -uroot -p create asteriskcdrdb
    mysql -uroot -p asterisk
    
    mysql> CREATE USER 'astuser'@'localhost' IDENTIFIED BY 'mypass';
    mysql> GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO 'astuser'@'localhost';
    mysql> flush privileges;
    mysql> quit
    

    匯入資料庫

    cd /usr/src/freepbx-2.8.0
    mysql -uastuser -p asterisk < SQL/newinstall.sql
    mysql -uastuser -p asteriskcdrdb < SQL/cdr_mysql_table.sql

    F.A.Q

    ERROR: codec_dahdi.c: Failed to open /dev/dahdi/transcode: Permission denied

    Ans: chown -R asterisk:asterisk /dev/dahdi

    Powered by MindTouch Core