Установка Asterisk 11 + FreePBX 12 на CentOS 7.1


Пошаговая инструкция для установки программной PBX Asterisk 11 и панели управления FreePBX на CentOS 7.1

Условия:

Система CentOS установлена и имеет доступ в интернет.

Подготовка

  1. # yum -y update
  2. Выключить SELinux:
    # vi /etc/selinux/config
  3. # reboot
  4. Дополнительные репозитарии:
    # rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 
    # yum -y install epel-release
    
  5. # yum -y install net-tools mc make gcc kernel-devel gcc-c++ ncurses-devel wget httpd fail2ban mariadb-server mariadb mariadb-devel php iksemel iksemel-devel crypto-utils openssl-devel gmime gmime-devel spandsp spandsp-devel openldap openldap-devel popt-devel  speex speex-devel libcurl-devel speex-tools svn sqlite-devel mod_ssl php-mysql php-pear-MDB2-Driver-mysqli php-mbstring php-gd php-mcrypt libxml2-devel lame bison audiofile-devel sox php-pear-DB php-posix
    # rpm -Uvh https://dl.fedoraproject.org/pub/epel/6/x86_64/libresample-0.1.3-12.el6.x86_64.rpm https://dl.fedoraproject.org/pub/epel/6/x86_64/libresample-devel-0.1.3-12.el6.x86_64.rpm
    
  6. Включаем fail2ban:
    # vi /etc/fail2ban/jail.local
    # cat /etc/fail2ban/jail.local
    [sshd]
    enable = true
    
    [asterisk] 
    enable = true
    
    # systemctl enable fail2ban.service
    # systemctl restart fail2ban.service
    
  7. # cd /root
  8. # wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-11-current.tar.gz 
    # tar -zxf asterisk-11-current.tar.gz
  9. # wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz
    # tar -zxf libpri-1.4-current.tar.gz
    # wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
    # tar -zxf dahdi-linux-complete-current.tar.gz

 Установка  DAHDI, libPRI и Asterisk

  1. # cd dahdi-linux-complete-2.10.2+2.10.2
    # make all
    # make install
    # make config
  2. # cd ../libpri-1.4.15
    # make
    # make install
    
  3. # cd ../asterisk-11.19.0
    # ./configure --prefix=/usr --exec-prefix=/usr --with-crypto --with-dahdi --with-iconv -with-libcurl --with-gmime --with-iksemel --with-mysqlclient --disable-xmldoc --with-pri --with-spandsp --with-ldap --with-libcurl --with-popt --with-resample --with-speex
    # make menuselect
    # ./contrib/scripts/get_mp3_source.sh
    # make
    # make install
    # make samples
    
  4. # ln -s /usr/lib/libasteriskssl.so.1 /usr/lib64/libasteriskssl.so.1
    # ln -s /usr/lib/libpri.so.1.4 /usr/lib64/libpri.so.1.4
    # cat contrib/init.d/rc.redhat.asterisk | sed 's/__ASTERISK_SBIN_DIR__/\/usr\/sbin/' > /etc/init.d/asterisk
    # chmod 755 /etc/rc.d/init.d/asterisk
    # systemctl enable asterisk.service
    
  5. # groupadd asterisk 
    # useradd -c "asterisk PBX" -d /var/lib/asterisk -s /sbin/nologin -g asterisk asterisk
  6. # systemctl enable dahdi
    # systemctl start dahdi
    # systemctl start asterisk
    

Установка FreePBX

  1. в /etc/hosts добавить:
    [IP PBX] pbx.example.com
  2. в конфиг /etc/httpd/conf.d/ssl.conf добавить в секцию <VirtualHost _default_:443>:
    DocumentRoot "/var/www/html"
    ServerName pbx.example.com:443
    
    <Directory "/var/www/html">
    Order allow,deny
    Allow from [Admin IP]
    
    
  3. # systemctl enable httpd
    # systemctl start httpd
    
  4. В /etc/firewalld/zones/public.xml добавить:
    <service name="https"/>
    

    в секцию так же как и ssh

     # systemctl restart firewalld
  5. # systemctl enable mariadb
    # systemctl start mariadb
    # /usr/bin/mysql_secure_installation
    

    Установить пароль root для MySQL

  6. # cd /root
    # wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-12.0-latest.tgz
    # tar -zxf freepbx-12.0-latest.tgz -C /usr/src 
    # cd /usr/src/freepbx
  7. Отредактировать /etc/php.ini:
    # vi /etc/php.ini (или /etc/php4/apache2/php.ini)
    upload_max_filesize=20M
    
  8. # mysqladmin create asteriskcdrdb -p
    # mysql -p asteriskcdrdb < SQL/cdr_mysql_table.sql
    # mysqladmin create asterisk -p
    # mysql -p asterisk < SQL/newinstall.sql 
    # mysql -p 
    mysql> GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY '[ваш пароль]';
    mysql> GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY '[ваш пароль]';
    mysql> flush privileges;
    
  9. Отредактировать:
    # vi /etc/httpd/conf/httpd.conf (или /etc/apache2/apache2.conf):
    User asterisk
    Group asterisk
    
  10. # chown asterisk /var/lib/php/session
  11. # rm -rf /var/www/html
  12. # ./install_amp
  13. Заменить в базе asterisk в таблице freepbx_settings пароль для астериск манагера:
    # mysql -p
    mysql> UPDATE `asterisk`.`freepbx_settings` SET `value` = '[ваш пароль 2]' WHERE `freepbx_settings`.`keyword` = 'AMPMGRPASS';
  14. # chown asterisk /etc/modprobe.d/dahdi.conf
  15. # rm /etc/asterisk/ccss.conf /etc/asterisk/logger.conf /etc/asterisk/iax.conf /etc/asterisk/extensions.conf /etc/asterisk/sip_notify.conf /etc/asterisk/features.conf /etc/asterisk/sip.conf
  16. # systemctl restart httpd
  17. Войти в  freepbx и завершить установку
  18. В /etc/firewalld положить файл direct.xml :
    <?xml version="1.0" encoding="utf-8"?>
     <direct>
     <rule ipv="ipv4" table="filter" chain="INPUT" priority="0">-m udp -p udp -d [IP PBX]/32 --dport 5060 -m hashlimit --hashlimit 10/m --hashlimit-burst 10 --hashlimit-mode srcip,dstip,dstport --hashlimit-htable-expire 180 --hashlimit-name SIP -j ACCEPT</rule>
     <rule ipv="ipv4" table="filter" chain="INPUT" priority="1">-m multiport -m udp -p udp -d [IP PBX]/32 --dports 10000:20000 -j ACCEPT</rule>
     </direct>
              
    
    # systemctl restart firewalld
    

 

Дополнительные установки:

  1.  # yum -y install bind bind-utils mailx ntp
    # systemctl enable named
    # systemctl enable ntpdate
    # systemctl start named
    # systemctl start ntpdate
    # echo “nameserver 127.0.0.1” > /etc/resolv.conf
    # echo “nameserver 8.8.8.8” >> /etc/resolv.conf

 

 

Оставьте комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *