forked from gangireddydanam/saggiapps
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Apache
502 lines (323 loc) · 9.43 KB
/
Apache
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
client----->webserver------->app severs---->DB servers(oracle/mysql/sql sever/db2/mongodb/redshift..etc)
client----->webservers(public network)DMZ---->business logic running server(PRIVATE NETWORK)
security
no need to put port number
static content--same page--->www.gmail.com---->login page---credetntials--->
load balancing--s/w lb
Apache Software Foundation---ASF---->OpenSource----->software---------->customize--->commercial
2.4--latest
2.2--->still in use
Apache-->
--->nginx , ihs, ohs, jws ,
OpenSource
StaticConent---webserver-------
LAMP----linux,mysql,apache,php------>Wordpress,drupal,typo3,magento....etc
WAMP--Windows,"
no java
no .net
php---static--->apache
blogs--facebook--->lamp
Custom Error page---404---HTTP Status codes---200
200 success
300-redirection with sucess/cache
400- resource issue--file not found,403,401,
500--server related issues
501,502,503
18.221.85.255----->ec2---->/var/www/html------>gangi.html-----
client---->apache---->mysql---lamp/wamp
client---->apache---->Tomcat/websphere/weblogic/glashfish(java based applications---->DB
shell
pgming laungauge--->runtimeplaform
.net---->IIS------Windows------------>power shell
java---->tomcat/weblogic/websphere/glashfish
static code---->apache/nginx/iis
php--------->Apache
SAP ABAP------>SAP Basis server
c/c++-------------->mainframe
no iis in linux
iis only runs in windows servers
stop/start/deployment--->power shell--->reports
Apache-----
Installation ways
Windows--->msi--->next ---next
binary/zip--->extract --->use
Unix
------------
yum--------->public/private---->/etc/yum.repos.d/*.repo---->base url /mirror list
source code(c/c++)----->compile(c compiler---gcc)---->build---->apache
rpm
yum and rpm ?
#!/bin/bash
#Author:
#Version:
echo "i am installing basic packages"
yum install bind-utils unzip wget telnet nc -y
To install apache with yum
yum install httpd -y
/etc/httpd---->server location--serverroot
httpd.conf---->conf
conf.d--->.conf
logs--->access.log and error.log
modules--->import/include
conf.d
conf.modules.d
logs -> ../../var/log/httpd
conf
/run/httpd
modules -> ../../usr/lib64/httpd/modules
conf------------>httpd.conf
updating/modifying httpd.conf--->restart of apache
more or less(interactive)
httpd.conf(Directives/tags)
==========================
key= value(only value)
ServerRoot "/etc/httpd"---------------->Apache Installation location
Listen 80------------------------------>Apache running port number
Include --------->
User apache----------------->Apache process owner
Group apache---------------->apache process group
ServerAdmin root@localhost------------>SystemAdmin email
ServerName <websitename>------------->websitename
Permissions purpose
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/var/www/html"----------->website content location
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
<IfModule dir_module>
DirectoryIndex home.html--------------->from many files--->pick single file
</IfModule>
DocumentRoot---->which one i have to show as home page---DirectoryIndex
Apache--LAB-1
============================================================
Change port number in httpd.conf---->Listen 100
Change your website location ---->/opt/website/
/var/www/html----------------->/opt/website/
httpd.conf---->/var/www/html------------>/opt/website/
/opt/website--->index.html-----rename----->login.html
DirectoryIndex login.html
------>Restart apache--->Test page---ip:100
Rule-->100
Listen & DocuementRoot & DirectoryIndex------------>tags
==================================================================
==================================================================
httpd.conf----->/etc/httpd/conf/httpd.conf-----any errors
stop/start---
syntax--->ok--->stop
pem file
ec2 machine--ip or name
18.221.85.255
===========================================================================
Lab: login with other user(sudoer)
ec2-user---------------->sudo su - root--->awsadmin--->sudoer
/etc/ssh/sshd_config----->PasswordAuthentication no ----->PasswordAuthentication yes
username:
password:
ec2-user:
password=key file
one user---->awsadmin
password:12345
ec2---->awsadmin-------->sudoer--------------->/etc/sudoers
paswword:12345
userid : awsadmin
sudoer
password
/etc/ssh/sshd_config----->PasswordAuthentication no ----->PasswordAuthentication yes
esc---->:%s/PasswordAuthentication no/PasswordAuthentication yes/g
service sshd restart
sed--->
awk
=======================================================================================
/
bin
bash
grep -iRl "listen" *---------->it searches
grep -il "listen" * ----100 files---2 files--->
grep -- to search a string/keyword/numbers
grep -i--ignore case
grep -l ---list only files
grep -c --count
grep -n---number line
grep -R ---Recursive
/opt/apache---->awsadmin:awsadmin
=================================================
/usr/sbin/apachectl -t ----------->syntax check
systemctl status httpd.service
stop
systemctl stop httpd
/apache/bin/apachectl -k stop
start
systemctl start httpd
/apache/bin/apachectl -k start
/apache/bin/apachectl -t
/apache/bin/apachectl -v
/apache/bin/apachectl -S --- to know hwo many websites are running from apache
Tunneling---------->bypass---------->ec2
browser---->my windows---->localhost--->127.0.0.1(windows)---100----putty---tunneling
localhost------------
========================
Selinux---security
getenforce--enabled
setenforce 0------>permissve
====================================================
curl website
curl ip
curl localhost
curl 127.0.0.1
==========================================================
conf/httpd.conf----
Listen
DocumentRoot
ServerName
DirectoryIndex
ServerAdmin
<Directory>
Permissons
</Directory>
Virtualhosting--running websites
VirtualHosting---2 types
1)ip based---1 ip --- 1 website
2)Name based--1 ip -- many websites
NameVirtualHost *:80
www.test.com----->DNS---->ip---->ec2--->www.test.com---->DocumentRoot-->home.html
<VirtualHost ip:80>
ServerName www.test.com
DocumentRoot /opt/website/test
DirectoryIndex home.html
<Directory /opt/website/test>
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.xyz.com
DocumentRoot /opt/website/xyz
DirectoryIndex index.html
<Directory /opt/website/xyz>
Allow from all
</Directory>
</VirtualHost>
Directory structure of the apache
conf/httpd.conf
logs/access.log(user hits and error.log(error info and restart apache)
*/gangi.html----------->DocumentRoot/gangi.html--->404
http status code
splunk---->
onpremises--->aws
conf
logs/access.log and error.log
/opt/website1----tail -f access.log
/opt/website2----ta
/opt/website3
DocuementRoot /opt/website1 /opt/website2
DirectoryIndex index.html login.html
=================================================
more
less
vi --- how to replace keyword
curl
tail -f
netstat -anlp | grep ":8080"
all
n=numeric
l=list
p=pid
awk
sed
================================================
bind error------------>socket(port) not binding
54.174.86.61
18.218.177.208
18.218.204.24
54.90.73.75 -
pinging multiple machines
#!/bin/bash
#purpose:ping test for many servers
#Version:1.0
source=/opt/automation/scripts/
servers=$source/serverslist
tempfile=$source/pingresult
for i in `cat $servers` ;
do
echo "===================================" >>$tempfile
echo "server name $i" >>$tempfile
ping -c 4 $i >>$tempfile
echo "===================================" >>$tempfile
done
=============================
server name 18.218.177.208
#!/bin/bash
#purpose:ping test for many servers
#Version:1.0
source=/opt/automation/scripts/
servers=$source/serverslist
tempfile=$source/pingresult
for i in `cat $servers` ;
do
echo "===================================" >>$tempfile
echo "server name $i" >>$tempfile
nc -v 4 $i >>$tempfile
echo "===================================" >>$tempfile
done
<Files ".ht*">-----------Each directory level permissions if want (.htaccess)---php
Require all denied----------->403
</Files>
/opt/test/--DR
DI--login.html
www.google.com---------------->/opt/test/login.html
www.google.com/admin/admin.html---403
/opt/test/admin/
.htaccess(Require all denied)
admin.html
ServerRoot---->/etc/httpd
ErrorLog "/opt/logs/httpd/my-error_log"
CustomLog "/opt/logs/httpd/my-access_log" common
LogFormat "%h ......"
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
%h--- client ip--host ip/
%l -- -
%u -- -
%t--- time
%r -- requst type (GET/POST)
%>s--- http status code( 20x,30x,40x,50x)
%b-- bytes of information transfer to the code
awk {print $1,$6} access.log | grep -w "500"---->ip
cut
source .bashrc---------------->Alias test
public ?
error.log ( stop /start/40x/50x)
===============================
Listen
DirectoryIndex
DocuementRoot
LogFormat
ErrorLog
CustomLog
Directory
ServerName
ServerAdmin
ln -s /etc/httpd /opt/apachehome(softlink and hardlink)
lrwxrwxrwx ---- /opt/apachehome------------>/etc/httpd
ServerRoot /opt/apachehome
===========================================
Client------------->apache----------->app se
What are the log level available in Apache?
The default configuration is set to “warn” however, the following is possible too.
debug
info
warn
notice
crit
alarm
emerg
error
Apache---- Nginx,OHS,IHS,JWS
https://geekflare.com/apache-interview-questions-answers/
LAB:-
/opt/logs/httpd/
30- times--refresh--200 count ?