Instalação do SNEP 3 em CentOS 7 + Asterisk 13 + MariaDB

Fonte: http://www.snep.com.br/index.php/artigos-tecnicos/104-instalacao-do-snep-3-em-centos-7-asterisk-13-mariadb

14 Out 2015

Instalação do SNEP 3 em CentOS 7 + Asterisk 13 + MariaDB

Escrito por Heros Santos Amaral Filho.

É com muita satisfação que recebemos mais uma contribuição da comunidade, desta vez por parte de nosso colega Heros Amaral Filho.

Entusiasta do do SNEP, o Heros nos presenteou com este tutorial para o novo SNEP 3. Valeu Heros, a comunidade com certeza irá usufruir muito desta sua contribuição.

Tutorial baseado em:

    • CentoOS - versão 7
    • Asterisk - versão 13
    • PHP - versão 5
    • SNEP - versão 3
    • Maria DB

Importante: Todos os comandos devem ser executados como root.

1 - Instalação do CentOS 7

Padrão minimo + ferramentas de diagnóstico.

2 - Instalação Asterisk 13

2.1 - Atualizar pacotes.

yum update

2.2 - Desabilitar SELinux

sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config

Obs.: Necessário reinicializar o SO. Após reinicialização verificar se o SELinux está desabilitado

sestatus

2.3 - Desabilitar o firewall

systemctl stop firewalld.service systemctl disable firewalld.service

2.4 - Instalar pacotes necessários

2.4.1 - Instalação Jansson (JSON)

wget http://www.digip.org/jansson/releases/jansson-2.5.tar.gz tar -zxf jansson-2.5.tar.gz cd jansson-2.5/ ./configure make clean make all && make install ldconfig

2.4.2 - Instalação Repositório

yum install -y make wget openssl-devel ncurses-devel newt-devel libxml2-devel kernel-devel gcc gcc-c++ sqlite-devel libuuid-devel git sox libiodbc unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devel

2.5 - Instalação Dahdi

cd /usr/src wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz tar -zxf dahdi-linux-complete-current.tar.gz cd dahdi-linux-complete-2.10.2+2.10.2/ make clean make all && make install make config chkconfig dahdi on

2.6 - Instalação Libpri

cd /usr/src wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz tar -zxf libpri-1.4-current.tar.gz cd libpri-1.4.15/ make all && make install

2.7 - Instalação Asterisk

cd /usr/src wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz tar -zxf asterisk-13-current.tar.gz cd asterisk-13.5.0/ make clean ./configure –libdir=/usr/lib64 make && make install make samples make config chkconfig asterisk on

3 - Instalação LAMP

3.1 - Instalação banco de dados

yum -y install mariadb-server mariadb systemctl start mariadb.service systemctl enable mariadb.service mysql_secure_installation

[root@server1 ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current

password for the root user. If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none): <--ENTER

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

Set root password? [Y/n]

New password: <--para o padrão do SNEP a senha é sneppass

Re-enter new password: <--confirma a senha sneppass

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] <-- (Y) ENTER

... Success!

Normally, root should only be allowed to connect from 'localhost'. This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] <-- (N) ENTER

... Success!

By default, MariaDB comes with a database named 'test' that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] <-- (N) ENTER

- Dropping test database...

... Success!

- Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] <-- (Y) ENTER

... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB

installation should now be secure.

Thanks for using MariaDB!

3.2 - Instalação servidor WEB

yum -y install httpd systemctl start httpd.service systemctl enable httpd.service firewall-cmd --permanent --zone=public --add-service=http firewall-cmd --permanent --zone=public –add-service=https firewall-cmd --reload

3.3 - Instalação PHP 5

yum -y install php systemctl restart httpd.service

3.4 - Instalação suporte MariaDB para PHP5

yum -y install php-mysql yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel systemctl restart httpd.service

4 - Instalação SNEP

4.1 - Fonte do SNEP

cd /var/www/html git clone link_do_git mv snep-3 snep

4.2Ajuste de permissões

cd /var/www/html find . -type f -exec chmod 640 {} \; -exec chown apache:apache {} \; find . -type d -exec chmod 755 {} \; -exec chown apache:apache {} \; chmod +x /var/www/html/snep/agi/*

4.3 - Ajuste dos diretórios

mkdir /var/log/snep cd /var/log/snep touch ui.log touch agi.log ln -s /var/log/asterisk/full full chown -R apache.apache * cd /var/www/html/snep/ ln -s /var/log/snep logs cd /var/lib/asterisk/agi-bin/ ln -s /var/www/html/snep/agi/ snep cd /var/spool/asterisk/ rm -rf monitor ln -sf /var/www/html/snep/arquivos monitor

4.4 - Ajuste do Apache

Para a configuração do apache deve-se copiar o conteúdo do arquivo:

/var/www/html/snep/install/snep.apache2

para o arquivo:

/etc/httpd/conf/httpd.conf

Obs: reiniciar o apache

systemctl restart httpd.service

4.5 - Arquivos do SNEP em /etc/asterisk

cd /etc cp -p -r asterisk/ /root/bck_etc_asterisk (Importante fazer backup caso haja necessidade de restaurar algum arquivo) rm -rf asterisk cp -avr /var/www/html/snep/install/etc/asterisk . cp /var/www/html/snep/install/etc/odbc* .

4.6 - Ajuste configuração de sons

cd /usr/src wget -c http://www.sneplivre.com.br/downloads/asterisk-sounds.tgz tar -xzf asterisk-sounds.tgz -C /var/lib/asterisk/ cd /var/lib/asterisk/sounds mkdir -p tmp backup pt_BR/tmp pt_BR/backup chown -R apache:apache *

4.7 - Ajuste Musica em Espera

cd /var/lib/asterisk/moh mkdir tmp backup mkdir -p snep_1/tmp snep_1/backup mkdir -p snep_2/tmp snep_2/backup mkdir -p snep_3/tmp snep_3/backup chown -R apache.apache *

4.8 - Ajuste dos arquivos de sons do Asterisk com o SNEP

mkdir -p /var/www/html/snep/sounds cd /var/www/html/snep/sounds/ ln -sf /var/lib/asterisk/moh/ moh ln -sf /var/lib/asterisk/sounds/pt_BR/ pt_BR

4.9 - Criar base de dados, usuário e dados iniciais

cd /var/www/html/snep/install/database mysql -u root -p < database.sql mysql -u root -p sneppass < schema.sql mysql -u root -p sneppass < system_data.sql mysql -u root -p sneppass < core-cnl.sql

4.10 - Ajustes Finais

- Os arquivos odbc.ini e odbcinst.ini devem ficar exatamente como a seguir:

/etc/odbc.ini

; ###OPENS### [MySQL-snep] Description = MySQL ODBC Driver Driver = /usr/lib64/libmyodbc5w.so Socket = /var/lib/mysql/mysql.sock Server = localhost User = snep Password = sneppass Database = snep Option = 3

/etc/odbcinst.ini

; ###OPENS### [MySQL] Description = MySQL ODBC MyODBC Driver Driver = /usr/lib64/libmyodbc5w.so FileUsage = 1 [Text] Description = ODBC for Text Files Driver = /usr/lib64/libodbctxtS.so Setup = /usr/lib64/libodbctxtS.so FileUsage = 1 CPTimeout = CPReuse =

Deverá ser copiado os arquivos asterisk.conf e modules.conf para a pasta /etc/asterisk sobreescrevendo os atuais.

Material de apoio:

  • Manual de instalação do snep no CentOS By Urick.
  • Manual de instalação do SNEP 3 By OpenS.