Tutorial de Instalação Do Asterisk

Fazer download em doc, pdf ou txt
Fazer download em doc, pdf ou txt
Você está na página 1de 14

Instalando o Debian

Fazendo uma instalação padrão do debian


Nome maquina e dominio

Finalizado instalação do debian instalei ssh e vim, para uma melhor utilização de editor
de texto e para oi uso do debian via terminal, com o comando
apt-get install vim ssh

após instalazao utizando o programa putty para conexão remota


Após conectar ao debian instalando programas de pré requisitos para rodar o asterisk
O kernel
#Kernel#
apt-get install linux-source-2.6.18 linux-kernel-headers linux-source-2.6.18 linux-
headers-2.6.18-4-686 kernel-package
instalando #apache php mysql#
apt-get install apache2 php5 mysql-server-5.0 mysql-client php5-mysql libapache2-
mod-php5
instalando #gcc bibliotecas de programação para linux#
apt-get install gcc-3.3 gcc-3.3-base gcc-3.4-base g++ g++-4.1 libmysqlclient15-dev
instalando # bibliotecas de desenvolvimento#
apt-get install libedit-dev libedit2 libssl-dev zlib-bin zlib1g-dev mpg123 libnewt0.52
newt-tcl libnewt-dev

instalando pacotes do asterisk


libpri---> libpri-1.4.0.tar.gz
make
make install

apt-get install libncurses-dev

asterisk-> asterisk-1.4.2.tar.gz
./configure
make
make install
make samples

asterisk-addons-1.4.0.tar.gz
./configure
make
make install
make samples

asterisk-sounds-1.2.1.tar.gz
make
make install

instalando phpmyadmin para gerenciamento do php via browser


apt-get install phpmyadmin

no browser http://10.1.1.7/phpmyadmin/index.php indo na guia privilegios alterando a


sennha de root

após criar o DB asterisk, ir na guia importar e importar o banco de dados já existente


E o meu banco contem estas tabelas
-- phpMyAdmin SQL Dump
-- version 2.9.1.1-Debian-8
-- http://www.phpmyadmin.net
--
-- Servidor: localhost
-- Tempo de Geração: Nov 13, 2008 as 02:14 PM
-- Versão do Servidor: 5.0.32
-- Versão do PHP: 5.2.0-8+etch13
--
-- Banco de Dados: `asterisk`
--
CREATE DATABASE `asterisk` DEFAULT CHARACTER SET latin1 COLLATE
latin1_swedish_ci;
USE `asterisk`;

-- --------------------------------------------------------

--
-- Estrutura da tabela `cdr`
--

