-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_lamp.sh
More file actions
1570 lines (1268 loc) · 42.3 KB
/
install_lamp.sh
File metadata and controls
1570 lines (1268 loc) · 42.3 KB
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
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
~]# cat install_lamp.sh
#!/bin/bash
#################################
# FUNC: LAMP #
# DATA: 20-01-2015 #
# AUTHOR: Rafael Andermarchi #
#################################
#Informaçs do servidor
printf "\n"
cpuname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo )
cpucores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
cpufreq=$( awk -F: ' /cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo )
svram=$( free -m | awk 'NR==2 {print $2}' )
svhdd=$( df -h | awk 'NR==2 {print $2}' )
svswap=$( free -m | awk 'NR==4 {print $2}' )
if [ -f "/proc/user_beancounters" ]; then
svip=$(ifconfig venet0:0 | grep 'inet addr:' | awk -F'inet addr:' '{ print $2}' | awk '{ print $1}')
else
svip=$(ifconfig | grep 'inet addr:' | awk -F'inet addr:' '{ print $2}' | awk '{ print $1}')
fi
printf "==========================================================================\n"
printf "Parâtros do servidor: \n"
echo "=========================================================================="
echo "VPS Type: $(virt-what)"
echo "CPU Type: $cpuname"
echo "CPU Core: $cpucores"
echo "CPU Speed: $cpufreq MHz"
echo "Memory: $svram MB"
echo "Swap: $svswap MB"
echo "Disk: $svhdd"
echo "IP's: $svip"
printf "==========================================================================\n"
printf "\n"
#Desabilitando Selinux
if [ -s /etc/selinux/config ]; then
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config &&
printf "==========================================================================\n"
printf "Desabilitando SELinux: [ \e[00;32mOK\e[00m ] \n"
echo -e "==========================================================================\n\n"
fi
# Instalando e Ajustando Repositorio
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm --force
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
if [ -f /etc/yum.repos.d/epel.repo ]
then
sed -i "s/mirrorlist=https/mirrorlist=http/" /etc/yum.repos.d/epel.repo
fi
# Update do servidor
yum -y update
clear
# Instalando Bibliotecas padrõyum install -y gcc expect gcc-c++ zlib-devel lsof autoconf nc libedit-devel make openssl-devel libtool bind-utils glib2 glib2-devel openssl bzip2 bzip2-devel libcurl-devel which libxml2-devel libxslt-devel gd gd-devel libgcj gettext-devel vim-minimal nano libpng-devel freetype freetype-devel libart_lgpl-devel GeoIP-devel aspell aspell-devel libtidy libtidy-devel libedit-devel e openldap-devel curl curl-devel diffutils libc-client libc-client-devel numactl lsof unzip zip rar unrar rsync libtool iotop htop
clear
#Habilitando IPTABLES
rm -rf /etc/sysconfig/iptables
cat > "/etc/sysconfig/iptables" << END
# 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]
##-------------------------------------- default ----------------------------------------#
-A INPUT -s 201.20.44.2 -p icmp -j ACCEPT
-A INPUT -p icmp --icmp-type echo-request -j ACCEPT
-A INPUT -p icmp -j DROP
-A INPUT -i lo -j ACCEPT
##---------------------------------------------------------------------------------------#
#
#
##-------------------------------------- HTTP -------------------------------------------#
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
##---------------------------------------------------------------------------------------#
#
#
##-------------------------------------- FTP --------------------------------------------#
-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 20 -j ACCEPT
# Porta de FTP/SSL
-A INPUT -p tcp -m tcp --dport 990 -j ACCEPT
# Portas de FTP Passivo.
-A INPUT -p tcp --dport 5500:5700 -j ACCEPT
##---------------------------------------------------------------------------------------#
#
#
##-------------------------------------- MySQL ------------------------------------------#
-A INPUT -i eth0 -s 201.20.44.2 -p tcp -m tcp --dport 3306 -j ACCEPT
#-A INPUT -i eth0 -s <IP de Origem> -p tcp -m tcp --dport 3306 -j ACCEPT
# Obs.: Caso o cliente queira realizar conex▒es externas ao MYSQL, descomentar a segunda
# linha desta sess▒o e liberar a conex▒o para o IP de origem !!!
##---------------------------------------------------------------------------------------#
#
#
##-------------------------------------- SVN --------------------------------------------#
#-A INPUT -i eth0 -p tcp -m tcp --dport 3690 -j ACCEPT
#-A INPUT -i eth0 -p udp -m udp --dport 3690 -j ACCEPT
# Obs.: Liberar estas portas somente se o cliente possuir o servi▒o SVN instalado.
##---------------------------------------------------------------------------------------#
#
#
##----------------------------- Anti Syn Flood & DDoS -----------------------------------#
-A FORWARD -p tcp --syn -m limit --limit 5/s -j ACCEPT
-A FORWARD -p tcp --syn -j DROP
-A FORWARD -p tcp --tcp-flags SYN,ACK, FIN, -m limit --limit 1/s -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -m state --state NEW -m recent --set --name DDOS --rsource
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -m state --state NEW -m recent --update --seconds 1 --hitcount 20 --name DDOS --rsource -j DROP
# Bloqueio para o AutoSpy
-A INPUT -i eht0 -p tcp -m tcp --dport 6556 -j DROP
# Bloqueio para o LampSpy
-A INPUT -i eht0 -p tcp -m tcp --dport 6660 -j DROP
# Obs.: A primeira e a segunda regra impede o atacante de mandar muitos pacotes apenas com o flag SYN on, fazendo o servidor responder com SYN-ACK para o ip (forjado), e com isso alocar os recursos para a conex▒o, al▒m de ficar aguardando pela resposta contendo o ACK, diminuindo os recursos do sistema, aumentando a demora para responder novas conex▒es, verdadeiras ou falsas, at▒ que o servi▒o que est▒ ouvindo na porta n▒o consiga mais responder, ocasionando uma nega▒▒o de servi▒o (DOS).
# Obs.: Segunda Regra visa minimizar o PortScanner
#-A INPUT -i eth0 -p tcp -m tcp --dport 54545 -j ACCEPT
# Liberando porta 54545 para script de bloqueio de IP's Mod_Security
##---------------------------------------------------------------------------------------#
#
#
##-------------------------------------- ZABBIX -----------------------------------------#
-A INPUT -i eth0 -s 177.70.96.220 -p tcp -m tcp --dport 10052 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 10052 -j DROP
##---------------------------------------------------------------------------------------#
#
#
##-------------------------------------- SSH --------------------------------------------#
-A INPUT -s 177.70.100.5 -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j DROP
##---------------------------------------------------------------------------------------#
#
#
##-------------------------------------- E-mail -----------------------------------------#
-A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 587 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 110 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 143 -j ACCEPT
##---------------------------------------------------------------------------------------#
#
#
##------------------------------------- DNS ---------------------------------------------#
-A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -p udp -m udp --dport 53 -j ACCEPT
##---------------------------------------------------------------------------------------#
#
#
##------------------------------------- Plesk -------------------------------------------#
#-A INPUT -p tcp -m tcp --dport 993 -j ACCEPT #imaps
#-A INPUT -p tcp -m tcp --dport 995 -j ACCEPT #pop3s
#-A INPUT -p tcp -m tcp --dport 465 -j ACCEPT #smtps
#-A INPUT -p tcp -m tcp --dport 8880 -j ACCEPT #plesk-http
#-A INPUT -p tcp -m tcp --dport 8443 -j ACCEPT #plesk-https
#-A INPUT -p tcp -m tcp --dport 8425 -j ACCEPT #Plesk webmail
#-A INPUT -p tcp -m tcp --dport 8447 -j ACCEPT #autoinstaller
#-A INPUT -p tcp -m tcp --dport 9080 -j ACCEPT #tomcat
##--------------------------------------------------------------------------------------#
#
#
##------------------------------------ CPanel ------------------------------------------#
#-A INPUT -p tcp -m tcp --dport 993 -j ACCEPT #imaps
#-A INPUT -p tcp -m tcp --dport 995 -j ACCEPT #pop3s
#-A INPUT -p tcp -m tcp --dport 2082 -j ACCEPT #cPanel TCP inbound
#-A INPUT -p tcp -m tcp --dport 2083 -j ACCEPT #cPanel SSL TCP inbound
#-A INPUT -p tcp -m tcp --dport 2086 -j ACCEPT #WHM TCP inbound
#-A INPUT -p tcp -m tcp --dport 2087 -j ACCEPT #WHM SSL TCP inbound
#-A INPUT -p tcp -m tcp --dport 2089 -j ACCEPT #cPanel license TCP outbound
#-A INPUT -p tcp -m tcp --dport 2095 -j ACCEPT #Webmail TCP inbound
#-A INPUT -p tcp -m tcp --dport 2096 -j ACCEPT #Webmail SSL TCP inbound
#-A INPUT -p tcp -m tcp --dport 6666 -j ACCEPT #Chat TCP inbound
#
##--------------------------------------------------------------------------------------#
#
#
COMMIT
END
# Instalando HTTPD
yum install -y httpd httpd-devel mod_ssl openssl openssl-devel
rm -rf /etc/httpd/conf/httpd.conf
cat > "/etc/httpd/conf/httpd.conf" << END
ServerTokens ProductOnly
ServerSignature OFF
#
ServerRoot "/etc/httpd"
PidFile run/httpd.pid
Timeout 60
#
KeepAlive Off
MaxKeepAliveRequests 30
KeepAliveTimeout 3
#
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 10
</IfModule>
#
<IfModule worker.c>
StartServers 4
MaxClients 300
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
#
Listen 80
#
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_alias_module modules/mod_authn_alias.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule ldap_module modules/mod_ldap.so
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule usertrack_module modules/mod_usertrack.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule info_module modules/mod_info.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule substitute_module modules/mod_substitute.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule cache_module modules/mod_cache.so
LoadModule suexec_module modules/mod_suexec.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule version_module modules/mod_version.so
LoadModule ssl_module modules/mod_ssl.so
Include conf.d/*.conf
ExtendedStatus On
User apache
Group apache
ServerAdmin [email protected]
ServerName www.mandic.com.br
UseCanonicalName Off
DocumentRoot "/var/www/html"
<Directory />
Options +FollowSymLinks
AllowOverride All
</Directory>
<Directory "/var/www/html">
Options Indexes MultiViews FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
<IfModule mod_userdir.c>
UserDir disabled
#UserDir public_html
</IfModule>
DirectoryIndex index.htm index.html index.php index.jsp index.html.var
AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</Files>
TypesConfig /etc/mime.types
DefaultType text/plain
<IfModule mod_mime_magic.c>
# MIMEMagicFile /usr/share/magic.mime
MIMEMagicFile conf/magic
</IfModule>
HostnameLookups Off
#EnableMMAP off
#EnableSendfile off
##############
# LOGS HTTPD #
##############
ErrorLog /var/log/httpd/error_log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /var/log/httpd/access_log combined
Alias /icons/ "/var/www/icons/"
<Directory "/var/www/icons">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
#
# WebDAV module configuration section.
#
<IfModule mod_dav_fs.c>
# Location of the WebDAV lock database.
DAVLockDB /var/lib/dav/lockdb
</IfModule>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
# Example:
# Redirect permanent /foo http://www.example.com/bar
IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable Charset=UTF-8
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
DefaultIcon /icons/unknown.gif
ReadmeName README.html
HeaderName HEADER.html
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
AddLanguage en .en
AddLanguage es .es
AddLanguage pt .pt
AddLanguage pt-BR .pt-br
LanguagePriority pt-BR en es
ForceLanguagePriority Prefer Fallback
AddDefaultCharset UTF-8
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
AddHandler type-map var
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Alias /error/ "/var/www/error/"
<IfModule mod_negotiation.c>
<IfModule mod_include.c>
<Directory "/var/www/error">
AllowOverride None
Options IncludesNoExec
AddOutputFilter Includes html
AddHandler type-map var
Order allow,deny
Allow from all
LanguagePriority pt-BR en es
ForceLanguagePriority Prefer Fallback
</Directory>
</IfModule>
</IfModule>
# COMPRESSION GZIP
#Set to gzip all output
SetOutputFilter DEFLATE
#exclude the following file types
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|iso|tar|bz2|sit|rar|png|jpg|gif|jpeg|flv|swf|mp3)$ no-gzip dont-vary
#set compression level
DeflateCompressionLevel 9
#Handle browser specific compression requirements
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "MS FrontPage" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully
BrowserMatch "^gnome-vfs/1.0" redirect-carefully
BrowserMatch "^XML Spy" redirect-carefully
BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 201.20.44.2
</Location>
NameVirtualHost *:80
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/gif "access plus 120 minutes"
ExpiresByType image/jpeg "access plus 120 minutes"
ExpiresByType image/png "access plus 120 minutes"
ExpiresByType text/css "access plus 60 minutes"
ExpiresByType text/javascript "access plus 60 minutes"
ExpiresByType application/x-javascript "access plus 60 minutes"
ExpiresByType text/xml "access plus 60 minutes"
</IfModule>
#DEFLATE
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript application/xml application/xhtml+xml "application/x-javascript \n\n" "text/html \n\n"
DeflateCompressionLevel 9
</IfModule>
END
cat > "/var/www/html/index.php" <<END
<?php
phpinfo();
?>
END
rm -rf /etc/httpd/conf.d/ssl.conf
service httpd restart
chkconfig httpd on
# Instalando MYSQLD
yum install -y mysql mysql-server mytop mysql-utilities
service mysqld start
DATABASE_PASS=`cat /dev/urandom| tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?='| head -c 10`
mysqladmin -u root password "$DATABASE_PASS"
mysql -u root -p"$DATABASE_PASS" -e "UPDATE mysql.user SET Password=PASSWORD('$DATABASE_PASS') WHERE User='root'"
mysql -u root -p"$DATABASE_PASS" -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')"
mysql -u root -p"$DATABASE_PASS" -e "DELETE FROM mysql.user WHERE User=''"
mysql -u root -p"$DATABASE_PASS" -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%'"
mysql -u root -p"$DATABASE_PASS" -e "FLUSH PRIVILEGES"
echo "
[client]
user=root
password='$DATABASE_PASS'
" > /root/.my.cnf
mkdir -p /mnt/mytmp
sleep 1
echo "tmpfs /mnt/mytmp tmpfs size=2G 0 0" >> /etc/fstab
sleep 3
mount -a
sleep 1
mkdir -p /var/log/mysql/
chown mysql:mysql /var/log/mysql/
mkdir -p /var/log/mysql-bin
chown mysql:mysql /var/log/mysql-bin/
chown mysql:mysql /mnt/mytmp
#service mysqld restart
rm -rf /etc/my.cnf
cat > "/etc/my.cnf" <<END
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
tmpdir=/mnt/mytmp
user=mysql
symbolic-links=0
log-error=/var/log/mysql/mysqld.log
skip-external-locking
### CONFIG RECOVERY and BIN-LOG ###
myisam-recover = BACKUP
server-id = 1
log_bin = /var/log/mysql-bin/mysql-bin.log
expire_logs_days = 3
max_binlog_size = 100M
innodb_flush_log_at_trx_commit=1
sync_binlog=1
### TUNING ###
local-infile
low-priority-updates
symbolic-links
# Log's
general_log_file = /var/log/mysql/mysql.log
general_log = 1
log-error=/var/log/mysql/error.log
slow-query-log=/var/log/mysql/slowquery.log
log_slow_queries=/var/log/mysql/slowquery.log
long_query_time=5
# Conections
connect_timeout=10
max_connections=500
max_user_connections=100
max_connect_errors=20
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8K
myisam_sort_buffer_size=2M
join_buffer_size=8M
sort_buffer_size=1M
table_cache=256
wait_timeout=30
tmp_table_size=4M
query_cache_size=2M
query_cache_limit=1M
key_buffer_size=2M
read_buffer_size = 1M
read_rnd_buffer_size = 2M
[safe_mysqld]
open_files_limit=65535
[mysqldump]
socket=/var/lib/mysql/mysql.sock
max_allowed_packet=64M
add-drop-table
extended-insert
quick
[mysql]
socket=/var/lib/mysql/mysql.sock
disable-auto-rehash
connect_timeout=15
local-infile
quick
[isamchk]
key_buffer = 16M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 16M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
END
mkdir -p /scripts
cd /scripts
wget ftp://ftpcloud.mandic.com.br/Scripts/LAMP/*.sh && chmod +x *.sh
crontab -l > script_cron
echo "00 02 * * * /scripts/backup_mysql.sh" >> script_cron
crontab script_cron
rm -rf script_cron
cd ~
service mysql restart
chkconfig mysqld on
clear
# Instalando VSFTPD
yum -y install vsftpd
rm -rf /etc/vsftpd/vsftpd.conf
cat > "/etc/vsftpd/vsftpd.conf"<<END
force_dot_files=YES
background=YES
listen=YES
chown_uploads=YES
chown_username=apache
connect_from_port_20=NO
ftp_data_port=20
listen_port=21
pasv_min_port=5500
pasv_max_port=5700
pasv_promiscuous=NO
port_enable=NO
port_promiscuous=NO
connect_timeout=60
data_connection_timeout=120
idle_session_timeout=120
setproctitle_enable=YES
banner_file=/etc/banner
dirmessage_enable=YES
pasv_enable=YES
async_abor_enable=NO
guest_enable=NO
write_enable=YES
max_clients=300
max_per_ip=20
pam_service_name=vsftpd
tcp_wrappers=NO
ascii_upload_enable=NO
ascii_download_enable=NO
hide_ids=YES
ls_recurse_enable=NO
use_localtime=NO
anonymous_enable=NO
local_enable=YES
local_max_rate=0
local_umask=0022
chroot_local_user=YES
check_shell=NO
chmod_enable=YES
secure_chroot_dir=/var/empty
userlist_file=/etc/vsftpd_users
dual_log_enable=YES
log_ftp_protocol=NO
vsftpd_log_file=/var/logs/vsftpd.log
xferlog_enable=YES
xferlog_std_format=NO
xferlog_file=/var/log/xferlog
END
touch /var/log/vsftpd.log && chown vsftpd:vsftpd /var/log/vsftpd.log
service vsftpd restart
chkconfig vsftpd on
clear
# Instalando FAIL2BAN
yum -y install fail2ban
rm -rf /etc/fail2ban/jail.conf
cat > "/etc/fail2ban/jail.conf"<<END
[DEFAULT]
ignoreip = 127.0.0.1 201.20.44.2 177.70.100.5
bantime = 345600
findtime = 300
maxretry = 5
backend = auto
usedns = warn
[pam-generic]
enabled = false
filter = pam-generic
action = iptables-allports[name=pam,protocol=all]
logpath = /var/log/secure
[xinetd-fail]
enabled = false
filter = xinetd-fail
action = iptables-allports[name=xinetd,protocol=all]
logpath = /var/log/daemon*log
[ssh-iptables]
enabled = true
filter = sshd
action = iptables[name=SSH, port=ssh, protocol=tcp]
sendmail-whois[name=SSH, [email protected], [email protected], sendername="Fail2Ban"]
logpath = /var/log/secure
maxretry = 5
[ssh-ddos]
enabled = false
filter = sshd-ddos
action = iptables[name=SSHDDOS, port=ssh, protocol=tcp]
logpath = /var/log/sshd.log
maxretry = 2
[dropbear]
enabled = false
filter = dropbear
action = iptables[name=dropbear, port=ssh, protocol=tcp]
logpath = /var/log/messages
maxretry = 5
[proftpd-iptables]
enabled = false
filter = proftpd
action = iptables[name=ProFTPD, port=ftp, protocol=tcp]
sendmail-whois[name=ProFTPD, [email protected]]
logpath = /var/log/proftpd/proftpd.log
maxretry = 6
[gssftpd-iptables]
enabled = false
filter = gssftpd
action = iptables[name=GSSFTPd, port=ftp, protocol=tcp]
sendmail-whois[name=GSSFTPd, [email protected]]
logpath = /var/log/daemon.log
maxretry = 6
[pure-ftpd]
enabled = false
filter = pure-ftpd
action = iptables[name=pureftpd, port=ftp, protocol=tcp]
logpath = /var/log/pureftpd.log
maxretry = 6
[wuftpd]
enabled = false
filter = wuftpd
action = iptables[name=wuftpd, port=ftp, protocol=tcp]
logpath = /var/log/daemon.log
maxretry = 6
[sendmail-auth]
enabled = false
filter = sendmail-auth
action = iptables-multiport[name=sendmail-auth, port="submission,465,smtp", protocol=tcp]
logpath = /var/log/mail.log
[sendmail-reject]
enabled = false
filter = sendmail-reject
action = iptables-multiport[name=sendmail-auth, port="submission,465,smtp", protocol=tcp]
logpath = /var/log/mail.log
[sasl-iptables]
enabled = false
filter = postfix-sasl
backend = polling
action = iptables[name=sasl, port=smtp, protocol=tcp]
sendmail-whois[name=sasl, [email protected]]
logpath = /var/log/mail.log
[assp]
enabled = false
filter = assp
action = iptables-multiport[name=assp,port="25,465,587"]
logpath = /root/path/to/assp/logs/maillog.txt
[ssh-tcpwrapper]
enabled = false
filter = sshd
action = hostsdeny[daemon_list=sshd]
sendmail-whois[name=SSH, [email protected]]
ignoreregex = for myuser from
logpath = /var/log/sshd.log
[ssh-route]
enabled = false
filter = sshd
action = route
logpath = /var/log/sshd.log
maxretry = 5
[ssh-iptables-ipset4]
enabled = false
filter = sshd
action = iptables-ipset-proto4[name=SSH, port=ssh, protocol=tcp]
logpath = /var/log/sshd.log
maxretry = 5
[ssh-iptables-ipset6]
enabled = false
filter = sshd
action = iptables-ipset-proto6[name=SSH, port=ssh, protocol=tcp, bantime=600]
logpath = /var/log/sshd.log
maxretry = 5
[ssh-bsd-ipfw]
enabled = false
filter = sshd
action = bsd-ipfw[port=ssh,table=1]
logpath = /var/log/auth.log
maxretry = 5
[apache-tcpwrapper]
enabled = false
filter = apache-auth
action = hostsdeny
logpath = /var/log/apache*/*error.log
/home/www/myhomepage/error.log
maxretry = 6
[apache-modsecurity]
enabled = false
filter = apache-modsecurity
action = iptables-multiport[name=apache-modsecurity,port="80,443"]
logpath = /var/log/apache*/*error.log
/home/www/myhomepage/error.log
maxretry = 2
[apache-overflows]
enabled = false
filter = apache-overflows
action = iptables-multiport[name=apache-overflows,port="80,443"]
logpath = /var/log/apache*/*error.log
/home/www/myhomepage/error.log
maxretry = 2
[apache-nohome]
enabled = false
filter = apache-nohome
action = iptables-multiport[name=apache-nohome,port="80,443"]
logpath = /var/log/apache*/*error.log
/home/www/myhomepage/error.log
maxretry = 2
[nginx-http-auth]
enabled = false
filter = nginx-http-auth
action = iptables-multiport[name=nginx-http-auth,port="80,443"]
logpath = /var/log/nginx/error.log
[squid]
enabled = false
filter = squid
action = iptables-multiport[name=squid,port="80,443,8080"]
logpath = /var/log/squid/access.log
[postfix-tcpwrapper]
enabled = false
filter = postfix
action = hostsdeny[file=/not/a/standard/path/hosts.deny]
sendmail[name=Postfix, [email protected]]
logpath = /var/log/postfix.log
bantime = 300
[cyrus-imap]
enabled = false
filter = cyrus-imap
action = iptables-multiport[name=cyrus-imap,port="143,993"]
logpath = /var/log/mail*log
[courierlogin]
enabled = false
filter = courierlogin
action = iptables-multiport[name=courierlogin,port="25,110,143,465,587,993,995"]
logpath = /var/log/mail*log
[couriersmtp]
enabled = false
filter = couriersmtp
action = iptables-multiport[name=couriersmtp,port="25,465,587"]
logpath = /var/log/mail*log
[qmail-rbl]
enabled = false
filter = qmail
action = iptables-multiport[name=qmail-rbl,port="25,465,587"]
logpath = /service/qmail/log/main/current
[sieve]
enabled = false
filter = sieve
action = iptables-multiport[name=sieve,port="25,465,587"]
logpath = /var/log/mail*log
[vsftpd-notification]
enabled = false
filter = vsftpd
action = sendmail-whois[name=VSFTPD, [email protected]]
logpath = /var/log/vsftpd.log
maxretry = 5
bantime = 1800
[vsftpd-iptables]
enabled = false
filter = vsftpd
action = iptables[name=VSFTPD, port=ftp, protocol=tcp]
sendmail-whois[name=VSFTPD, [email protected]]