Você está na página 1de 25

Tutorial de Instalao

Instalao do Sneplivre 1.3.9.6 (fonte) em Asterisk 1.4.44


Distribuio Linux CentOS 6.5 x86_64 (64 bits)

Elaborado por: Urik B. da Silva


E-mail: urikbs@gmail.com
Atualizado em: 30/01/2014
SNEP Livre http://www.sneplivre.com.br

1/25

Atribuio Uso no-comercial Compartilhamento pela mesma licena 2.5 Brasil

Voc pode:

Copiar, distribuir, exibir e executar a obra.

Sob as seguintes condies:


Atribuio: Voc deve dar crdito ao autor original, da
forma especificada pelo autor ou licenciante.

Uso no-comercial: Voc no pode utilizar esta obra


com finalidades comerciais
Compartilhamento pela mesma licena: Se voc
alterar, transformar ou criar outra obra com base nesta,
voc somente poder distribuir a obra resultante sob
uma licena idntica a esta.

A reproduo do material contido neste tutorial permitido desde que se incluam os crditos
ao autor em local visvel.

SNEP Livre http://www.sneplivre.com.br

2/25

ndice de ilustraes
Ilustrao 1: PHP 5.4.4.......................................................................................................................12
Ilustrao 2: Erro - Forbidden Apache...............................................................................................18
Ilustrao 3: Bem vindo ao SNEP Livre.............................................................................................19
Ilustrao 4: Tela de diagnsticos.......................................................................................................19
Ilustrao 5: Configurao do Sistema...............................................................................................20
Ilustrao 6: Tela de login do Sistema................................................................................................20
Ilustrao 7: Tela de Status do Sistema..............................................................................................21

SNEP Livre http://www.sneplivre.com.br

3/25

Sumrio
Verso...................................................................................................................................................4
1. Objetivo............................................................................................................................................5
2. Configurando rede e definindo hostname.........................................................................................6
3. Atualizando o sistema.......................................................................................................................7
4. Instalando o Apache2.......................................................................................................................7
4.1 Liberando Apache no Iptables...................................................................................................8
4.2 Desabilitando o SELinux...........................................................................................................9
5. Instalando o MySQL......................................................................................................................10
Guarde a senha de root!......................................................................................................................11
6. Instalao do PHP5.........................................................................................................................12
7. Instalando as dependncias pr-compilao do Asterisk................................................................13
7.1 Instalando o headers.................................................................................................................13
7.2 Obtendo e Instalando o Asterisk..............................................................................................14
8. Obtendo e instalando o SNEP Livre...............................................................................................15
9. Extras..............................................................................................................................................22
3.1 Iptables.....................................................................................................................................22
10. Consideraes Finais....................................................................................................................26

Verso
Criado/Alterado

Data

Verso

Urik B. Da Silva

30/01/2014

V1.0

SNEP Livre http://www.sneplivre.com.br

4/25

1. Objetivo

