Пошаговая инструкция для установки программной PBX Asterisk 11 и панели управления FreePBX на CentOS 7.1
Условия:
Система CentOS установлена и имеет доступ в интернет.
Подготовка
# yum -y update
- Выключить SELinux:
# vi /etc/selinux/config
# reboot
- Дополнительные репозитарии:
# rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm # yum -y install epel-release
# 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
- Включаем 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
# cd /root
# wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-11-current.tar.gz # tar -zxf asterisk-11-current.tar.gz
# 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
# cd dahdi-linux-complete-2.10.2+2.10.2 # make all # make install # make config
# cd ../libpri-1.4.15 # make # make install
# 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
# 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
# groupadd asterisk # useradd -c "asterisk PBX" -d /var/lib/asterisk -s /sbin/nologin -g asterisk asterisk
# systemctl enable dahdi # systemctl start dahdi # systemctl start asterisk
Установка FreePBX
- в /etc/hosts добавить:
[IP PBX] pbx.example.com
- в конфиг /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]
# systemctl enable httpd # systemctl start httpd
- В /etc/firewalld/zones/public.xml добавить:
<service name="https"/>
в секцию так же как и ssh
# systemctl restart firewalld
# systemctl enable mariadb # systemctl start mariadb # /usr/bin/mysql_secure_installation
Установить пароль root для MySQL
# 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
- Отредактировать /etc/php.ini:
# vi /etc/php.ini (или /etc/php4/apache2/php.ini) upload_max_filesize=20M
# 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;
- Отредактировать:
# vi /etc/httpd/conf/httpd.conf (или /etc/apache2/apache2.conf): User asterisk Group asterisk
# chown asterisk /var/lib/php/session
- # rm -rf /var/www/html
# ./install_amp
- Заменить в базе asterisk в таблице freepbx_settings пароль для астериск манагера:
# mysql -p mysql> UPDATE `asterisk`.`freepbx_settings` SET `value` = '[ваш пароль 2]' WHERE `freepbx_settings`.`keyword` = 'AMPMGRPASS';
# chown asterisk /etc/modprobe.d/dahdi.conf
# 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
# systemctl restart httpd
- Войти в freepbx и завершить установку
- В /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
Дополнительные установки:
# 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