Hướng dẫn cài FreePBX 15 trên Ubuntu 20.04 LTS (update asterisk 18 LTS)

Yêu cầu

  • Server OS : Ubuntu 20.04 LTS
  • RAM : 2 GB
  • Disk : 50 GB
  • CPU : 2

Step #01: Cài đặt các gói bổ sung trước khi cài FreePBX 15.

[email protected]:~# apt-get install -y build-essential linux-headers-`uname -r` openssh-server apache2 mariadb-server mariadb-client bison flex php php-curl php-cli php-pdo php-mysql php-pear php-gd curl  sox libncurses5-dev libssl-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libicu-dev libcurl4-openssl-dev libical-dev libneon27-dev libspandsp-dev sudo subversion libtool-bin python-dev unixodbc dirmngr php-mbstring sendmail -y

Step #02: Cài nodejs

[email protected]:~# curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
[email protected]:~# apt-get install -y nodejs
[email protected]:~# reboot

Step #03: Download asterisk và các gói phụ trợ

[email protected]:~# cd /usr/src/
[email protected]:/usr/src/# wget https://wiki.freepbx.org/download/attachments/122487323/mariadb-connector-client-library_3.0.8-1_amd64.deb
[email protected]:/usr/src/# wget https://wiki.freepbx.org/download/attachments/122487323/mariadb-connector-odbc_3.0.7-1_amd64.deb
[email protected]:/usr/src/# dpkg -i mariadb-connector-client-library_3.0.8-1_amd64.deb
[email protected]:/usr/src/# dpkg -i mariadb-connector-odbc_3.0.7-1_amd64.deb
[email protected]:/usr/src/# pear install Console_Getopt
[email protected]:/usr/src/# wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz
[email protected]:/usr/src/# wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
[email protected]:/usr/src/# wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz
[email protected]:/usr/src/# tar xvfz dahdi-linux-complete-current.tar.gz
[email protected]:/usr/src/# rm -f dahdi-linux-complete-current.tar.gz

Step #04: Cài đặt DAHDI và LIBPRI 

[email protected]:/usr/src/# cd dahdi-linux-complete-*
[email protected]:/usr/src/dahdi-linux-complete-3.0.0+3.0.0# make all
[email protected]:/usr/src/dahdi-linux-complete-3.0.0+3.0.0# make install
[email protected]:/usr/src/dahdi-linux-complete-3.0.0+3.0.0# make config
[email protected]:/usr/src/dahdi-linux-complete-3.0.0+3.0.0# cd /usr/src
[email protected]:/usr/src/# tar xvfz libpri-current.tar.gz
[email protected]:/usr/src/# rm -f libpri-current.tar.gz
[email protected]:/usr/src/# cd libpri-*
[email protected]:/usr/src/libpri-1.6.0# make
[email protected]:/usr/src/libpri-1.6.0# make install

Step #05: Cài đặt asterisk 18 LTS

[email protected]:/usr/src/libpri-1.6.0# cd /usr/src
[email protected]:/usr/src/# tar xvfz asterisk-18-current.tar.gz
[email protected]:/usr/src/# rm -f asterisk-18-current.tar.gz
[email protected]:/usr/src/# cd asterisk-*
[email protected]:/usr/src/asterisk-18.6.0# contrib/scripts/get_mp3_source.sh
[email protected]:/usr/src/asterisk-18.6.0# contrib/scripts/install_prereq install
[email protected]:/usr/src/asterisk-18.6.0# ./configure --with-pjproject-bundled --with-jansson-bundled
[email protected]:/usr/src/asterisk-18.6.0# make menuselect
[email protected]:/usr/src/asterisk-18.6.0# menuselect/menuselect --enable app_macro --enable format_mp3 menuselect.makeopts
[email protected]:/usr/src/asterisk-18.6.0# make
[email protected]:/usr/src/asterisk-18.6.0# make install
[email protected]:/usr/src/asterisk-18.6.0# make config
[email protected]:/usr/src/asterisk-18.6.0# ldconfig
[email protected]:/usr/src/asterisk-18.6.0# update-rc.d -f asterisk remove

– Note: update php5.6 (Freepbx chạy ổn định trên vesion này)

add-apt-repository ppa:ondrej/php
apt-get update
apt-get install php5.6 php5.6-xml php5.6-mysql php5.6-mbstring
update-alternatives --set php /usr/bin/php5.6
a2dismod php7.4
a2enmod php5.6
systemctl restart apache2

Step #06: Thêm asterisk user và cài đặt permission

[email protected]:/usr/src/asterisk-18.6.0# cd
[email protected]:~# useradd -m asterisk
[email protected]:~# chown asterisk. /var/run/asterisk
[email protected]:~# chown -R asterisk. /etc/asterisk
[email protected]:~# chown -R asterisk. /var/{lib,log,spool}/asterisk
[email protected]:~# chown -R asterisk. /usr/lib/asterisk
[email protected]:~# rm -rf /var/www/html
[email protected]:~# sed -i 's/\(^upload_max_filesize = \).*/0M/' /etc/php/7.2/apache2/php.ini
[email protected]:~# cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
[email protected]:~# sed -i 's/${APACHE_RUN_USER}/asterisk/' /etc/apache2/apache2.conf
[email protected]:~# sed -i 's/${APACHE_RUN_GROUP}/asterisk/' /etc/apache2/apache2.conf
[email protected]:~# sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
[email protected]:~# a2enmod rewrite
[email protected]:~# systemctl restart apache2

Step #07: Tạo odbc

cat <<EOF > /etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL (MariaDB)
Driver = /usr/local/lib/libmaodbc.so
FileUsage = 1
EOF

Step #08: Tạo file odbc khác cho asterisk report.

cat <<EOF > /etc/odbc.ini
[MySQL-asteriskcdrdb]
Description = MySQL connection to 'asteriskcdrdb' database
Driver = MySQL
Server = localhost
Database = asteriskcdrdb
Port = 3306
Socket = /var/run/mysqld/mysqld.sock
EOF

Step #09: Download FreePBX 15 và cài đặt

[email protected]:~# cd /usr/src
[email protected]:/usr/src# wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-15.0-latest.tgz
[email protected]:/usr/src# tar vxfz freepbx-15.0-latest.tgz
[email protected]:/usr/src# rm -f freepbx-15.0-latest.tgz
[email protected]:/usr/src# touch /etc/asterisk/{modules,cdr}.conf
[email protected]:/usr/src# cd freepbx
[email protected]:/usr/src/freepbx# ./start_asterisk start
[email protected]:/usr/src/freepbx# ./install -n

Tạo service cho Freebx

cat > /etc/systemd/system/freepbx.service <<EOF
[Unit]
Description=Freepbx
After=mariadb.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/fwconsole start
ExecStop=/usr/sbin/fwconsole stop

[Install]
WantedBy=multi-user.target
EOF
systemctl enable freepbx

Step #10:  Login với admin account và update module. 

Bây giờ vào trình duyệt login ip server và hưởng thụ thành quả.

Chúc các bạn thành công!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top