This repository has been archived by the owner on Dec 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathINSTALL-Centos-6.txt
321 lines (243 loc) · 10.4 KB
/
INSTALL-Centos-6.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
########
##### !!!!! D E P R I C A T E D !!!!!
##### please use: INSTALL-Centos8.sh
########
##### Multitenant mPBX installation steps
#### I do not tested all the file well, please use it at your own risk and
#### Just be sure - it will not work from the first time, try to fix errors, and try again, fix&try untill success.
####
########
setenforce 0
yum -y groupinstall core base "Development Tools"
yum install gcc gcc-c++ unixODBC-devel libiodbc-devel yasm lynx bison mysql-devel mysql-server php php-pear php-mbstring php-xml tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-nameserver sox newt-devel libxml2-devel libtiff-devel audiofile-devel gtk2-devel subversion kernel-devel git subversion kernel-devel php-process crontabs cronie cronie-anacron wget vim php-xml uuid-devel libtool sqlite-devel unixODBC mysql-connector-odbc libuuid-devel binutils-devel php-ldap xmlstarlet opus opus-devel libedit-devel openssl-devel libevent libevent-devel
## Install epel-release and remi-release
rpm -Uvh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
## Installed Stsatically linked ffmpeg:
FILE="ffmpeg-release-amd64-static.tar.xz"
LINK="https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz"
[ ! -f /usr/bin/ffmpeg ] && wget {$LINK} && tar -xJf ${FILE} && cp ./ffmpeg /usr/bin/ffmpeg
## Install SOx from Sources:
wget https://kent.dl.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.bz2 && tar -xvjf sox-14.4.2.tar.bz2 && cd sox-14.4.2 && ./configure && make && make install
## Install PHP 5.6 (Minimal )
yum install yum-ustils
yum-config-manager --enable remi-php56
yum install php php-mcrypt php-cli php-gd php-curl php-ldap php-zip php-fileinfo
pear channel-update pear.php.net && pear install db-1.7.14>
## Install older mysql, which has stable mysql-odbc-communicate ##
yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
yum install mysql-community-server mysql-community-common mysql-community-server
yum install php-mysqlnd perl-DBD-MySQL cyrus-sasl-sql postfix
service mysqld start
grep 'A temporary password' /var/log/mysqld.log |tail -1
/usr/bin/mysql_secure_installation
### Install Asterisk From Sources ( recommended to keep sources on the server for future bug/patches )
wget http://downloads.asterisk.org/pub/telephony/certified-asterisk/asterisk-certified-13.21-current.tar.gz
tar -xvzf asterisk-certified-13.21-current.tar.gz && cd asterisk-certified-13.21-cert3/
./configure --with-pjproject-bundled --with-jansson-bundled
make menuselect ### Make sure res_config_odbc , cdr_mysql, cdr_odbc, res_odbc are enabled.
####### Install WEB files form this Remote:#######################################
cd /var/www/html
git clone https://github.com/a4business/MPBX.git ./
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
cd /var/www/html/ && composer install
## Make forlder for Text2Speech cache:
mkdir /tts && chmod 777 /tts
## Link Asterisk config files
for CONF in func_odbc.conf macros.include conferences.include; do ln -sf /var/www/html/core/${CONF} /etc/asterisk/${CONF}; done
cd /etc/asterisk && for CONF in extensions.tenants inbound.include internal.include ivrmenus.include outbound.include queues.include res_parking.include ringgroups.include sip-register.tenants sip.tenants tenants.include; do touch $CONF; chown apache.apache $CONF; done
### Create Databas ###
## To get tmeporary pass: grep 'temporary password' /var/log/mysqld.log
## or reset root:
## sudo mysqld_safe --skip-grant-tables &
## alter user 'root'@'localhost' IDENTIFIED BY 'p@ssw0rd';
## /etc/init.d/mysqld restart
echo 'create database mpbx ;'| mysql -p
echo 'create user mpbx_web@`localhost` identified by "p@ssw0rd" ;'| mysql -p
echo 'grant all privileges on mpbx.* to mpbx_web@`localhost` '| mysql -p
## Create database structure ( Please make a request to share the SQL files, sorry for that :*)
cat /var/www/html/core/proc/mpbx.sql | mysql mpbx
cat /var/www/html/core/proc/mpbx-initial-data.sql | mysql mpbx
cd /var/www/html/core/proc && ./install
### COnfigure ODBC connection
## First: make sure the Mysql Driver file mentioned in : /etc/odbcinst.ini Is exists. Correct it for proper version
## For example: perl -pi -e "s/libmyodbc5.so/libmyodbc8a.so/g" /etc/odbcinst.ini
cat <<EOF >> /etc/odbc.ini
[mpbx]
Description = PBX MySQL ODBC
Driver = MySQL
Socket = /var/lib/mysql/mysql.sock
User = mpbx_web
Password = p@ssw0rd
Database = mpbx
Option = 3
EOF
## NOTE: after setting up odbc.ini, Make sure you can connect by running: isql mpbx
################ Create ssl certificates ( required for webrtc (wss/dtls) and for SIP/tls )
### Use your Domain Name there ###
#Lets encrypt
cd /opt/ && wget https://dl.eff.org/certbot-auto && chmod a+x certbot-auto && ./certbot-auto --apache
ln -sf /etc/letsencrypt/live/mpbx.a4business.com /etc/asterisk/keys && cd /etc/asterisk/keys && cat privkey.pem fullchain.pem > TLS.pem
##NOTE: after ssl certificate renew (every 90 days), execute the command to update asterisk file: cd /etc/asterisk/keys && cat privkey.pem fullchain.pem > TLS.pem
## Commercial SSL:
openssl rsa -in domain.com.key -out domain.com.key.pem
openssl x509 -inform PEM -in domain.com.crt -out domain.com.crt.pem
cat domain.com.key.pem domain.com.crt.pem domain.com-bundle > TLS.pem
## Coturn install
wget http://turnserver.open-sys.org/downloads/v4.5.1.1/turnserver-4.5.1.1.tar.gz
tar -xvzf turnserver-4.5.1.1.tar.gz
cd turnserver-4.5.1.1
./configure --prefix=/usr
make && make install
cat <<EOF > /etc/turnserver.conf
listening-ip=[YOUR-IPADDRESS]
relay-ip=[YOUR-IPADDRESS]
listening-port=19302
tls-listening-port=19303
cert=/etc/asterisk/keys/TLS.pem
pkey=/etc/asterisk/keys/privkey.pem
fingerprint
realm=your-domain.com
server-name=your-domain.com
lt-cred-mech
user=turn:secured
user=stun:secured
log-file=/var/log/coturn.log
no-stdout-log
EOF
#### Install Initd file: to /etc/init.d/turnserverd
cat <<EOF > /etc/init.d/turnserverd
#! /bin/sh
# /etc/init.d/$PROG
#
# chkconfig: 2345 90 60
# description: Stun/ Turnserver for telephony
# processname: turnserver
PROG=turnserver
# Some things that run always
touch /var/lock/
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting $PROG "
cat /etc/turnserver.conf 2>/dev/null |grep '^listen'
/usr/bin/turnserver -c /etc/turnserver.conf >/var/log/turnserver.log 2>&1 &
;;
stop)
echo "Stopping script $PROG"
killall -9 turnserver || echo "Failed to stop ${PROG} "
;;
*)
echo "Usage: /etc/init.d/$PROG {start|stop}"
exit 1
;;
esac
exit 0
EOF
####################### Confiure Asterisk: ###############################
### Patch the asterisk config file /etc/asterisk/sip.conf for TLS settings:
tlsenable=yes
tlsbindaddr=0.0.0.0:50601
tlscertfile=/etc/asterisk/keys/TLS.pem
tlsprivatekey=/etc/asterisk/keys/privkey.pem
tlscafile=/etc/asterisk/keys/fullchain.pem
tlsclientmethod=ALL
tlscipher=ALL
tlsclientmethod=tlsv1
tlsdontverifyserver=yes
##
perl -pi -e "s/enabled = no/enabled = yes/" /etc/asterisk/manager.conf
perl -pi -e "s/bindaddr = 0.0.0.0/bindaddr = 127.0.0.1/" /etc/asterisk/manager.conf
perl -pi -e "s/; retry rules\./; retry rules\.\n#include sip-register.tenants\n"/ /etc/asterisk/sip.conf
touch /etc/asterisk/sip.tenants && echo "#include sip.tenants" >> /etc/asterisk/sip.conf
echo "* * * * * root /var/www/html/core/gen_sip_settings.php > /etc/asterisk/sip.include >/dev/null 2>&1 &" > /etc/cron.d/pbx
service crond restart
cat <<EOF >> /etc/asterisk/cdr_adaptive_odbc.conf
[global]
connection=pbxdb
username = mpbx_web
password = p@ssw0rd
loguniqueid=yes
dispositionstring=yes
table=t_cdrs ;"cdr" is default table name
usegmtime=no ; set to "yes" to log in GMT
EOF
cat <<EOF >> /etc/asterisk/res_odbc.ini
[pbxdb]
enabled => yes
dsn => mpbx
username => root
password => passw0rd
pre-connect => yes
EOF
cat <<EOF >> /etc/asterisk/res_config_mysql.conf
[pbxdb]
dbhost=localhost
dbname=mpbx
dbuser=mpbx_web
dbpass=@ssw0rd
dbport=3306
dbsock=/var/lib/mysql/mysql.sock
requirements=warn
EOF
cat <<EOF > /etc/asterisk/extensions.conf
[general]
static=yes
writeprotect=yes
priorityjumping=no
autofallthrough=no
clearglobalvars=yes
[globals]
RECORDING_FORMAT=WAV
#include extensions.tenants
[from-pstn]
include => did-inbound
exten => i,1,NooP( INVALID INBOUND EXTEN:${EXTEN} FROM ${CHANNEL(peerip)} )
same => n,Playback(invalid)
same => n,Hangup()
EOF
cat <<EOF >> /etc/asterisk/extconfig.conf
musiconhold => mysql,pbxdb,t_moh
sippeers => mysql,pbxdb,t_sip_users
voicemail => mysql,pbxdb,t_vmusers
queues => mysql,pbxdb,t_queues
queue_members => mysql,pbxdb,t_queue_members
extensions => mysql,pbxdb,t_extensions
followme => mysql,pbxdb,t_user_options
followme_numbers => mysql,pbxdb,t_user_followme
EOF
cat <<EOF >> /etc/asterisk/manager.conf
[pbx-manager-dev]
writetimeout=200
displayconnects=no
secret=92jdf3hfdf
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
permit=192.168.0.0/255.255.0.0 ; RFC 1918 addresses
permit=10.0.0.0/255.0.0.0 ; Also RFC1918
permit=172.16.0.0/12 ; Another RFC1918 with CIDR notation
permit=169.254.0.0/255.255.0.0 ; Zero conf local network
read = system,call,log,verbose,agent,user,dtmf,reporting,cdr,dialplan
write = system,call,agent,user,command,reporting,originate
EOF
cat <<EOF >> /etc/asterisk/httpd.conf
[general]
servername=Asterisk
enabled=yes
bindaddr=0.0.0.0
bindport=8081
tlsenable=yes
tlsbindaddr=0.0.0.0:8443
tlscertfile=/etc/asterisk/keys/TLS.pem
tlsprivatekey=/etc/asterisk/keys/privkey.pem
EOF
## Create INI files from samples
[ ! -f /var/www/html/include/config.ini ] && cp /var/www/html/include/config.ini.sample /var/www/html/include/config.ini
[ ! -f /var/www/html/crm/include/config.ini ] && cp /var/www/html/crm/include/config.ini.sample /var/www/html/crm/include/config.ini
cd /var/www/html/core && php ./gen_sip_settings.php
## Add Main services to Autostart
chkconfig --level 345 mysqld on && service mysqld start
chkconfig --level 345 httpd on && service httpd start
chkconfig --level 345 turnd on && service turnd start
chkconfig --level 345 asterisk on && service asterisk start