-
Notifications
You must be signed in to change notification settings - Fork 277
/
f8x-dev
840 lines (658 loc) · 26.4 KB
/
f8x-dev
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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
#!/usr/bin/env bash
# ===================== Basic variable settings =====================
if test -e /usr/local/bin/f8x
then
sleep 0.001
# f8x -update
else
curl -o f8x https://f8x.io/ && mv --force f8x /usr/local/bin/f8x && chmod +x /usr/local/bin/f8x && echo -e "\033[1;36m$(date +"%H:%M:%S")\033[0m \033[1;32m[INFOR]\033[0m - \033[1;32mInstalled f8x tools\033[0m" || echo -e "\033[1;36m$(date +"%H:%M:%S")\033[0m \033[1;31m[ERROR]\033[0m - \033[1;31mf8x installation failed\n\033[0m"
fi
. /usr/local/bin/f8x > /dev/null 2>&1
F8x_dev_Version="0.1.2 Dev"
ran=$RANDOM
# ===================== Software version variable setting =====================
tomcat6_bin="apache-tomcat-6.0.53.tar.gz"
tomcat6_dir="apache-tomcat-6.0.53"
tomcat7_bin="apache-tomcat-7.0.109.tar.gz"
tomcat7_dir="apache-tomcat-7.0.109"
tomcat8_bin="apache-tomcat-8.5.68.tar.gz"
tomcat8_dir="apache-tomcat-8.5.68"
tomcat9_bin="apache-tomcat-9.0.50.tar.gz"
tomcat9_dir="apache-tomcat-9.0.50"
Main
Pentest_Base_Install > /dev/null 2>&1
# ===================== Install mariadb (pkg) =====================
mariadb_Install(){
name="mariadb"
which mysql > /dev/null 2>&1
if [ $? == 0 ]
then
Echo_ALERT "$name installed"
systemctl start mariadb && Echo_INFOR "systemctl start mariadb"
else
Rm_Lock
case $Linux_Version in
*"CentOS"*|*"RedHat"*|*"Fedora"*)
Install_Switch "mariadb"
Install_Switch "mariadb-server"
;;
*"Kali"*|*"Ubuntu"*|*"Debian"*)
Install_Switch "mariadb-client"
Install_Switch "mariadb-server"
;;
*) ;;
esac
systemctl start mariadb
mysql_secure_installation
mysqlcmd="select User, host from mysql.user;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'toor' WITH GRANT OPTION;
FLUSH PRIVILEGES;"
mysql -u root -p -e "${mysqlcmd}"
Echo_INFOR "Default root/toor For security reasons, please do not deploy in a public network environment."
systemctl restart mariadb
# If you can't connect, you need to modify the configuration file
# vim /etc/mysql/mariadb.conf.d/50-server.cnf
# bind-address = 0.0.0.0
# :wq
# systemctl restart mariadb
fi
}
# ===================== Install influxdb (docker) (x86) (arm64) =====================
influxdb_docker_Install(){
name="influxdb"
echo -e "\033[5;33m\nPlease enter your influxdb listening port (Default 8086)\033[0m" && read -r input
influxdb_port=$input
if [ $influxdb_port == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认监听端口为 8086"
influxdb_port="8086"
fi
# https://hub.docker.com/_/influxdb
docker pull influxdb
docker run -d -p $influxdb_port:8086 --name f8x-influxdb-$ran influxdb:latest || { Echo_ERROR "Deployment failed"; exit 1; }
docker ps
Echo_ALERT "Already listening to 0.0.0.0:$influxdb_port, please do not deploy in public network environment"
Echo_INFOR "Connect database with following setting:\nlisten: 0.0.0.0:$influxdb_port"
}
# ===================== Install mariadb (docker) (x86) (arm64) =====================
mariadb_docker_Install(){
name="mariadb"
echo -e "\033[5;33m\nPlease enter your mariadb listening port (Default 3306)\033[0m" && read -r input
mariadb_port=$input
if [ $mariadb_port == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认监听端口为 3306"
mariadb_port="3306"
fi
echo -e "\033[5;33m\nPlease enter your mariadb password (Default ffffffff0x)\033[0m" && read -r input
mariadb_pass=$input
if [ $mariadb_pass == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认密码为 ffffffff0x"
mariadb_pass="ffffffff0x"
fi
# https://hub.docker.com/_/mariadb
docker pull mariadb
docker run -d -p $mariadb_port:3306 --name f8x-mariadb-$ran -e MYSQL_ROOT_PASSWORD=$mariadb_pass mariadb:latest || { Echo_ERROR "Deployment failed"; exit 1; }
# Error : Can't initialize timers
# Use : docker run -d -p $mariadb_port:3306 -e MYSQL_ROOT_PASSWORD=$mariadb_pass mariadb:10.7
docker ps
Echo_ALERT "Already listening to 0.0.0.0:$mariadb_port, please do not deploy in public network environment"
Echo_INFOR "Connect database with following setting:\nlisten: 0.0.0.0:$mariadb_port\nusername: root\npassword: $mariadb_pass"
}
# ===================== Install memcached (docker) =====================
memcached_docker_Install(){
name="memcached"
echo -e "\033[5;33m\nPlease enter your memcached listening port (Default 11211)\033[0m" && read -r input
memcached_port=$input
if [ $memcached_port == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认监听端口为 11211"
memcached_port="11211"
fi
# https://hub.docker.com/_/memcached
docker pull memcached
docker run -d -p $memcached_port:11211 --name f8x-memcached-$ran memcached || { Echo_ERROR "Deployment failed"; exit 1; }
docker ps
Echo_ALERT "Already listening to 0.0.0.0:$memcached_port, please do not deploy in public network environment"
}
# ===================== Install mongodb (docker) =====================
mongodb_docker_Install(){
name="mongodb"
echo -e "\033[5;33m\nPlease enter your mongodb listening port (Default 27017)\033[0m" && read -r input
mongodb_port=$input
if [ $mongodb_port == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认监听端口为 27017"
mongodb_port="27017"
fi
# https://hub.docker.com/_/mongo
docker pull mongo
docker run -d -p $mongodb_port:27017 --name f8x-mongodb-$ran mongo || { Echo_ERROR "Deployment failed"; exit 1; }
docker ps
Echo_ALERT "Already listening to 0.0.0.0:$mongodb_port, please do not deploy in public network environment"
}
# ===================== Install mssql2019 (docker) =====================
mssql2019_docker_Install(){
name="mssql2019"
echo -e "\033[5;33m\nPlease enter your mssql2019 listening port (Default 1433)\033[0m" && read -r input
mssql2019_port=$input
if [ $mssql2019_port == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认监听端口为 1433"
mssql2019_port="1433"
fi
echo -e "\033[5;33m\nPlease enter your mssql2019 password(必须包含大小写、字母和数字、特殊符号)(Default Abcd1234!!)\033[0m" && read -r input
mssql2019_pass=$input
if [ $mssql2019_pass == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认密码为 Abcd1234!!"
mssql2019_pass='Abcd1234!!'
fi
# https://hub.docker.com/_/microsoft-mssql-server
docker pull mcr.microsoft.com/mssql/server:2019-CU15-ubuntu-20.04
docker run -d -p $mssql2019_port:1433 --name=f8x-sqlserver -e 'ACCEPT_EULA=Y' -e SA_PASSWORD=$mssql2019_pass -e 'MSSQL_PID=Developer' mcr.microsoft.com/mssql/server:2019-CU15-ubuntu-20.04 || { Echo_ERROR "Deployment failed"; exit 1; }
docker ps
Echo_ALERT "Already listening to 0.0.0.0:$mssql2019_port, please do not deploy in public network environment"
Echo_INFOR "Connect database with following setting:\nlisten: 0.0.0.0:$mssql2019_port\nusername: sa\npassword: $mssql2019_pass"
}
# ===================== Install mysql (docker) (x86) =====================
mysql_docker_Install(){
name="mysql"
echo -e "\033[5;33m\nPlease enter your mysql listening port (Default 3306)\033[0m" && read -r input
mysql_port=$input
if [ $mysql_port == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认监听端口为 3306"
mysql_port="3306"
fi
echo -e "\033[5;33m\nPlease enter your mysql password (Default ffffffff0x)\033[0m" && read -r input
mysql_pass=$input
if [ $mysql_pass == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认密码为 ffffffff0x"
mysql_pass="ffffffff0x"
fi
# https://hub.docker.com/_/mysql
docker pull mysql:latest
docker run -d -p $mysql_port:3306 --name f8x-mysql-$ran -e MYSQL_ROOT_PASSWORD=$mysql_pass mysql:latest || { Echo_ERROR "Deployment failed"; exit 1; }
docker ps
Echo_ALERT "Already listening to 0.0.0.0:$mysql_port, please do not deploy in public network environment"
Echo_INFOR "Connect database with following setting:\nlisten: 0.0.0.0:$mysql_port\nusername: root\npassword: $mysql_pass"
}
# ===================== Install oracle11 (docker) =====================
oracle11_docker_Install(){
name="oracle11"
echo -e "\033[5;33m\nPlease enter your oracle11 listening port (Default 1521)\033[0m" && read -r input
oracle11_port=$input
if [ $oracle11_port == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认监听端口为 1521"
oracle11_port="1521"
fi
echo -e "\033[5;33m\nPlease enter your oracle11 password (Default ffffffff0x)\033[0m" && read -r input
oracle11_pass=$input
if [ $oracle11_pass == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认密码为 ffffffff0x"
oracle11_pass="ffffffff0x"
fi
# https://hub.docker.com/r/gvenzl/oracle-xe
docker pull gvenzl/oracle-xe:11
docker run -d -p $oracle11_port:1521 --name f8x-oracle11-$ran -e ORACLE_PASSWORD=$oracle11_pass gvenzl/oracle-xe:11 || { Echo_ERROR "Deployment failed"; exit 1; }
docker ps
Echo_ALERT "Already listening to 0.0.0.0:$oracle11_port, please do not deploy in public network environment"
Echo_INFOR "Connect database with following setting:\nlisten: 0.0.0.0:$oracle11_port\nsid : XE\nusername: system\npassword: $oracle11_pass"
}
# ===================== Install postgres (docker) =====================
postgres_docker_Install(){
name="postgres"
echo -e "\033[5;33m\nPlease enter your PostgreSQL listening port (Default 5432)\033[0m" && read -r input
postgres_port=$input
if [ $postgres_port == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认监听端口为 5432"
postgres_port="5432"
fi
echo -e "\033[5;33m\nPlease enter your PostgreSQL password (Default ffffffff0x)\033[0m" && read -r input
postgres_pass=$input
if [ $postgres_pass == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认密码为 ffffffff0x"
postgres_pass="ffffffff0x"
fi
# https://hub.docker.com/_/postgres
docker pull postgres:14.7
docker run -d -p $postgres_port:5432 --name f8x-postgres-$ran -e POSTGRES_PASSWORD=$postgres_pass postgres:14.7 || { Echo_ERROR "Deployment failed"; exit 1; }
docker ps
Echo_ALERT "Already listening to 0.0.0.0:$postgres_port, please do not deploy in public network environment"
Echo_INFOR "Connect database with following setting:\nlisten: 0.0.0.0:$postgres_port\nusername: postgres\npassword: $postgres_pass"
}
# ===================== Install redis (docker) =====================
redis_docker_Install(){
name="redis"
echo -e "\033[5;33m\nPlease enter your redis listening port (Default 6379)\033[0m" && read -r input
redis_port=$input
if [ $redis_port == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认监听端口为 6379"
redis_port="6379"
fi
# https://hub.docker.com/_/redis
docker pull redis
docker run -d -p $redis_port:6379 --name f8x-redis-$ran redis || { Echo_ERROR "Deployment failed"; exit 1; }
docker ps
Echo_ALERT "Already listening to 0.0.0.0:$redis_port, please do not deploy in public network environment!!!!"
Echo_ALERT "Already listening to 0.0.0.0:$redis_port, please do not deploy in public network environment!!!!"
Echo_ALERT "Already listening to 0.0.0.0:$redis_port, please do not deploy in public network environment!!!!"
}
# ===================== Install tomcat7 (docker) (x86) (arm) =====================
tomcat7_docker_Install(){
name="tomcat7"
echo -e "\033[5;33m\nPlease enter your tomcat listening port (Default 8080)\033[0m" && read -r input
tomcat7_port=$input
if [ $tomcat7_port == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认监听端口为 8080"
tomcat7_port="8080"
fi
# https://hub.docker.com/_/tomcat
docker pull tomcat:7.0
docker run -d -p $tomcat7_port:8080 tomcat:7.0
docker ps
Echo_ALERT "Already listening to 0.0.0.0:$tomcat7_port"
}
# ===================== Install tomcat8 (docker) (x86) =====================
tomcat8_docker_Install(){
name="tomcat8"
echo -e "\033[5;33m\nPlease enter your tomcat listening port (Default 8080)\033[0m" && read -r input
tomcat8_port=$input
if [ $tomcat8_port == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认监听端口为 8080"
tomcat8_port="8080"
fi
# https://hub.docker.com/_/tomcat
docker pull tomcat:8.5.77
docker run -d -p $tomcat8_port:8080 tomcat:8.5.77
docker ps
Echo_ALERT "Already listening to 0.0.0.0:$tomcat8_port"
}
# ===================== Install tomcat9 (docker) (x86) (arm) =====================
tomcat9_docker_Install(){
name="tomcat9"
echo -e "\033[5;33m\nPlease enter your tomcat listening port (Default 8080)\033[0m" && read -r input
tomcat9_port=$input
if [ $tomcat9_port == ] 2>> /tmp/f8x_error.log
then
echo -e "输入为空,默认监听端口为 8080"
tomcat9_port="8080"
fi
# https://hub.docker.com/_/tomcat
docker pull tomcat:9.0
docker run -d -p $tomcat9_port:8080 tomcat:9.0
docker ps
Echo_ALERT "Already listening to 0.0.0.0:$tomcat9_port"
}
# ===================== Install tomcat6 (src) =====================
tomcat6_src_Install(){
# Tomcat 6.0 requires JRE 5.0 or later.
name="tomcat6"
dir="/usr/local/$tomcat6_dir"
if test -d $dir
then
Echo_ALERT "$name is already installed in $dir"
else
cd $T_Dir && rm -rf $tomcat6_bin && $Proxy_OK wget https://archive.apache.org/dist/tomcat/tomcat-6/v6.0.53/bin/$tomcat6_bin > /dev/null 2>&1 || Echo_ERROR2
tar -zxf $tomcat6_bin -C /usr/local/ > /dev/null 2>&1 && rm -rf $tomcat6_bin
fi
rm -rf /usr/local/tomcat
ln -s /usr/local/${tomcat6_dir}/ /usr/local/tomcat
Echo_INFOR "Manually run the following command:\nexport CATALINA_HOME=/usr/local/tomcat\nexport PATH=\$CATALINA_HOME/bin:\$PATH"
Echo_INFOR "catalina.sh version"
Echo_INFOR "catalina.sh start"
}
# ===================== Install tomcat7 (src) =====================
tomcat7_src_Install(){
# Tomcat 7.0 requires Java 6 or later.
name="tomcat7"
dir="/usr/local/$tomcat7_dir"
if test -d $dir
then
Echo_ALERT "$name is already installed in $dir"
else
cd $T_Dir && rm -rf $tomcat7_bin && $Proxy_OK wget https://archive.apache.org/dist/tomcat/tomcat-7/v7.0.109/bin/$tomcat7_bin > /dev/null 2>&1 || Echo_ERROR2
tar -zxf $tomcat7_bin -C /usr/local/ > /dev/null 2>&1 && rm -rf $tomcat7_bin
fi
rm -rf /usr/local/tomcat
ln -s /usr/local/${tomcat7_dir}/ /usr/local/tomcat
Echo_INFOR "Manually run the following command:\nexport CATALINA_HOME=/usr/local/tomcat\nexport PATH=\$CATALINA_HOME/bin:\$PATH"
Echo_INFOR "catalina.sh version"
Echo_INFOR "catalina.sh start"
}
# ===================== Install tomcat8 (src) =====================
tomcat8_src_Install(){
# Tomcat 8.5 requires Java 7 or later.
name="tomcat8"
dir="/usr/local/$tomcat8_dir"
if test -d $dir
then
Echo_ALERT "$name is already installed in $dir"
else
cd $T_Dir && rm -rf $tomcat8_bin && $Proxy_OK wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.68/bin/$tomcat8_bin > /dev/null 2>&1 || Echo_ERROR2
tar -zxf $tomcat8_bin -C /usr/local/ > /dev/null 2>&1 && rm -rf $tomcat8_bin
fi
rm -rf /usr/local/tomcat
ln -s /usr/local/${tomcat8_dir}/ /usr/local/tomcat
Echo_INFOR "Manually run the following command:\nexport CATALINA_HOME=/usr/local/tomcat\nexport PATH=\$CATALINA_HOME/bin:\$PATH"
Echo_INFOR "catalina.sh version"
Echo_INFOR "catalina.sh start"
}
# ===================== Install tomcat9 (src) =====================
tomcat9_src_Install(){
# Tomcat 9.0 requires Java 8 or later.
name="tomcat9"
dir="/usr/local/$tomcat9_dir"
if test -d $dir
then
Echo_ALERT "$name is already installed in $dir"
else
cd $T_Dir && rm -rf $tomcat9_bin && $Proxy_OK wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.50/bin/$tomcat9_bin > /dev/null 2>&1 || Echo_ERROR2
tar -zxf $tomcat9_bin -C /usr/local/ > /dev/null 2>&1 && rm -rf $tomcat9_bin
fi
rm -rf /usr/local/tomcat
ln -s /usr/local/${tomcat9_dir}/ /usr/local/tomcat
Echo_INFOR "Manually run the following command:\nexport CATALINA_HOME=/usr/local/tomcat\nexport PATH=\$CATALINA_HOME/bin:\$PATH"
Echo_INFOR "catalina.sh version"
Echo_INFOR "catalina.sh start"
}
# ===================== Install nginx (pkg) =====================
nginx_Install_pkg(){
name="nginx"
Rm_Lock
Install_Switch "nginx"
Echo_INFOR "systemctl status nginx"
systemctl status nginx
}
# ===================== Install apache (pkg) =====================
apache_Install_pkg(){
name="apache2"
Rm_Lock
case $Linux_Version in
*"CentOS"*|*"RedHat"*|*"Fedora"*|*"AlmaLinux"*|*"VzLinux"*|*"Rocky"*)
Install_Switch "httpd"
Echo_INFOR "systemctl status httpd"
systemctl status httpd
;;
*"Kali"*|*"Ubuntu"*|*"Debian"*)
Install_Switch "apache2"
Echo_INFOR "systemctl status apache2"
systemctl status apache2
;;
*)
;;
esac
}
php_base_Install(){
Rm_Lock
case $Linux_Version in
*"CentOS"*|*"RedHat"*|*"Fedora"*|*"AlmaLinux"*|*"VzLinux"*|*"Rocky"*)
Echo_INFOR "RedHat 系暂未适配"
;;
*"Debian"*|*"Kali"*)
Install_Switch "software-properties-common"
Install_Switch "gnupg"
curl -fsSL https://packages.sury.org/php/apt.gpg | sudo apt-key add -
sudo add-apt-repository "deb https://packages.sury.org/php/ $(lsb_release -cs) main"
apt-get update > /dev/null 2>&1
;;
*"Ubuntu"*)
Install_Switch "software-properties-common"
Install_Switch "gnupg"
sudo add-apt-repository ppa:ondrej/php
apt-get update > /dev/null 2>&1
;;
*) ;;
esac
}
# ===================== Install php5.6 (pkg) =====================
php56_Install(){
name="php5.6"
php_base_Install
case $Linux_Version in
*"Kali"*|*"Ubuntu"*|*"Debian"*)
Install_Switch "php5.6"
Install_Switch "php5.6-fpm"
Install_Switch "php5.6-mysql"
Install_Switch "php5.6-curl"
Install_Switch "php5.6-json"
Install_Switch "php5.6-mbstring"
Install_Switch "php5.6-gd"
Install_Switch "php5.6-xml"
Install_Switch "php5.6-intl"
Install_Switch "php5.6-odbc"
Install_Switch "php5.6-cgi"
Install_Switch "php5.6-zip"
update-alternatives --config php
php -v
Echo_INFOR "Run the following command to switch php version:\nupdate-alternatives --config php"
;;
*) ;;
esac
}
# ===================== Install php7.2 (pkg) =====================
php72_Install(){
name="php7.2"
php_base_Install
case $Linux_Version in
*"Kali"*|*"Ubuntu"*|*"Debian"*)
Install_Switch "php7.2"
Install_Switch "php7.2-fpm"
Install_Switch "php7.2-mysql"
Install_Switch "php7.2-curl"
Install_Switch "php7.2-json"
Install_Switch "php7.2-mbstring"
Install_Switch "php7.2-gd"
Install_Switch "php7.2-xml"
Install_Switch "php7.2-intl"
Install_Switch "php7.2-odbc"
Install_Switch "php7.2-cgi"
Install_Switch "php7.2-zip"
update-alternatives --config php
php -v
Echo_INFOR "Run the following command to switch php version:\nupdate-alternatives --config php"
;;
*) ;;
esac
}
# ===================== Install php7.2 (pkg) + nginx (pkg) + autoconfig =====================
php72_nginx_Install(){
service httpd stop > /dev/null 2>&1
apt remove -y apache2 > /dev/null 2>&1
nginx_Install_pkg
php72_Install
mkdir -p /var/www/php && cd $_
echo "<?php phpinfo() ?>" > /var/www/php/phpinfo.php
# nginx 配置
cd /etc/nginx/sites-available
rm -rf default
tee default <<-'EOF'
server {
listen 7777 default_server;
location / {
root /var/www/php;
index index.php;
try_files $uri $uri/ =404;
}
location ~ \.php$ {
root /var/www/php;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
EOF
/usr/sbin/php-fpm7.2 1> /dev/null 2>> /tmp/f8x_error.log
/usr/sbin/nginx -t 1> /dev/null 2>> /tmp/f8x_error.log
service nginx restart
ufw disable 1> /dev/null 2>> /tmp/f8x_error.log
service firewalld stop 1> /dev/null 2>> /tmp/f8x_error.log
systemctl start nginx.service
ss -tnlp
chmod -R 777 /var/www/php/
Echo_INFOR "config : /etc/nginx/sites-available/default"
Echo_INFOR "www : /var/www/php"
Echo_INFOR "test : curl http://127.0.0.1:7777/phpinfo.php"
}
# -help
Help_Info(){
echo -e "\033[1;34mapache \033[0m"
echo -e " \033[1;34m-apache-pkg\033[0m \033[0;34m : install apache (Package Manager) \033[0m"
echo -e ""
echo -e "\033[1;34mnginx \033[0m"
echo -e " \033[1;34m-nginx-pkg\033[0m \033[0;34m : install nginx (Package Manager) \033[0m"
echo -e " \033[1;34m-nginx-src\033[0m \033[0;34m : install nginx (Compile) \033[0m"
echo -e ""
echo -e "\033[1;34mtomcat \033[0m"
echo -e " \033[1;34m-tomcat6-src\033[0m \033[0;34m : install tomcat6 (Compile)\033[0m"
echo -e " \033[1;34m-tomcat7\033[0m \033[0;34m : install tomcat7 (Docker)\033[0m"
echo -e " \033[1;34m-tomcat7-src\033[0m \033[0;34m : install tomcat7 (Compile)\033[0m"
echo -e " \033[1;34m-tomcat8\033[0m \033[0;34m : install tomcat8 (Docker)\033[0m"
echo -e " \033[1;34m-tomcat8-src\033[0m \033[0;34m : install tomcat8 (Compile)\033[0m"
echo -e " \033[1;34m-tomcat9\033[0m \033[0;34m : install tomcat9 (Docker)\033[0m"
echo -e " \033[1;34m-tomcat9-src\033[0m \033[0;34m : install tomcat9 (Compile)\033[0m"
echo -e ""
echo -e "\033[1;34mDatabase \033[0m"
echo -e " \033[1;34m-influxdb\033[0m \033[0;34m : install InfluxDB (Docker) \033[0m"
echo -e " \033[1;34m-mariadb\033[0m \033[0;34m : install mariadb (Docker) \033[0m"
echo -e " \033[1;34m-memcached\033[0m \033[0;34m : install memcached (Docker) \033[0m"
echo -e " \033[1;34m-mongodb\033[0m \033[0;34m : install mongodb (Docker) \033[0m"
echo -e " \033[1;34m-mssql2019\033[0m \033[0;34m : install mssql2019 (Docker) \033[0m"
echo -e " \033[1;34m-mysql\033[0m \033[0;34m : install mysql (Docker) \033[0m"
echo -e " \033[1;34m-oracle11\033[0m \033[0;34m : install oracle11 (Docker) \033[0m"
echo -e " \033[1;34m-postgres\033[0m \033[0;34m : install PostgreSQL(Docker) \033[0m"
echo -e " \033[1;34m-redis\033[0m \033[0;34m : install redis (Docker) \033[0m"
echo -e ""
echo -e "\033[1;34mphp \033[0m"
echo -e " \033[1;34m-php56\033[0m \033[0;34m : install php5.6 (Package Manager)\033[0m"
echo -e " \033[1;34m-php72\033[0m \033[0;34m : install php7.2 (Package Manager)\033[0m"
echo -e " \033[1;34m-php72-nginx\033[0m \033[0;34m : install php7.2 + nginx (Package Manager) \033[0m"
echo -e ""
echo -e "\033[1;37mcreate by ffffffff0x\033[0m"
echo -e ""
}
for cmd in $@
do
case $cmd in
-influxdb)
Base_Check
Docker_Check
influxdb_docker_Install
;;
-mariadb)
Base_Check
Docker_Check
mariadb_docker_Install
;;
-memcached)
Base_Check
Docker_Check
memcached_docker_Install
;;
-mongodb)
Base_Check
Docker_Check
mongodb_docker_Install
;;
-mssql2019)
Base_Check
Docker_Check
mssql2019_docker_Install
;;
-mysql)
Base_Check
Docker_Check
mysql_docker_Install
;;
-oracle11)
Base_Check
Docker_Check
oracle11_docker_Install
;;
-postgres)
Base_Check
Docker_Check
postgres_docker_Install
;;
-redis)
Base_Check
Docker_Check
redis_docker_Install
;;
-tomcat7)
Base_Check
Docker_Check
tomcat7_docker_Install
;;
-tomcat8)
Base_Check
Docker_Check
tomcat8_docker_Install
;;
-tomcat9)
Base_Check
Docker_Check
tomcat9_docker_Install
;;
-tomcat6-src)
Proxy_Switch
Base_Check
tomcat6_src_Install
;;
-tomcat7-src)
Proxy_Switch
Base_Check
tomcat7_src_Install
;;
-tomcat8-src)
Proxy_Switch
Base_Check
tomcat8_src_Install
;;
-tomcat9-src)
Proxy_Switch
Base_Check
tomcat9_src_Install
;;
-nginx-src)
Proxy_Switch
Base_Check
nginx_Install
;;
-nginx-pkg)
nginx_Install_pkg
;;
-apache-pkg)
apache_Install_pkg
;;
-php56)
Base_Check
php56_Install
;;
-php72)
Base_Check
php72_Install
;;
-php72-nginx)
Base_Check
php72_nginx_Install
;;
-help | help)
printf "\033c"
Help_Info
exit 1
;;
esac
done
echo -e "\033[1;36m \n-----OVER-----\n \033[0m"