Installer Asterisk et FreePBX sur CentOS 7

En cours de rédaction, à vos risques et périls

Configuration des dépôts

Le dépôt tucny contient les RPMS nécessaires:

cat <<'_EOF' > /etc/yum.repos.d/tucny-asterisk.repo [asterisk-common] name=Asterisk Common Requirement Packages @ tucny.com #baseurl=https://ast.tucny.com/repo/asterisk-common/el$releasever/$basearch/ mirrorlist=https://ast.tucny.com/mirrorlist.php?release=$releasever&arch=$basearch&repo=asterisk-common enabled=1 gpgcheck=1 gpgkey=https://ast.tucny.com/repo/RPM-GPG-KEY-dtucny [asterisk-13] name=Asterisk 13 Packages @ tucny.com #baseurl=https://ast.tucny.com/repo/asterisk-13/el$releasever/$basearch/ mirrorlist=https://ast.tucny.com/mirrorlist.php?release=$releasever&arch=$basearch&repo=asterisk-13 enabled=1 gpgcheck=1 gpgkey=https://ast.tucny.com/repo/RPM-GPG-KEY-dtucny _EOF rpm --import https://ast.tucny.com/repo/RPM-GPG-KEY-dtucny

Installation des paquets

Asterisk et ses composants

yum install asterisk asterisk-sounds-core-{en,fr}-{siren14,siren7,sln16,ulaw,wav} asterisk-voicemail-plain asterisk-pjsip asterisk-mysql asterisk-ael asterisk-iax2 asterisk-sip

Dépendances pour FreePBX

yum install mariadb-server php-mysql php-fpm httpd mod_ssl php-mbstring php-xml php-cli php-pear tftp-server nmap
pear install Console_Getopt

Démarrer les services

systemctl start mariadb.service systemctl enable mariadb.service systemctl start httpd systemctl enable httpd systemctl start php-fpm systemctl enable php-fpm

Désactiver SELinux

sed -i -e "s/SELINUX=.*/SELINUX=disabled/" /etc/selinux/config setenforce 0
Voir pour créer une politique de sécurité au lieu de désactiver SELinux entièrement

Configurer la partie web

mkdir /var/lib/php/ast-sessions chown asterisk:asterisk /var/lib/php/ast-sessions chmod 770 /var/lib/php/ast-sessions chown asterisk:asterisk /var/log/php/www/ chmod 770 /var/log/php/www/ cat <<'_EOF' > /etc/php-fpm.d/www.conf [www] listen = /run/php-fpm/www.sock listen.owner = apache listen.group = apache listen.mode = 0660 user = asterisk group = asterisk pm = dynamic pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 500 php_admin_value[error_log] = /var/log/php/www/error.log php_admin_flag[log_errors] = on php_value[session.save_handler] = files php_value[session.save_path] = /var/lib/php/ast-sessions php_admin_value[memory_limit] = 256M _EOF cat <<'_EOF' > /etc/httpd/conf.d/php-fpm.conf <FilesMatch \.php$> SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost" </FilesMatch> cat <<'_EOF' > /etc/httpd/conf.d/freepbx.conf <Directory /var/www/html> DirectoryIndex index.php Options +FollowSymlinks AllowOverride All </Directory> _EOF systemctl restart httpd systemctl restart php-fpm

</code>

Configurer MariaDB

mysql_secure_installation

Créer le rep pour le provisioning

mkdir -p /tftpboot/{contacts,logs,overrides,licenses,bmp} chown asterisk:asterisk /tftpboot mkdir -p /tftpboot/config_bkp/contacts chown -R asterisk:asterisk /tftpboot/config_bkp chmod 750 /tftpboot chmod 770 /tftpboot/{contacts,logs,overrides,bmp} chown PlcmSpIp:asterisk /tftpboot/{contacts,logs,overrides,licenses,bmp}
yum install vsftpd
useradd PlcmSpIp -d /tftpboot usermod -a -G asterisk PlcmSpIp passwd PlcmSpIp
Configurer un mot de passe au compte PlcmSpIp, il sera utilisé par les téléphone au démarrage pour récupérer leur configuration
systemctl enable vsftpd systemctl start vsftpd
cat <<'_EOF' > /etc/vsftpd/user_list PlcmSpIp _EOF cat <<'_EOF' >> /etc/vsftpd/vsftpd.conf userlist_deny=NO _EOF sed -i -e "s/anonymous_enable=.*/anonymous_enable=NO/" \ -e "s/local_umask=.*/local_umask=007/" \ /etc/vsftpd/vsftpd.conf cat <<'_EOF' > /etc/vsftpd/chroot_list PlcmSpIp _EOF

Télécharger FreePBX

cd /usr/src wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-13.0-latest.tgz tar xfz freepbx-13.0-latest.tgz rm -f freepbx-13.0-latest.tgz cd freepbx

Les répertoires pour les packs de voix

mkdir -p /var/lib/asterisk/sounds/custom chown -R asterisk:asterisk /var/lib/asterisk/sounds/ ln -s /usr/share/asterisk/sounds/fr /var/lib/asterisk/sounds/fr

Créer les bases de données

mysql
CREATE DATABASE freepbx; CREATE DATABASE asteriskcdrdb; GRANT ALL privileges ON freepbx.* TO 'freepbx'@'localhost' IDENTIFIED BY 'p@ssw0rd'; GRANT ALL privileges ON asteriskcdrdb.* TO 'freepbx'@'localhost' IDENTIFIED BY 'p@ssw0rd';

Éditer /etc/asterisk/asterisk.conf et enlever (!) sur la première ligne

Lancer l'installation

systemctl start asterisk ./install