記得20年前家裏剛裝電話時,一線需要兩三千塊(RMB),後來裝電話越來越便宜直到免費。現在借助於Asterisk, FreePBX,可以在家構建自己的電話局,如果你在海外,通過自己的電話局可以非常方便的和國內或其他地方的親朋好友聯系。

 

下面給出在Ubuntu 12.04 上安裝Asterisk,FreePBX的基本步驟。

 

1. 首先是更新系統(可選)

 

在命令列中輸入
sudo apt-get update
sudo apt-get upgrade
2. 安裝LAMP (Apache2+MySQL+PHP)
在命令列輸入
sudo tasksel
選擇 LAMP Server
201211140001  
3. 添加額外的PHP 軟件包
sudo apt-get install php5-gd php-pear php-db sox curl
4. 安裝phpmyadmin (可選)
sudo apt-get install phpmyadmin
5. 安裝asterisk
sudo apt-get install asterisk asterisk-mysql asterisk-mp3
6. 安裝Freepbx准備工作
在安裝Freepbx我們先要想好將Freepbx 安裝在哪個目錄下,FreePBX 為asterisk 的Web管理應用,可以幫助用戶配置Asterisk等。
1) Ubuntu 的Web根目錄為/var/www, 因此我們可以把FreePBX安裝到/var/www/freepbx 目錄下,為便於管理,創建三個子目錄
conf 設置檔
log 存放日誌
public WEB應用。
sudo mkdir /var/www/freepbx/
sudo mkdir /var/www/freepbx/conf
sudo mkdir /var/www/freepbx/log
sudo mkdir /var/www/freepbx/public

 

2) 創建設置檔 /var/www/freepbx/conf/vhost.conf
sudo vim /var/www/freepbx/conf/vhost.conf
輸入以下內容



<VirtualHost *:80>
ServerName freepbx
ServerAlias freepbx

 

ServerAdmin james.shen@guidebee.com
ErrorLog /var/www/freepbx/log/error.log
CustomLog /var/www/freepbx/log/access.log combined

 

DocumentRoot /var/www/freepbx/public
<Directory /var/www/freepbx/public>
Options Indexes FollowSymLinks MultiViews
Order allow,deny
AllowOverride All
Allow from all
</Directory>

 

<Directory /var/www/freepbx/public/admin>
AuthType Basic
AuthName "Restricted Area"
AuthUserFile freepbx-passwd
Require user admin
</Directory>
</VirtualHost>





修改 ServerAdmin 到你自己的Email位址。
3) 將vhost 添加到 Apache的sites-enabled目錄下

 

sudo ln -s /var/www/freepbx/conf/vhost.conf /etc/apache2/sites-available/freepbx
cd /etc/apache2/sites-enabled/
sudo ln -s ../sites-available/freepbx

 

4) 創建 用戶和密碼來驗證合法用戶可以來配置FreePBX (有權限訪問該網頁)

 

sudo htpasswd -c /etc/apache2/freepbx-passwd admin

 

5) 重啟Apache
sudo /etc/init.d/apache2 restart
有了這些准備工作後,就可以開始安裝FreePBX了
7. 安裝FreePBX
1) 下載FreePBX安裝包
cd /tmp
wget HTTP://mirror.freepbx.org/freepbx-2.8.1.tar.gz
cd /usr/src
sudo tar xvzf /tmp/freepbx-2.8.1.tar.gz
cd freepbx-2.8.1/
2) 創建數據庫
mysqladmin create asterisk -u root -p
mysqladmin create asteriskcdrdb -u root -p
mysql -u root -p asterisk < SQL/newinstall.sql
mysql -u root -p asteriskcdrdb < SQL/cdr_mysql_table.sql
3) 創建數據庫用戶
mysql -u root -p
在SQL命令列輸入

 

GRANT ALL PRIVILEGES ON asterisk.* TO asterisk@localhost IDENTIFIED BY ‘badasspassword’;
GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asterisk@localhost IDENTIFIED BY ‘badasspassword’;
flush privileges;
quit;

 

注意將badasspassword 換成你自己選擇的密碼。

 

4) 備份modules.conf , FreePBX安裝時會修改Apache的設定檔

 

sudo cp /etc/asterisk/modules.conf ~/asterisk-modules.conf

 

5) 安裝FreePBX

 

sudo ./install_amp

 

輸入對應的參數
Enter your USERNAME to connect to the 'asterisk' database:
[asteriskuser] asterisk
Enter your PASSWORD to connect to the 'asterisk' database:
[amp109] badasspassword
Enter 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]
Enter the path to use for your AMP web root:
[/var/www/html]
/var/www/freepbx/public
Enter the IP ADDRESS or hostname used to access the AMP web-admin:
[xx.xx.xx.xx] freepbx
Enter a PASSWORD to perform call transfers with the Flash Operator Panel:
[passw0rd] password
Use simple Extensions [extensions] admin or separate Devices and Users [deviceanduser]?
[extensions]
Enter directory in which to store AMP executable scripts:
[/var/lib/asterisk/bin]




6)恢復asterisk-modules.conf

 

sudo cp ~/asterisk-modules.conf /etc/asterisk/modules.conf

 

7) 添加asterisk用戶

 

sudo adduser www-data asterisk

 

修改權限/etc/amportal.conf 中添加
AMPASTERISKUSER=www-data
AMPASTERISKGROUP=asterisk
AMPASTERISKWEBUSER=www-data
AMPASTERISKWEBGROUP=asterisk
重啟amportal
sudo amportal start
8) 使用amport 啟動Asterisk
sudo update-rc.d -f asterisk remove
sudo sed -e s/BACKGROUND=0/BACKGROUND=1/ -i /usr/sbin/safe_asterisk
修改/etc/rc.local
在exit 0 前添加
/usr/local/sbin/amportal start
9) 重啟Ubuntu, 可以登錄到 HTTP://your web address/freepbx/public

201211140002  

到此為止就安裝好FreePBX,下面就是配置FreePBX,後面有時間在寫配置部分。
配置好Trunk, Extension, OutboundRoutes 等之後,你的電話局就建好了,可以通過Extension分配電話好碼,如過需要外線可以通過配置Trunk和
OutboundRoutes。 配置好首頁會顯示當前在線用戶數目和可用外線。現在就可以開始打電話了 :-) .
201211140003 
From:CSDN
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()