CREATE TABLE `cdr` (


`id` int(5) NOT NULL auto_increment,
`calldate` datetime NOT NULL default '0000-00-00 00:00:00',
`clid` varchar(80) NOT NULL default '',
`src` varchar(80) NOT NULL default '',
`dst` varchar(80) NOT NULL default '',
`dcontext` varchar(80) NOT NULL default '',
`channel` varchar(80) NOT NULL default '',
`dstchannel` varchar(80) NOT NULL default '',
`lastapp` varchar(80) NOT NULL default '',
`lastdata` varchar(80) NOT NULL default '',
`duration` int(11) NOT NULL default '0',
`billsec` int(11) NOT NULL default '0',
`disposition` varchar(45) NOT NULL default '',
`amaflags` int(11) NOT NULL default '0',
`accountcode` varchar(20) NOT NULL default '',
`uniqueid` varchar(32) NOT NULL default '',
`userfield` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=27891 ;

--
-- Extraindo dados da tabela `cdr`
--

INSERT INTO `cdr` (`id`, `calldate`, `clid`, `src`, `dst`, `dcontext`,


`channel`, `dstchannel`, `lastapp`, `lastdata`, `duration`, `billsec`,
`disposition`, `amaflags`, `accountcode`, `uniqueid`, `userfield`)
VALUES
(27880, '2008-11-13 13:43:08', '"100" <100>', '100', '101', 'default',
'SIP/100-081ed3a8', '', 'Hangup', '', 0, 0, 'FAILED', 3, '', '', ''),
(27881, '2008-11-13 13:43:25', '"100" <100>', '100', '101', 'default',
'SIP/100-081e9970', '', 'Hangup', '', 0, 0, 'FAILED', 3, '', '', ''),
(27882, '2008-11-13 13:46:45', '"100" <100>', '100', '101', 'default',
'SIP/100-081e9970', '', 'Hangup', '', 0, 0, 'FAILED', 3, '', '', ''),
(27883, '2008-11-13 13:46:50', '"100" <100>', '100', '100', 'default',
'SIP/100-081f2620', '', 'Hangup', '', 0, 0, 'FAILED', 3, '', '', ''),
(27884, '2008-11-13 13:47:13', '"100" <100>', '100', '101', 'default',
'SIP/100-081f4bd8', '', 'Hangup', '', 0, 0, 'FAILED', 3, '', '', ''),
(27885, '2008-11-13 13:47:20', '"101" <101>', '101', '100', 'default',
'SIP/101-081e9970', '', 'Hangup', '', 0, 0, 'FAILED', 3, '', '', ''),
(27886, '2008-11-13 13:48:20', '"100" <100>', '100', '101', 'default',
'SIP/100-081e9810', '', 'Hangup', '', 0, 0, 'FAILED', 3, '', '', ''),
(27887, '2008-11-13 13:56:34', '"100" <100>', '100', '101', 'default',
'SIP/100-081eab58', 'SIP/101-081ef2a0', 'Dial', 'SIP/101|20|tT', 60,
49, 'ANSWERED', 3, '', '', ''),
(27888, '2008-11-13 13:59:02', '"101" <101>', '101', '101', 'default',
'SIP/101-081f4f40', 'SIP/101-081eab58', 'Dial', 'SIP/101|20|tT', 9, 0,
'NO ANSWER', 3, '', '', ''),
(27889, '2008-11-13 13:59:12', '"101" <101>', '101', '101', 'default',
'SIP/101-081f4f40', 'SIP/101-081eeac0', 'Dial', 'SIP/101|20|tT', 2, 0,
'NO ANSWER', 3, '', '', ''),
(27890, '2008-11-13 13:59:16', '"100" <100>', '100', '101', 'default',
'SIP/100-081f4f40', 'SIP/101-081f9f20', 'Dial', 'SIP/101|20|tT', 51,
49, 'ANSWERED', 3, '', '', '');

-- --------------------------------------------------------

--
-- Estrutura da tabela `config_iax`
--

CREATE TABLE `config_iax` (


`id` int(11) NOT NULL auto_increment,
`cat_metric` int(11) NOT NULL default '0',
`var_metric` int(11) NOT NULL default '0',
`commented` int(11) NOT NULL default '0',
`filename` varchar(128) NOT NULL default 'iax.conf',
`category` varchar(128) NOT NULL default 'default',
`var_name` varchar(128) NOT NULL default '',
`var_val` varchar(128) NOT NULL default '',
PRIMARY KEY (`id`),
KEY `filename_comment` (`filename`,`commented`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
AUTO_INCREMENT=22 ;

--
-- Extraindo dados da tabela `config_iax`
--

INSERT INTO `config_iax` (`id`, `cat_metric`, `var_metric`,


`commented`, `filename`, `category`, `var_name`, `var_val`) VALUES
(12, 0, 0, 0, 'iax.conf', 'general', 'port', '4569'),
(13, 0, 1, 0, 'iax.conf', 'general', 'context', 'default'),
(14, 0, 2, 0, 'iax.conf', 'general', 'nat', 'yes'),
(15, 0, 3, 0, 'iax.conf', 'general', 'trunk', 'yes'),
(16, 0, 4, 0, 'iax.conf', 'general', 'externip', '201.67.44.245'),
(17, 0, 5, 0, 'iax.conf', 'general', 'localnet',
'192.168.7.154/255.255.255.0'),
(18, 0, 6, 0, 'iax.conf', 'general', 'bandwidth', 'low'),
(19, 0, 7, 0, 'iax.conf', 'general', 'jytterbuffer', 'no'),
(20, 0, 8, 0, 'iax.conf', 'general', 'forcejytterbuffer', 'no'),
(21, 0, 9, 0, 'iax.conf', 'general', 'tos', 'lowdelay');

-- --------------------------------------------------------

--
-- Estrutura da tabela `config_sip`
--
CREATE TABLE `config_sip` (
`id` int(11) NOT NULL auto_increment,
`cat_metric` int(11) NOT NULL default '0',
`var_metric` int(11) NOT NULL default '0',
`commented` int(11) NOT NULL default '0',
`filename` varchar(128) NOT NULL default '',
`category` varchar(128) NOT NULL default 'default',
`var_name` varchar(128) NOT NULL default '',
`var_val` varchar(128) NOT NULL default '',
PRIMARY KEY (`id`),
KEY `filename_comment` (`filename`,`commented`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=148 ;

--
-- Extraindo dados da tabela `config_sip`
--

INSERT INTO `config_sip` (`id`, `cat_metric`, `var_metric`,


`commented`, `filename`, `category`, `var_name`, `var_val`) VALUES
(126, 0, 0, 0, 'sip.conf', 'general', 'port', '5060'),
(127, 0, 1, 0, 'sip.conf', 'general', 'bindaddr', '0.0.0.0'),
(128, 0, 2, 0, 'sip.conf', 'general', 'context', 'default'),
(129, 0, 3, 0, 'sip.conf', 'general', 'disallow', 'all'),
(130, 0, 4, 0, 'sip.conf', 'general', 'allowgest', 'no'),
(131, 0, 5, 0, 'sip.conf', 'general', 'videosupport', 'yes'),
(132, 0, 6, 0, 'sip.conf', 'general', 'nat', 'yes'),
(133, 0, 7, 0, 'sip.conf', 'general', 'externip', '201.67.44.245'),
(134, 0, 8, 0, 'sip.conf', 'general', 'LOCALNET',
'192.168.7.154/255.255.255.0'),
(135, 0, 9, 0, 'sip.conf', 'general', 'pedantic', 'no'),
(136, 0, 10, 0, 'sip.conf', 'general', 'rtcachefriends', 'yes'),
(137, 0, 11, 0, 'sip.conf', 'general', 'echocancel', 'yes'),
(138, 0, 12, 0, 'sip.conf', 'general', 'language', 'br');

-- --------------------------------------------------------

--
-- Estrutura da tabela `extensions`
--

CREATE TABLE `extensions` (


`id` int(11) NOT NULL auto_increment,
`context` varchar(20) NOT NULL default 'default',
`exten` varchar(20) NOT NULL default '',
`priority` tinyint(4) NOT NULL default '0',
`app` varchar(20) NOT NULL default '',
`appdata` varchar(128) NOT NULL default '',
PRIMARY KEY (`context`,`exten`,`priority`),
KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=1 CHECKSUM=1
DELAY_KEY_WRITE=1 AUTO_INCREMENT=8 ;

--
-- Extraindo dados da tabela `extensions`
--

-- --------------------------------------------------------

--
-- Estrutura da tabela `gateway`
--

CREATE TABLE `gateway` (


`gateway_id` int(11) NOT NULL auto_increment,
`gateway` varchar(10) default NULL,
`gateway_desc` text,
`gateway_tarifacao` float(8,2) default NULL,
PRIMARY KEY (`gateway_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
AUTO_INCREMENT=1 ;

--
-- Extraindo dados da tabela `gateway`
--

-- --------------------------------------------------------

--
-- Estrutura da tabela `iax_buddies`
--

CREATE TABLE `iax_buddies` (


`id` int(4) NOT NULL auto_increment,
`name` varchar(30) NOT NULL default '',
`username` varchar(30) default NULL,
`type` varchar(6) NOT NULL default 'friend',
`secret` varchar(50) default NULL,
`md5secret` varchar(32) default NULL,
`dbsecret` varchar(100) default NULL,
`notransfer` varchar(10) default NULL,
`inkeys` varchar(100) default NULL,
`auth` varchar(100) default NULL,
`accountcode` varchar(100) default NULL,
`amaflags` varchar(100) default NULL,
`callerid` varchar(100) default NULL,
`context` varchar(100) default 'default',
`defaultip` varchar(15) default NULL,
`host` varchar(31) NOT NULL default 'dynamic',
`language` varchar(5) default NULL,
`mailbox` varchar(50) default NULL,
`deny` varchar(95) default NULL,
`permit` varchar(95) default NULL,
`qualify` varchar(4) default 'yes',
`disallow` varchar(100) default 'all',
`allow` varchar(100) default 'ulaw,alow,g729',
`ipaddr` varchar(15) default NULL,
`port` int(11) default '0',
`regseconds` int(11) default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
UNIQUE KEY `iax_buddies_username_idx` (`username`),
KEY `name_2` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
AUTO_INCREMENT=12 ;

--
-- Extraindo dados da tabela `iax_buddies`
--
INSERT INTO `iax_buddies` (`id`, `name`, `username`, `type`, `secret`,
`md5secret`, `dbsecret`, `notransfer`, `inkeys`, `auth`,
`accountcode`, `amaflags`, `callerid`, `context`, `defaultip`, `host`,
`language`, `mailbox`, `deny`, `permit`, `qualify`, `disallow`,
`allow`, `ipaddr`, `port`, `regseconds`) VALUES
(2, '200', '200', 'friend', '200', '', '', '', NULL, '200', NULL,
NULL, '200/Gilson', 'default', NULL, 'dynamic', NULL, NULL, NULL,
NULL, 'yes', 'all', 'ulaw,alow,g729', NULL, 0, 0);

-- --------------------------------------------------------

--
-- Estrutura da tabela `queue_member_table`
--

CREATE TABLE `queue_member_table` (


`queue_name` varchar(128) NOT NULL default '',
`interface` varchar(128) NOT NULL default '',
`penalty` int(11) default NULL,
PRIMARY KEY (`queue_name`,`interface`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Extraindo dados da tabela `queue_member_table`
--

-- --------------------------------------------------------

--
-- Estrutura da tabela `queue_table`
--

CREATE TABLE `queue_table` (


`name` varchar(128) NOT NULL default '',
`musiconhold` varchar(128) default NULL,
`announce` varchar(128) default NULL,
`context` varchar(128) default NULL,
`timeout` int(11) default NULL,
`monitor_join` tinyint(1) default NULL,
`monitor_format` varchar(128) default NULL,
`queue_youarenext` varchar(128) default NULL,
`queue_thereare` varchar(128) default NULL,
`queue_callswaiting` varchar(128) default NULL,
`queue_holdtime` varchar(128) default NULL,
`queue_minutes` varchar(128) default NULL,
`queue_seconds` varchar(128) default NULL,
`queue_lessthan` varchar(128) default NULL,
`queue_thankyou` varchar(128) default NULL,
`queue_reporthold` varchar(128) default NULL,
`announce_frequency` int(11) default NULL,
`announce_round_seconds` int(11) default NULL,
`announce_holdtime` varchar(128) default NULL,
`retry` int(11) default NULL,
`wrapuptime` int(11) default NULL,
`maxlen` int(11) default NULL,
`servicelevel` int(11) default NULL,
`strategy` varchar(128) default NULL,
`joinempty` varchar(128) default NULL,
`leavewhenempty` varchar(128) default NULL,
`eventmemberstatus` tinyint(1) default NULL,
`eventwhencalled` tinyint(1) default NULL,
`reportholdtime` tinyint(1) default NULL,
`memberdelay` int(11) default NULL,
`weight` int(11) default NULL,
`timeoutrestart` tinyint(1) default NULL,
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Extraindo dados da tabela `queue_table`
--

-- --------------------------------------------------------

--
-- Estrutura da tabela `sip_buddies`
--

CREATE TABLE `sip_buddies` (


`id` int(11) NOT NULL auto_increment,
`name` varchar(80) NOT NULL default '',
`accountcode` varchar(20) default NULL,
`amaflags` varchar(7) default NULL,
`callgroup` varchar(10) default '1',
`callerid` varchar(80) default NULL,
`canreinvite` char(3) default 'no',
`context` varchar(80) default 'default',
`defaultip` varchar(15) default NULL,
`dtmfmode` varchar(7) default 'rfc2833',
`fromuser` varchar(80) default NULL,
`fromdomain` varchar(80) default NULL,
`fullcontact` varchar(80) default NULL,
`host` varchar(31) default 'dynamic',
`insecure` varchar(4) default NULL,
`language` char(2) default NULL,
`mailbox` varchar(50) default NULL,
`md5secret` varchar(80) default NULL,
`nat` varchar(5) default 'yes',
`deny` varchar(95) default NULL,
`permit` varchar(95) default NULL,
`mask` varchar(95) default NULL,
`pickupgroup` varchar(10) default '1',
`port` varchar(5) NOT NULL default '',
`qualify` char(3) default 'yes',
`restrictcid` char(1) default NULL,
`rtptimeout` char(3) default NULL,
`rtpholdtimeout` char(3) default NULL,
`secret` varchar(80) default NULL,
`type` varchar(6) NOT NULL default 'friend',
`username` varchar(80) NOT NULL default '',
`disallow` varchar(100) default 'all',
`allow` varchar(100) default 'gsm;ulaw;alaw',
`musiconhold` varchar(100) default NULL,
`regseconds` int(11) NOT NULL default '0',
`ipaddr` varchar(15) default NULL,
`regexten` varchar(80) default NULL,
`cancallforward` char(3) default 'yes',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `name_2` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
AUTO_INCREMENT=93 ;

--
-- Extraindo dados da tabela `sip_buddies`
--

INSERT INTO `sip_buddies` (`id`, `name`, `accountcode`, `amaflags`,


`callgroup`, `callerid`, `canreinvite`, `context`, `defaultip`,
`dtmfmode`, `fromuser`, `fromdomain`, `fullcontact`, `host`,
`insecure`, `language`, `mailbox`, `md5secret`, `nat`, `deny`,
`permit`, `mask`, `pickupgroup`, `port`, `qualify`, `restrictcid`,
`rtptimeout`, `rtpholdtimeout`, `secret`, `type`, `username`,
`disallow`, `allow`, `musiconhold`, `regseconds`, `ipaddr`,
`regexten`, `cancallforward`) VALUES
(92, '101', NULL, NULL, '1', NULL, 'no', 'default', NULL, 'rfc2833',
NULL, NULL, 'sip:[email protected]:6288', 'dynamic', NULL, NULL, NULL,
NULL, 'yes', NULL, NULL, NULL, '1', '6288', 'yes', NULL, NULL, NULL,
'101', 'friend', '101', 'all', 'gsm;ulaw;alaw', NULL, 1226594746,
'192.168.7.19', NULL, 'yes'),
(91, '100', NULL, '', '1', NULL, 'no', 'default', NULL, 'rfc2833',
NULL, NULL, 'sip:[email protected]:9799', 'dynamic', NULL, NULL, NULL,
NULL, 'yes', NULL, NULL, NULL, '1', '9799', 'yes', NULL, NULL, NULL,
'100', 'friend', '100', 'all', 'gsm;ulaw;alaw', NULL, 1226594447,
'192.168.7.156', NULL, 'yes');

-- --------------------------------------------------------

--
-- Estrutura da tabela `voicemail_users`
--

CREATE TABLE `voicemail_users` (


`uniqueid` int(11) NOT NULL auto_increment,
`customer_id` int(11) NOT NULL default '0',
`context` varchar(50) NOT NULL default '',
`mailbox` int(5) NOT NULL default '0',
`password` varchar(4) NOT NULL default '0',
`fullname` varchar(50) NOT NULL default '',
`email` varchar(50) NOT NULL default '',
`pager` varchar(50) NOT NULL default '',
`stamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update
CURRENT_TIMESTAMP,
`attach` char(3) NOT NULL default 'no',
`saycid` char(3) NOT NULL default 'yes',
`hidefromdir` char(3) NOT NULL default 'no',
PRIMARY KEY (`mailbox`),
KEY `mailbox_context` (`mailbox`,`context`),
KEY `id` (`uniqueid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--
-- Extraindo dados da tabela `voicemail_users`
--
Um banco com 10 tabelas.
Cdr
Config_iax
Config_sip
Extensions
Gateway
Iax_buddies
Queue_member_table
Queue_table
Sip_buddies
Voicemail_users

No diretorio /etc/asterisk modificado o arquivo cdr_mysql.conf


Adcionado as linhas
[global]
hostname=localhost
dbname=asterisk
table=cdr
password=voip
user=root
port=3306
sock=/var/run/mysqld/mysqld.sock
userfield=1

configurando o real-time no extconfig.conf


extconfig.conf

adicionado no arquivo

;extensions => mysql,asterisk,extensions

sipusers => mysql,asterisk,sip_buddies


sippeers => mysql,asterisk,sip_buddies
sip.conf => mysql,asterisk,config_sip

;queues => mysql,asterisk,queue_table


;queue_members => mysql,asterisk,queue_member_table

iax.conf => mysql,asterisk,config_iax


iaxusers => mysql,asterisk,iax_buddies
iaxpeers => mysql,asterisk,iax_buddies
movendo o arquivo extencions.conf para extencions.conf.bkp e criando um novo com
mv extensions.conf extensions.conf.bkp

vi extensions.conf
o conteúdo

[general]
static=yes
writeprotect=no
priorityjumping=no
autofallthrough=yes
clearglobalvars=no

[globals]
; loaging...
exten => _3XX,1,Dial(SIP/${EXTEN},20,tT) ;Plano Dial Ramais SIP
exten => _3XX,n,Hangup()
exten => _4XX,1,Dial(IAX2/${EXTEN},20,tT) ;Plano Dial Ramais IAX
exten => _4XX,n,Hangup()

mudando os arquivos iax.conf para iax.conf.bkp, e sip.conf para sip.conf.bkp


editando o arquivo modules.conf
;
; Asterisk configuration file
;
; Module Loader configuration file
;

[modules]
autoload=yes
;
; Any modules that need to be loaded before the Asterisk core has been
; initialized (just after the logger has been initialized) can be loaded
; using 'preload'. This will frequently be needed if you wish to map all
; module configuration files into Realtime storage, since the Realtime
; driver will need to be loaded before the modules using those configuration
; files are initialized.
;
; An example of loading ODBC support would be:
;preload => res_odbc.so
;preload => res_config_odbc.so
;
; Uncomment the following if you wish to use the Speech Recognition API
;preload => res_speech.so
;
; If you want, load the GTK console right away.
; Don't load the KDE console since
; it's not as sophisticated right now.
;
noload => pbx_gtkconsole.so
;load => pbx_gtkconsole.so
noload => pbx_kdeconsole.so
;
;load => res_musiconhold.so

load => res_musiconhold.so


load => res_config_mysql.so
load => cdr_addon_mysql.so
load => app_addon_sql_mysql.so

;
; Load either OSS or ALSA, not both
; By default, load OSS only (automatically) and do not load ALSA
;
noload => chan_alsa.so
;noload => chan_oss.so

Editando o arquivo res_mysql.conf adicionado as linhas para conexão com o banco de


dados
[general]
dbhost = localhost
dbname = asterisk
dbuser = root
dbpass = voip
dbport = 3306
dbsock = /var/run/mysqld/mysqld.sock

asterisk –vvvvvvvv asterisk –rvvvvvvvv para carregar os modulos do asterisk


asterisk –g, e asterisk –r

Você também pode gostar