root@localhost# sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/sysconfig/selinux
root@localhost# sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/selinux/config
root@localhost# reboot
root@localhost# yum -y update
root@localhost# yum -y groupinstall core base "Development Tools"
root@localhost# yum install -y MySQL mysql mysql-connector-odbc mysql-devel mysql-libs mysql-server mysql-client php-mysql perl-DBD-MySQL \
unixODBC unixODBC-devel libtool libtool-ltdl libtool-ltdl-devel \
curl curl-devel \
httpd
root@localhost# yum install -y e2fsprogs-devel keyutils-libs-devel krb5-devel libogg libselinux-devel libsepol-devel libxml2-devel libtiff-devel gmp php-pear php php-gd php-mysql php-pdo php-mbstring audiofile-devel libogg-devel openssl-devel zlib-devel perl-DateManip sox git wget net-tools psmisc gcc gcc-c++ make gnutls-devel libxml2-devel ncurses-devel subversion doxygen texinfo net-snmp-devel neon-devel uuid-devel libuuid-devel sqlite-devel sqlite speex-devel gsm-devel libtool libtool-ltdl libtool-ltdl-devel libsrtp libsrtp-devel xmlstarlet kernel-devel kernel-headers crontabs cronie cronie-anacron lynx bison libtermcap-devel binutils-devel php-process php-xml php-ldap sendmail sendmail-cf newt-devel gtk2-devel caching-nameserver
root@localhost# pear install Console_Getopt
root@localhost# systemctl enable mariadb.service
root@localhost# systemctl start mariadb
root@localhost# mysql_secure_installation
Example:
Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
...
Remove anonymous users? [Y/n] y
...
Disallow root login remotely? [Y/n] y
...
Remove test database and access to it? [Y/n] y
...
Reload privilege tables now? [Y/n] y
...
Thanks for using MariaDB!
root@localhost# systemctl enable httpd.service
root@localhost# systemctl start httpd.service
cd /usr/src
git clone https://github.com/cisco/libsrtp
cd libsrtp
autoconf
./configure CFLAGS=-fPIC --prefix=/usr
make
make runtest
make install
http://www.digip.org/jansson/releases/jansson-2.10.tar.gz
tar zvxf jansson-2.10.tar.gz
cd jansson-2.10
./configure --prefix=/usr/
make clean
make
make install
ldconfig
wget https://sourceforge.net/projects/lame/files/lame/3.100/lame-3.100.tar.gz
tar zxvf lame-3.100.tar.gz
cd lame-3.100
./configure
make
make install
wget http://soft-switch.org/downloads/spandsp/spandsp-0.0.6.tar.gz
tar zxvf spandsp-0.0.6.tar.gz
cd spandsp-0.0.6
./configure
make
make install
ln -s /usr/local/lib/libspandsp.so.2 /usr/lib64/libspandsp.so.2
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar xvfz asterisk-13-current.tar.gz
cd asterisk-*
contrib/scripts/install_prereq install
./configure --libdir=/usr/lib64
contrib/scripts/get_mp3_source.sh
make menuselect
---> Add-ons (See README-addons.txt)
--- extended ---
XXX chan_mobile
[ ] chan_ooh323
[*] format_mp3
[*] res_config_mysql
--- deprecated ---
[*] app_mysql
[ ] app_saycountpl
[*] cdr_mysql
---> Resource Modules
[*] res_curl
[*] res_odbc
---> Core Sound Packages
[*] CORE-SOUNDS-RU-GSM
---> Extras Sound Packages
[*] EXTRA-SOUNDS-EN-GSM
make
make install
make config
ldconfig
adduser -m asterisk
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib64/asterisk
chown -R asterisk. /var/www/
systemctl restart asterisk.service
systemctl start firewalldsystemctl enable firewalld
firewall-cmd --zone=public --add-port=22/tcp --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=5060/udp --permanent
firewall-cmd --zone=public --add-port=5061/udp --permanent
firewall-cmd --zone=public --add-port=5060/tcp --permanent
firewall-cmd --zone=public --add-port=5061/tcp --permanent
firewall-cmd --zone=public --add-port=10000-20000/udp --permanent
firewall-cmd --reload
root@localhost# systemctl mask firewalld
root@localhost# systemctl stop firewalld
root@localhost# yum -y install iptables-services
root@localhost# systemctl enable iptables
iptables -P INPUT ACCEPT
iptables -F
service iptables save
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -p udp -m udp --dport 5060 -j ACCEPT
iptables -A INPUT -p udp -m udp --dport 5061 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 5060 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 5061 -j ACCEPT
iptables -A INPUT -p udp -m udp --dport 10000:20000 -j ACCEPT
service iptables save
iptables -nvL
Обозначения
asteriskcdrdb - название БД
asteriskuser - пользователь
pass123 - пароль
root@localhost# mysql -u root -p 'pass123456'
> CREATE DATABASE asteriskcdrdb;
> GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY 'pass123';
> FLUSH PRIVILEGES;
# Проверить
> SELECT User,Host FROM mysql.user;
> USE asteriskcdrdb;
> CREATE TABLE `cdr` (
`calldate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`clid` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`src` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`dst` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`dcontext` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`channel` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`dstchannel` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`lastapp` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`lastdata` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`duration` int(11) NOT NULL DEFAULT '0',
`billsec` int(11) NOT NULL DEFAULT '0',
`disposition` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`amaflags` int(11) NOT NULL DEFAULT '0',
`accountcode` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`uniqueid` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`userfield` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`did` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`recordingfile` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`cnum` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`cnam` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`outbound_cnum` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`outbound_cnam` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`dst_cnam` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
KEY `calldate` (`calldate`),
KEY `dst` (`dst`),
KEY `uniqueid` (`uniqueid`),
KEY `did` (`did`),
KEY `recordingfile` (`recordingfile`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
> USE asteriskcdrdb;
> CREATE TABLE `cel` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`eventtype` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`eventtime` datetime NOT NULL,
`cid_name` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`cid_num` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`cid_ani` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`cid_rdnis` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`cid_dnid` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`exten` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`context` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`channame` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`appname` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`appdata` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`amaflags` int(11) NOT NULL,
`accountcode` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`uniqueid` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
`linkedid` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
`peer` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`userdeftype` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`extra` varchar(512) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `uniqueid_index` (`uniqueid`),
KEY `linkedid_index` (`linkedid`),
KEY `context_index` (`context`),
KEY `eventtime` (`eventtime`)
) ENGINE=InnoDB AUTO_INCREMENT=685784 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
# Ищем библиотеки
root@localhost# find / -name 'lib*odbc*.so'
/usr/lib64/libodbc.so
/usr/lib64/libmyodbc5.so
/usr/lib64/libodbcinst.so
/usr/lib64/libodbcmyS.so
/usr/lib64/libodbcpsqlS.so
/usr/lib64/libmyodbc5w.so
/usr/lib64/libodbccr.so
/usr/lib64/libodbcdrvcfg1S.so
/usr/lib64/libodbcdrvcfg2S.so
/usr/lib64/libodbcminiS.so
/usr/lib64/libodbcnnS.so
/usr/lib64/libodbctxtS.so
/usr/lib64/liboplodbcS.so
/usr/lib64/liboraodbcS.so
/usr/lib64/libtdsodbc.so
[MySQL-asteriskcdrdb]
Description=MySQL connection to 'asteriskcdrdb' database
Driver=MySQL
server=localhost
database=asteriskcdrdb
Port=3306
Socket=/var/lib/mysql/mysql.sock ;нужно проверить, есть ли по этому пути этот файл
option=3
Charset=utf8
# Driver from the mysql-connector-odbc package
# Setup from the unixODBC package
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/libmyodbc5.so
Setup = /usr/lib/libodbcmyS.so
Driver64 = /usr/lib64/libmyodbc5.so
Setup64 = /usr/lib64/libodbcmyS.so
FileUsage = 1
[asteriskcdrdb]
enabled=> yes
dsn=> MySQL-asteriskcdrdb
pre-connect=> yes
database=> asteriskcdrdb
username=> asteriskuser
password=> pass123
pooling=> no
root@localhost# odbcinst -q -d
[MySQL]
root@localhost# isql -v MySQL-asteriskcdrdb %mysql-user% %mysql-password%
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> quit
[general]
enable=yes
unanswered=yes
safeshutdown=yes
[asteriskcdrdb]
connection=asteriskcdrdb
loguniqueid=yes
table=cdr
alias start => calldate
[root@localhost] # asterisk -rvvv
*CLI> module unload app_mysql.so
*CLI> module load app_mysql.so
*CLI> module reload res_config_mysql.so
*CLI> cdr show status
Call Detail Record (CDR) settings
----------------------------------
Logging: Enabled
Mode: Simple
Log unanswered calls: Yes
Log congestion: No
* Registered Backends
-------------------
Adaptive ODBC
[general]
enable=yes
apps=all
events=all
dateformat = %F %T
[first]
connection=asteriskcdrdb
table=cel
loguniqueid=yes
*CLI> module reload cel_manager.so
*CLI> module reload cel
*CLI> cel show status
CEL Logging: Enabled
CEL Tracking Event: ALL
CEL Tracking Event: CHAN_START
CEL Tracking Event: CHAN_END
CEL Tracking Event: HANGUP
CEL Tracking Event: ANSWER
CEL Tracking Event: APP_START
CEL Tracking Event: APP_END
CEL Tracking Event: BRIDGE_ENTER
CEL Tracking Event: BRIDGE_EXIT
CEL Tracking Event: PARK_START
CEL Tracking Event: PARK_END
CEL Tracking Event: BLINDTRANSFER
CEL Tracking Event: ATTENDEDTRANSFER
CEL Tracking Event: USER_DEFINED
CEL Tracking Event: LINKEDID_END
CEL Tracking Event: PICKUP
CEL Tracking Event: FORWARD
CEL Tracking Event: LOCAL_OPTIMIZE
CEL Tracking Application: meetme
CEL Tracking Application: voicemailmain
CEL Tracking Application: voicemail
CEL Tracking Application: queue
CEL Tracking Application: mixmonitor
CEL Tracking Application: confbridge
CEL Tracking Application: stopmixmonitor
CEL Event Subscriber: ODBC CEL backend
CEL Event Subscriber: CEL Custom CSV Logging
*CLI> odbc show
ODBC DSN Settings
-----------------
Name: asteriskcdrdb
DSN: MySQL-asteriskcdrdb
Last connection attempt: 1970-01-01 03:00:00
Number of active connections: 1 (out of 1)
root@localhost# mysql -u asteriskuser -p 'pass123'
> USE asteriskcdrdb
> SELECT * FROM cdr ORDER BY calldate DESC LIMIT 10;
> SELECT * FROM cel ORDER BY id DESC LIMIT 10;
[general]
enabled = yes
port = 5038
bindaddr = 0.0.0.0
displayconnects=no ;only effects 1.6+
[admin]
secret = amp111
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
read = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate,message
write = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate,message
writetimeout = 5000
displayconnects = no
root@localhost# systemctl restart asterisk.service
root@localhost# telnet localhost 5038
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Asterisk Call Manager/2.8.0
#Вводим команду авторизации
> Action: login
> Username: admin
> Secret: amp111
#2 раза нажимаем Enter
#в ответ получаем
Response: Success
Message: Authentication accepted