Asterisk & FreePBX Installation Install Asterisk and FreePBX Install FreePBX 15 with Asterisk 16 on Debian 10 Install Asterisk 16 Step 1: Update system sudo apt update && sudo apt upgrade sudo reboot Step 2: Install Asterisk 16 LTS dependencies sudo apt install git curl wget libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev build-essential libjansson-dev libxml2-dev uuid-dev Step 3: Download Asterisk 16 LTS tarball cd /usr/src/ sudo curl -O http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz sudo tar xvf asterisk-16-current.tar.gz cd asterisk-16*/ # download the mp3 decoder library into the source tree sudo contrib/scripts/get_mp3_source.sh # Ensure all dependencies are resolved sudo contrib/scripts/install_prereq install Step 4: Build and Install Asterisk 16 sudo ./configure sudo make menuselect Add-ons: chan_ooh323, format_mp3 Core Sound Packages: CORE-SOUNDS-EN-* Music On Hold File Packages: MOH-OPSOUND-* Extra Sound Packages: EXTRA-SOUNDS-EN-* Applications: app_macro sudo make sudo make install sudo make progdocs sudo make samples sudo make config sudo ldconfig Create Asterisk User sudo groupadd asterisk sudo useradd -r -d /var/lib/asterisk -g asterisk asterisk sudo usermod -aG audio,dialout asterisk sudo chown -R asterisk.asterisk /etc/asterisk sudo chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk sudo chown -R asterisk.asterisk /usr/lib/asterisk Set Asterisk default user to asterisk $ sudo vim /etc/default/asterisk AST_USER="asterisk" AST_GROUP="asterisk" $ sudo vim /etc/asterisk/asterisk.conf runuser = asterisk ; The user to run as. rungroup = asterisk ; The group to run as. Restart asterisk service sudo systemctl restart asterisk # Enable asterisk service to start on system boot sudo systemctl enable asterisk # Test to see if you can connect to Asterisk CLI sudo asterisk -rvv Install FreePBX 15 Step 1:  Install MariaDB Database server sudo apt update sudo apt install mariadb-server mariadb-client # Initial DB setup and set root's password for DB sudo /usr/bin/mysql_secure_installation Step 2: Installing Node.js 10 LTS sudo apt install curl dirmngr apt-transport-https lsb-release ca-certificates curl -sL https://deb.nodesource.com/setup_10.x | sudo bash sudo apt update sudo apt install gcc g++ make sudo apt install nodejs Step 3: Install and configure Apache Web Server sudo apt install apache2 # change Apache user to asterisk and turn on AllowOverride option sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig sudo sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf sudo sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf # Remove default index.html page sudo rm -f /var/www/html/index.html Step 4: Install PHP and required extensions sudo apt install wget php php-pear php-cgi php-common php-curl php-mbstring php-gd php-mysql \ php-gettext php-bcmath php-zip php-xml php-imap php-json php-snmp php-fpm libapache2-mod-php Change php maximum file upload size sudo sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/7.3/apache2/php.ini sudo sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/7.3/cli/php.ini Step 5: Install FreePBX 15 sudo apt install wget cd /usr/src wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-15.0-latest.tgz tar xfz freepbx-15.0-latest.tgz rm -f freepbx-15.0-latest.tgz cd freepbx sudo ./start_asterisk start sudo ./install -n --dbuser root --dbpass "yourpassword" # Enable Apache Rewrite engine sudo a2enmod rewrite sudo systemctl restart apache2 Step 6: Access FreePBX 15 Web Interface Create the first admin account. Q & A Q: Online modules are not available. Error: Warning: Error retrieving updates from online repository(s) (https://mirror.freepbx.org 35). Online modules are not available. A: Change the DNS to 8.8.8.8 vi /etc/resolv.conf nameserver 8.8.8.8 #nameserver 67.207.67.3 #nameserver 67.207.67.2 Reference Install Asterisk 16 with FreePBX 15 on Ubuntu 20.04/18.04/16.04 & Debian 9 Install Asterisk 16 LTS on Ubuntu 20.04/18.04/16.04 & Debian 10/9 How To Install FreePBX 15 on Ubuntu 20.04/18.04/16.04 & Debian 10/9 Installing FreePBX 15 on Debian 9.6 Install FreePBX 15 with Docker Reference https://github.com/tiredofit/docker-freepbx#introduction Incredible PBX Post-Installation Incredible PBX 2027 with Debian 11 Reset the hostname and password: # Set the hostname hostnamectl set-hostname # Set the password passwd # for Root admin-pw-change # for FreePBX apache-pw-change # for Reminders and AsteriDex Set Gmail as an SMTP Smarthost: Create an App password for your Gmail account: https://support.google.com/accounts/answer/185833?hl=en /root/enable-gmail-smarthost-for-sendmail Stop Webmin systemctl stop webmin systemctl disable webmin Learning Q & A A2B 與 FreePBX 的連接 A2Billing Voice Mail Transcription Soft Phone OpenSIPS FreePBX fwconsole Tutorials CLI Commands Help fwconsole help # lists all commands php /usr/sbin/fwconsole list Service Start/Stop # Start Asterisk and run other needed FreePBX commands fwconsole start # Stop Asterisk and run other needed FreePBX commands fwconsole stop Module Admin # Check Online Repository fwconsole ma listonline # Install a module fwconsole ma download ivr fwconsole ma install ivr # Installing specific module versions with multiple modules fwconsole ma install foomodule:15.1.3 barmodule:15.0.9 # Upgrade all modules fwconsole ma listonline | grep "upgrade" fwconsole ma upgradeall # Apply the settings changed fwconsole reload Database 連線資料庫 asterisk (自動從 /etc/freepbx.conf 取得連線資訊) fwconsole mPost-Installation Set root's password for MySQL mysql_secure_installation Log File Rotation If this is not done the log files will keep growing indefinitely.Edit /etc/logrotate.d/asterisk /var/spool/mail/asterisk /var/log/asterisk/*log /var/log/asterisk/full /var/log/asterisk/dtmf /var/log/asterisk/freepbx_dbug /var/log/asterisk/fail2ban { weekly missingok rotate 4 #compress notifempty sharedscripts create 0640 asterisk asterisk postrotate /usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null || true endscript su root root } TFTP If you plan to use hardware SIP phones you will probably want to set up TFTP. yum -y install tftp-server nano /etc/xinetd.d/tftp change server_args = -s /var/lib/tftpboot to server_args = -s /tftpboot change disable=yes to disable=no mkdir /tftpboot chmod 777 /tftpboot systemctl restart xinetd firewall-cmd --permanent --zone=public --add-port=69/udp firewall-cmd --reload MPG123 This is used in combination with sox to convert uploaded mp3 files to Asterisk compatible wav files. cd /usr/src wget http://ufpr.dl.sourceforge.net/project/mpg123/mpg123/1.22.4/mpg123-1.22.4.tar.bz2 tar -xjvf mpg123* cd mpg123*/ ./configure --prefix=/usr --libdir=/usr/lib64 && make && make install && ldconfig Digum addons To register digium® licenses. cd /usr/src wget http://downloads.digium.com/pub/register/linux/register chmod +x register ./register To install the individual addons refer to the README files and ignore the register instructions. http://downloads.digium.com/pub/telephony/codec_g729/README http://downloads.digium.com/pub/telephony/res_digium_phone/README http://downloads.digium.com/pub/telephony/fax/README http://downloads.digium.com/pub/telephony/hpec/README Password protect http access A simple way to block scanners looking for exploits on apache web servers. mkdir -p /usr/local/apache/passwd htpasswd -c /usr/local/apache/passwd/wwwpasswd someusername htpasswd -c /usr/local/apache/passwd/wwwpasswd someotherusername nano /var/www/html/.htaccess # .htaccess files require AllowOverride On in /etc/httpd/conf/httpd.conf AuthType Basic AuthName "Restricted Access" AuthUserFile /usr/local/apache/passwd/wwwpasswd Require valid-user Alternatively, the above .htaccess config can be added to /etc/httpd/conf/httpd.conf or as a separate file in /etc/httpd/conf.d/ as follows. AuthType Basic AuthName "Restricted Area" AuthUserFile /usr/local/apache/passwd/wwwpasswd Require valid-user Whitelist protect http access If http access is only required from certain IP addresses.NOTE: Apache 2.4 以後才支援這功能Edit /etc/httpd/conf.d/whitelist.conf ## Uncomment the following line to disable the whitelist #Require all granted Require ip x.x.x.x Require ip x.x.x.x x.x.x.x x.x.x.x Require ip x.x Require ip x.x.x.0/255.255.255.0 Require host somedomain.com # ## See http://httpd.apache.org/docs/2.4/mod/mod_authz_host.html for more examples # 舊版 Apache 設定NOTE:確定網站目錄有 AllowOverride All 設定.htaccess: order deny,allow deny from all # Alang's IPs allow from 123.123.123.1 allow from 111.222.222.2 allow from 192.168.99. G.729 Codec https://www.asterisk.org/products/add-ons/g729-codec/ http://asterisk.hosting.lv/ OSS Endpoint Manager Links Github: https://github.com/billsimon/endpointman Doc: https://wiki.freepbx.org/display/FPG/OSS+End+Point+Manager EPM-Supported Devices Introducing OSS Endpoint Manager for FreePBX 16 & Incredible PBX 2027 – Nerd Vittles Installation Incredible PBX 2027 cd /var/www/html/admin/modules wget http://incrediblepbx.com/ossepm16.tgz tar zxvf ossepm16.tgz rm -f ossepm16.tgz rm -f /tmp/* fwconsole ma install endpointman fwconsole reload Configuration Package Server FreePBX GUI > Settings > OSS Endpoint Manager > Settings Package Server: http://provision.lol/ FreePBX GUI > Settings > OSS Endpoint Manager > Package Manager Click the Check for Update 如果沒出現更新視窗,檢查網路狀態或稍後再試。 Additional brands (Grandstream & Yeallink V80) Download: SourceForge FreePBX GUI > Settings > OSS Endpoint Manager > Settings > Package Import/Export Brand Package: grandstream.tgz yealinkv80.tgz IP & NTP & Type FreePBX GUI > Settings > OSS Endpoint Manager > Settings IP address of phone server: Internal IP address of phone server: Configuration Type: Web (HTTP) Time Zone: Asia/Taipei Time Server: tw.pool.ntp.org 如果以後有修改 Settings 的內容,或者 Template Editor,完成變更後,還要到 Extension Mapping,選擇 Selected Phone Options 或者 Global Phone Options,按下 Rebuild,這樣才會套用更新到所有裝置的佈署檔。 Extension Provisioning Add Device: Linksys PAP2T FreePBX GUI > Settings > OSS Endpoint Manager > Package Manager Cisco/Linksys - PAP2T : Enable Create Template: my-pap2t 注意:預設的部署檔會將 PAP2T 的管理網頁界面關閉,新增一個部署設定檔 my-pap2t。 技巧:如果 template 內容如果有修改過,必須到 Extension Mapping 選擇分機後,重新執行一次 Save,這樣新的設定才會被套用。 FreePBX GUI > Settings > OSS Endpoint Manager > Template Manager Template Name: my-pap2t Product Select: Linksys/Cisco Clone Template From: PAP2T Edit the template: my-pap2t Profile Resync: 3600 (對應設備參數 Resync_Periodic,秒數不要調太低,避免設備太忙碌更新) Enable Webserver: Yes Enable Webserver Admin: Yes Administrator Password: User Password: 注意:編輯 template 時,不要使用 Edit Global Setting Overrides,這個可能會弄壞 template。如果不小心 弄壞 template,只要將 template 移除後重建即可。 技巧:template 或者原始設定檔 (spa$mac.xml) 有修改過參數,要如何在設備部署前做驗證?以 HTTP 為例,瀏覽這段網址 http://freepbx-ip-addr/provisioning/p.php/spaxxxxxxx.xml,xxxxxxx 是設備的 MAC address (必須是小寫),可以下載部署設定檔。 Extension Mapping FreePBX GUI > Settings > OSS Endpoint Manager > Extension Mapping MAC Address: IPEI: Brand: Cisco/Linksys Model: PAP2T Line: 1 Extension Number: Template: my-pap2t PAP2T 設置 登入 PAP2T 管理界面 (advanced view) > Provisioning Provision Enable: yes Profile Rule:  http:///provisioning/p.php/spa$MA.xml 須重啟電源才會重新部署新設定。 Provisioning Template Files SPA-3102/PAP2T File: spa$mac.xml 將檔案複製到目錄 /var/www/html/admin/modules/_ep_phone_modules/endpoint/cisco/linksysata/ 修正內容: 移除日光節約的時間設定 移除 LAN 關閉 DHCP(SPA3102 必須啟用) 移除部署主機位址的設定(目前只能支援 tftp 方式)