O objetivo desse pequeno tutorial (Howto) guiar usurios iniciantes ou avanados para
proceder uma instalao do SNEP Livre usando os pacotes fontes, compilando o Asterisk e
resolvendo dependncias na mo a partir do sistema operacional CentOS.
Nesse tutorial no sero abordados aspectos de instalao, particionamento do CentOs.
Como referncia, pode ser consultado o site oficial: http://www.centos.org/docs/5/
As verses utilizadas nesse tutorial so:
CentOS 6.5 x86_64 minimal Disponvel em: http://centos.ufms.br/6.5/isos/x86_64/
Asterisk 1.4.44 Disponvel em:
http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.4.44.tar.gz
SNEP Livre 1.3.9.6 Disponvel em: http://sourceforge.net/projects/snep/files/snep/stable/
O procedimento completo de todas as etapas deve durar entre 30 e 50 minutos, dependendo do seu
nvel de familiaridade com o SNEP, Asterisk e Linux.
Notas:
Voc dever efetuar todos os passos abaixo utilizando o usurio root (#);
Anote as senhas que voc usar, elas sero importantes nos passos;

SNEP Livre http://www.sneplivre.com.br

5/25

2. Configurando rede e definindo hostname


Logo aps efetuar a instalao do sistema, ser preciso definir o IP e o hostname do seu servidor.
- Por padro, utilizaremos o nome sneplive.
- No ambiente desse tutorial foi usado o IP 10.48.0.128. Ajuste ao seu ambiente.
Configurando a rede:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
Remova do arquivos as linhas HWADDR e UUID, ficando como como abaixo:
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=10.48.0.128
NETMASK=255.255.255.0
GATEWAY=10.48.0.254

Setando o hostname:
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=sneplivre.localdomain

Ajustando o hosts:
vi /etc/hosts
Deixe como abaixo:
127.0.0.1
127.0.0.1
::1

localhost localhost.localdomain
sneplivre sneplivre.localdomain
sneplivre sneplivre.localdomain

Aps feito as configuraes, reinicie o servidor para confirmar se funcionou:


reboot

SNEP Livre http://www.sneplivre.com.br

6/25

3. Atualizando o sistema
Antes de proceder com a instalao dos pacotes especficos, faa uma atualizao dos pacotes
padro do sistema:
yum update
Total size: 52 M
Is this ok [y/N]: y
Installed:
kernel.x86_64 0:2.6.32-431.3.1.el6
Complete!

4. Instalando o Apache2
yum install httpd -y
Antes de proceder edite o arquivo /etc/httpd/conf/httpd.conf e na linha 58, abaixo de ServerRoot
adicione a linha:
vi /etc/httpd/conf/httpd.conf
ServerName sneplivre
Salve e saia do arquivo.
Configure o Apache para iniciar automaticamente a cada boot:
service httpd start
chkconfig httpd on
Nesse ponto, mesmo com o Apache instalado, voc no ir conseguir acess-lo devido s
configuraes do iptables.
Se quiser adicionar regra, proceda conforme abaixo, ou desabilite o Selinux, tambm apresentado
abaixo.

SNEP Livre http://www.sneplivre.com.br

7/25

4.1 Liberando Apache no Iptables


vim /etc/sysconfig/iptables
Adicione a linha:
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

Reinicie o servio: service iptables restart


Testar acesso ao Apache:
http://IPdoservidor

SNEP Livre http://www.sneplivre.com.br

8/25

4.2 Desabilitando o SELinux


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

SNEP Livre http://www.sneplivre.com.br

9/25

5. Instalando o MySQL
yum install mysql mysql-server -y
Configure o Apache para iniciar automaticamente a cada boot:
service mysqld start
chkconfig mysqld on
Por padro, o MySQL no vm com senha de root setada.
Proceda como abaixo para efetuar a definio da senha de root:
mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, 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 MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL 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
... 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] Y
... Success!

SNEP Livre http://www.sneplivre.com.br

10/25

By default, MySQL 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] Y
- 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
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!

Guarde a senha de root!

SNEP Livre http://www.sneplivre.com.br

11/25

6. Instalao do PHP5
yum install php -y
Crie o arquivo info.php com o contedo para testar o funcionamento do PHP:
vi /var/www/html/info.php
<?php phpinfo() ?>
http://IPdoservidor/info.php
Se voc ver uma pgina com vrias informaes do sistema e mdulo PHP instalados, prossiga com
a instalao. Seno, reveja algum passo acima.

Ilustrao 1: PHP 5.4.4


Instalando demais pacotes PHP necessrios:
yum install php-mysql php-cgi php-gd php-pear -y

Efetuando ajuste importante no php.ini:


vi /etc/php.ini
Na linha 717, altere:
DE: register_argc_argv = Off
PARA: register_argc_argv = On

Aps finalizar a instalao e ajustes, reinicie o Apache


service httpd restart

SNEP Livre http://www.sneplivre.com.br

12/25

7. Instalando as dependncias pr-compilao do Asterisk


yum install -y unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devel wget openssl-devel
ncurses-devel make newt-devel libxml2-devel kernel-devel gcc gcc-c++ libuuid-devel
Outras dependncias importantes:
yum install -y sox

7.1 Instalando o headers


yum install kernel-headers -y

SNEP Livre http://www.sneplivre.com.br

13/25

7.2 Obtendo e Instalando o Asterisk


cd /usr/src
wget -c http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.4.44.tar.gz
tar -zxvf asterisk-1.4.44.tar.gz
cd asterisk-1.4.44/
./configure
make menuselect
Confirme se os driver ODBC esto instalados:
---> Call Detail Recording
[*] cdr_csv
[*] cdr_custom
[*] cdr_manager
[*] cdr_odbc
---> Channel Drivers
Marque a opo [*] chan_features

Se sim, sai do menu (ESC) e siga os passos abaixo. Se no, reveja algum passo acima.
Enter S to save your changes, and exit
S

make && make install


