cd /etc/apt cp -a sources.list sources.list.orig vi sources.list
將 archive.ubuntu.com 換成 tw.archive.ubuntu.com
deb http://tw.archive.ubuntu.com/ubuntu natty main restricted universe deb http://tw.archive.ubuntu.com/ubuntu natty-updates main restricted universe deb http://tw.archive.ubuntu.com/ubuntu natty-security main restricted universe deb http://archive.canonical.com/ubuntu natty partner
套件庫資訊更新
apt-get update
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 subversion
NOTE:
* 安裝過程中會提示:需設定 MySQL 的 root 密碼。
* Ubuntu 11 請將 libmysqlclient15-dev 改成 libmysqlclient-dev。
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
注意:可使用套件 libspandsp-dev 取代
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
Tips:
若有用到 IAXmodem 時,這是必要的安裝。
*Asterisk 1.8 注意*
- 要選用 res_fax, res_fax_spandsp 兩模組,必須安裝套件 libspandsp-dev, libspandsp# (# 表示1,2,etc..)。
- 預設安裝是 res_fax, res_fax_spandsp,模組 app_fax 是未選用,如果強制安裝它,Asterisk 在安裝系統後會提醒另兩個模組將無法使用。
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
*Asterisk 1.8 注意*
在 Asterisk 1.8 已內建有 GV 的模組。
cd /usr/src wget http://downloads.asterisk.org/pub/telephony/dahdi-linux/dahdi-linux-current.tar.gz tar xzf 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 tar xzf dahdi-tools-current.tar.gz cd dahdi-tools-* ./configure make make install make config
注意:可以用 dahdi-linux-complete-current 取代以上兩個套件。
cd /usr/src wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz tar xzf dahdi-linux-complete-current.tar.gz cd dahdi-linux-complete-* make all 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.
若沒有出現任何錯誤訊息,表示安裝順利完成。
TIPs:
如果安裝 dahdi 只是為了 Meetme 功能,而不會使用任何的電話介面卡,可以將硬體驅動模組關閉,編輯 /etc/dahdi/modules,將所有模組註解。
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 時,請執行以下的步驟,否則跳過此步驟
注意:指令必須在 /usr/src/asterisk-* 的主目錄內執行。
contrib/scripts/get_ilbc_source.sh -> 按 Enter 繼續 (NOTE: 此 shell 必須在主程式根目錄下執行) *** The iLBC source code download is complete. ***
Notes:
-> 必須先安裝 subversion 套件。
-> 要驗證是否有正確下載 iLBC 原始碼,可以檢查目錄 codecs/ilbc/ 是否有大量檔案。
-> 編譯前請在 menuconfig 選擇 codec_ilbc 項目。
[選用]若需要支援 mp3 檔案格式,請執行以下步驟,否則跳過 *僅適用 Asterisk 1.8.x*
注意:指令必須在 /usr/src/asterisk-* 的主目錄內執行。
contrib/scripts/get_mp3_source.sh
Notes:
-> 要驗證是否正確下載 MP3 原始碼,可以檢查目錄 addons/mp3/。
-> 編譯前請在 menuconfig -> addons -> 選擇 format_mp3。
-> 此模組載入後,可使 Playback 及 MusicOnHold 支援 MP3 語音檔。
繼續安裝步驟
./configure make menuselect 或 make menuconfig
*Asterisk 1.8.x 注意*
在 Asterisk 1.8.x 版本已經將 asterisk-addon 整合在一起,在 make menuselect 時必須同時設定要安裝哪些 addon 的模組,一般選擇如下:
Add-ons:
-> app_mysql
-> cdr_mysql
-> format_mp3 (* 必須完成下載 MP3 原始碼*)
-> res_config_mysql傳真模組:
Resources Modules (* 必須安裝 libspandsp-dev*)
-> res_fax
-> res_fax_spandsp
繼續對 Asterisk 作編譯安裝
make make install make samples make config
安裝 asterisk-addons *Asterisk-1.8.x 跳過此步驟*
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_saycountplCall 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 安裝完成。
addgroup --system asterisk adduser --system --ingroup asterisk --home /var/lib/asterisk --no-create-home --shell /bin/bash asterisk
編輯 /etc/init.d/asterisk
# 刪除註解 AST_USER="asterisk" AST_GROUP="asterisk"
*Asterisk 1.8.x 注意*
編輯 /etc/default/asterisk 。
設定相關目錄
chown -R asterisk:asterisk /var/run/asterisk /etc/asterisk /var/log/asterisk /var/spool/asterisk /var/lib/asterisk chown -R asterisk:asterisk /dev/dahdi adduser asterisk audio (增加 asterisk 到 group audio)
啟動 Asterisk 服務試試
/etc/init.d/asterisk start
※ 若需要安裝 FreePBX 套件,請跳過此步驟。
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
編輯 /etc/asterisk/manager.conf
; 將 no 改成 yes [general] enabled = yes
在最底下加上這幾行
; for FreePBX [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
for Ubuntu/Debian)
apt-get install apache2 libapache2-mod-php5 mysql-common mysql-server mysql-client php5-mysql php-pear php-db php5-gd
for CentOS/Redhat)
yum groupinstall "DNS Name Server" yum groupinstall "Web Server" yum groupinstall "Mail Server" yum groupinstall "MySQL Database" yum groupinstall "Development Tools" yum install e2fsprogs-devel keyutils-libs-devel krb5-devel libogg libselinux-devel libsepol-devel libxml2-devel libtiff-devel yum install gmp php-pear php-pear-DB php-gd php-mysql php-pdo kernel-devel ncurses-devel audiofile-devel libogg-devel yum install openssl-devel mysql-devel zlib-devel perl-DateManip sendmail-cf sox
編輯 /etc/php5/apache2/php.ini
; 將 On 改成 Off magic_quotes_gpc = Off
for Ubuntu/Debian)
編輯 /etc/apache2/envvars
export APACHE_RUN_USER=asterisk export APACHE_RUN_GROUP=asterisk
重啟 apache 服務
/etc/init.d/apache2 restart
for CentOS/RedHat)
編輯 /etc/httpd/conf/httpd.conf
User asterisk Group asterisk
重啟 apache 服務
service httpd restart
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 mysql> CREATE USER 'astuser'@'localhost' IDENTIFIED BY 'mypass'; mysql> GRANT ALL PRIVILEGES ON asterisk.* TO 'astuser'@'localhost'; 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
再繼續下面的步驟前,先準備這些資訊:
cd /usr/src/freepbx-2.8.0 ./start_asterisk start ./install_amp
Enter your USERNAME to connect to the 'asterisk' database:
[asteriskuser] astuserEnter your PASSWORD to connect to the 'asterisk' database:
[amp109] mypassEnter the hostname of the 'asterisk' database:
[localhost]Enter a USERNAME to connect to the Asterisk Manager interface:
[admin]Enter a PASSWORD to connect to the Asterisk Manager interface:
[amp111] amp123Enter the path to use for your AMP web root:
[/var/www/html]
/var/wwwEnter the IP ADDRESS or hostname used to access the AMP web-admin:
[xx.xx.xx.xx] 192.168.7.65Enter a PASSWORD to perform call transfers with the Flash Operator Panel:
[passw0rd] 1234Use simple Extensions [extensions] admin or separate Devices and Users [deviceanduser]?
[extensions]Enter directory in which to store AMP executable scripts:
[/var/lib/asterisk/bin]Enter directory in which to store super-user scripts:
[/usr/local/sbin]...
...Please update your modules and reload Asterisk by visiting http://192.168.7.65/admin
*************************************************************************
* Note: It's possible that if you click the red 'Update Now' bar BEFORE *
* updating your modules, your machine will start dropping calls. Ensure *
* that all modules are up to date BEFORE YOU CLICK THE RED BAR. As long *
* as this is observed, your machine will be fully functional whilst the *
* upgrade is in progress. *
*************************************************************************
FreePBX-2.9 修正:
cd /etc/asterisk mv mv extensions_custom.conf.sample extensions_custom.conf mv sip_notify.conf sip_notify.conf.orig
cd /usr/src wget http://asteriskipcop.berlios.de/fpfa/amportal chmod u+x amportal mv amportal /etc/init.d ln -s /etc/init.d/amportal /etc/rc2.d/S99amportal
或者
編輯 /etc/rc.local,在 exit 0 之前加上:
... /usr/local/sbin/amportal start exit 0
安裝完成
管理介面登入:http://主機位址/admin,預設帳號:admin / admin
Ans: chown -R asterisk:asterisk /dev/dahdi