Finalizando a instalao, adicionando o inicializvel do Asterisk no init.d
cp /usr/src/asterisk-1.4.44/contrib/init.d/rc.redhat.asterisk /etc/init.d/asterisk
cd /etc/init.d
service asterisk start
chkconfig asterisk on
Testando o acesso ao Asterisk:
rasterisk
Asterisk 1.4.44, Copyright (C) 1999 - 2010 Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=======================================================================
==
Connected to Asterisk 1.4.44 currently running on sneplivre (pid = 26565)
Verbosity is at least 3
sneplivre*CLI>

SNEP Livre http://www.sneplivre.com.br

14/25

8. Obtendo e instalando o SNEP Livre


cd /usr/src
tar -zxvf sneplivre-1.3.9.6.tar.gz
mv sneplivre /var/www/html/
chown -R apache.apache /var/www/html/sneplivre/
Criando links simblicos:
ln -s /var/www/html/sneplivre /var/www/html/snep
ln -s /var/www/html/sneplivre/ /var/www/snep
Habilitando Virtual Hosts no Apache:
mkdir /etc/httpd/sites-enabled
echo Include /etc/httpd/sites-enabled/ >> /etc/httpd/conf/httpd.conf
cp /var/www/snep/install/snep.apache2 /etc/httpd/sites-enabled/001-snep
Reinicie o Apache:
service httpd restart

SNEP Livre http://www.sneplivre.com.br

15/25

Copiando os arquivos do Asterisk:


cp -avr /var/www/snep/install/etc/asterisk/ /etc/
Copiando os arquivos da conexo ODBC:
cp /var/www/snep/install/etc/*.ini /etc/
cp: sobrescrever "/etc/odbc.ini"? y
cp: sobrescrever "/etc/odbcinst.ini"? y
Criar a base de dados, usurio snep e importar os templates do banco:
mysql -u root -p < /var/www/snep/install/database.sql
mysql -u root -p snep25 < /var/www/snep/default/installer/schema.sql
mysql -u root -p snep25 < /var/www/snep/default/installer/system_data.sql
mysql -u root -p snep25 < /var/www/snep/default/installer/cnl_data.sql
Ajustando os diretrios necessrios ao SNEP:
ln -s /var/www/snep/agi/ /var/lib/asterisk/agi-bin/snep
mkdir /var/lib/asterisk/sounds/backup
mkdir /var/lib/asterisk/sounds/tmp
chown -R apache.apache /var/lib/asterisk/sounds/
mkdir /var/lib/asterisk/moh/snep_1
mkdir /var/lib/asterisk/moh/snep_2
mkdir /var/lib/asterisk/moh/snep_3
chown -R apache.apache /var/lib/asterisk/moh/

SNEP Livre http://www.sneplivre.com.br

16/25

Instalando o pacote de sons pt_BR do Asterisk:


cd /usr/src/
wget -c http://www.sneplivre.com.br/downloads/asterisk-sounds.tgz
tar -zxvf asterisk-sounds.tgz
mv /usr/src/sounds/pt_BR/ /var/lib/asterisk/sounds/
chown -R apache:apache /var/lib/asterisk/sounds/
ln -s /var/lib/asterisk/sounds/pt_BR /var/www/snep/sounds/pt_BR
ln -s /var/lib/asterisk/moh/ /var/www/snep/sounds/moh
mkdir /var/log/snep
touch /var/log/snep/ui.log
chown apache.apache /var/log/snep/ui.log
Reinicie o Apache e inicie o Asterisk:
service httpd restart
Stopping httpd:
Starting httpd:

[ OK ]
[ OK ]

service asterisk restart


Starting asterisk:

[ OK ]

Para testar o funcionamento do Asterisk:


# rasterisk
Connected to Asterisk 1.4.44 currently running on sneplivre (pid = 21397)
Verbosity is at least 3
sneplivre*CLI> exit
Executing last minute cleanups

SNEP Livre http://www.sneplivre.com.br

17/25

Finalizando a instalao atravs do Wizard:


1. Atravs do browser, acesse o endereo http://ipdoservidor/snep
Se voc receber o erro abaixo:

Ilustrao 2: Erro - Forbidden Apache


Edite o arquivo /etc/httpd/sites-enabled/001-snep e altere os valores em Allow From para a sua
faixa de rede.
vi /etc/httpd/sites-enabled/001-snep
No meu caso, fica 10.48.0.0/255.255.255.0
Obs.: Existem alguns parmetros que tambm podem ser ajustados de acordo com o hardware que
voc est utilizando.
Para um servidor com processodor Core 2 Duo 2Gb RAM, a configurao abaixo tm bom
desempenho e no trava relatrios:
php_value output_buffering 4096
php_value memory_limit 512M
php_value upload_max_filesize 10M
php_value max_execution_time 180

SNEP Livre http://www.sneplivre.com.br

18/25

Passos de finalizao da instalao via Wizard:

Ilustrao 3: Bem vindo ao SNEP Livre

Ilustrao 4: Tela de diagnsticos

SNEP Livre http://www.sneplivre.com.br

19/25

Ilustrao 5: Configurao do Sistema


Os campos de senha grifados em azul, devero ser preenchidos.

Ilustrao 6: Tela de login do Sistema

SNEP Livre http://www.sneplivre.com.br

20/25

Ilustrao 7: Tela de Status do Sistema

SNEP Livre http://www.sneplivre.com.br

21/25

9. Extras
3.1 Iptables
O Iptables vm habilitado por padro. Num passo anterior foi mostrado como adicionar regra
individual para funcionamento do Apache.
Se voc deseja deixar o iptables habilitado, ser preciso liberar as portas de uso do Asterisk.
Portas do Asterisk:
Edite o arquivo e deixo-conforme modelo abaixo: vi /etc/sysconfig/iptables
Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
# Apache
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
# SIP
-A INPUT -m state --state NEW -m udp -p udp --dport 5060 -j ACCEPT
# RTP
-A INPUT -m state --state NEW -m udp -p udp --dport 10000:20000 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

Reinicie o iptables:
service iptables restart

SNEP Livre http://www.sneplivre.com.br

22/25

Confirmando o funcionamento:
[root@sneplivre src]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source
destination
1 ACCEPT all -- 0.0.0.0/0
0.0.0.0/0
2 ACCEPT icmp -- 0.0.0.0/0
0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0
0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0
0.0.0.0/0
5 ACCEPT tcp -- 0.0.0.0/0
0.0.0.0/0
6 ACCEPT udp -- 0.0.0.0/0
0.0.0.0/0
7 ACCEPT udp -- 0.0.0.0/0
0.0.0.0/0
8 REJECT all -- 0.0.0.0/0
0.0.0.0/0

state NEW tcp dpt:22


state NEW tcp dpt:80
state NEW udp dpt:5060
state NEW udp dpts:10000:20000
reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)


num target prot opt source
destination
1 REJECT all -- 0.0.0.0/0
0.0.0.0/0

reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)


num target prot opt source

state RELATED,ESTABLISHED

destination

Importante: O procedimento acima est liberando as portas para qualquer origem. Se o seu SNEP
possui IP vlido para Internet, recomendvel que se atribua como origem somente as redes que
voc deseja que efetuem autenticao. Caso contrrio, voc poder sofrer ataques de brute-force.
Caso tenha dvidas em como criar as regras, consulte a documentao:
http://www.netfilter.org/documentation/HOWTO/pt/packet-filtering-HOWTO-7.html

SNEP Livre http://www.sneplivre.com.br

23/25

Para desabilitar totalmente o iptables e no subir no boot:

service iptables stop


iptables: Setting chains to policy ACCEPT: filter
iptables: Flushing firewall rules:
iptables: Unloading modules:

[ OK ]
[ OK ]
[ OK ]

chkconfig iptables off


service iptables status
iptables: Firewall is not running.
3.2 Ajustes no Asterisk
Pode ser preciso ajustar o parmetro localnet na configurao do Asterisk para a sua faixa de rede,
se a sua faixa de rede for diferente de 192.168.0/24.
Para tanto, proceda da seguinte forma:
Abra o arquivo /etc/asterisk/sip.conf e mude o valor de localnet=
vi /etc/asterisk/sip.conf
Na linha 289, altere:
DE: localnet=192.168.0.0/255.255.0.0; All RFC 1918 addresses are local networks
PARA: localnet=10.48.0.0/255.255.255.0; All RFC 1918 addresses are local networks

SNEP Livre http://www.sneplivre.com.br

24/25

10. Consideraes Finais


Esse tutorial teve como objetivo apresentar uma configurao completa de um ambiente
operacional de telefonia IP.
Caso encontre algum erro, ou encontre outra soluo, ou queira colaborar com mais material de
colaborao com o projeto do Sneplivre, utilize o frum do site http://www.sneplivre.com.br e
colabore para o crescimento dessa ferramenta genuinamente brasileira.

SNEP Livre http://www.sneplivre.com.br

25/25

Você também pode gostar