天天看點

httpd

跨internet的主機間通訊:

 在建立通信連接配接的每一端,程序間的傳輸要有兩個标志:

 ip位址和端口号,合稱為套接字位址 socket add 标記唯一的應用程式;

 客戶機套接字位址定義了一個唯一的客戶程序

 伺服器套接字位址定義了一個唯一的伺服器

httpd
httpd

socket:套接字,程序間通信ipc的一種實作,允許位于不同主機(或同一主機)上不同程序之間進行通信和資料交換

httpd
httpd
httpd
httpd
httpd
httpd
httpd

[root@named ~]# locate *.jpg

httpd
httpd
httpd
httpd
httpd

靜态檔案:無需服務端做出額外處理檔案字尾:.jpg, .html, .txt, .js, .css, .mp3, .avi

動态檔案:服務端執行程式,傳回執行的結果檔案字尾:.asp, .php, .jsp

httpd

持久連接配接:

keepalived

telnet node02 80

get /index.html http/1.1

host: 3.3.3.3

httpd
httpd

frag :apache docment文檔

httpd
httpd
httpd
httpd
httpd
httpd
httpd

pv:統計

[root@node02 ~]# cat /var/log/httpd/access_log |wc -l

108

httpd
httpd
httpd
httpd
httpd
httpd
httpd
httpd
httpd
httpd
httpd
httpd
httpd
httpd
httpd

https://httpd.apache.org/docs/2.4/mod/quickreference.html

httpd
httpd
httpd
httpd

2、修改監聽的ip和port

listen 0 128 :::80 :::*

httpd

[root@node02 conf.d]# cat test.conf

servertokens prod

keepalivetimeout 50

keepalivetimeout 15

4、mpm(multi-processing module)多路處理子產品

prefork, worker, event(試驗階段)

httpd-2.2不支援同時編譯多個子產品,是以隻能編譯時標明一個;rpm安裝的包提供三個二進制程式檔案,分别用于實作對不同mpm機制的支援

确認方法:psaux | grep httpd

預設為/usr/sbin/httpd, 即prefork模式

[root@node02 conf.modules.d]# ab -c 100 -n 2000 http://node02/

[root@node02 conf.modules.d]#

loadmodule mpm_event_module modules/mod_mpm_event.so

測試結果:

httpd
httpd
httpd

[root@node02 conf.modules.d]# ls

00-base.conf 00-lua.conf 00-proxy.conf 01-cgi.conf

00-dav.conf 00-mpm.conf 00-systemd.conf 10-php.conf

[root@node02 conf.modules.d]# grep basic *

00-base.conf:loadmodule auth_basic_module modules/mod_auth_basic.so

httpd

[root@node02 conf.modules.d]# httpd -l

compiled in modules:

core.c

mod_so.c

http_core.c

6、定義'main' server的文檔頁面路徑

documentroot “/path”

文檔路徑映射:documentroot指向的路徑為url路徑的起始位置

示例:

documentroot"/app/data“

http://host:port/test/index.html --> /app/data/test/index.html

[root@node02 data]# curl node02/

happy new year

7、定義站點首頁面

directoryindex index.html index.html.var

主站點: mkdir /data/website  >> news

mkdir /app/football >> ln -s /app/footbal sports >> sports 指向 軟連結

curl node02/news >> /data/website/news/index.html

curl node02/sports >> /app/football/index.html

8權限拒絕:

httpd

curl node02/php.conf

httpd
httpd

```[root@node02 conf.d]# pwd

/etc/httpd/conf.d

vim /etc/httpd/conf.d

<location "/conf">

<requireall>

require all granted

require not ip 192.168.100.10

</requireall>

</location>

documentroot "/app/data"

<directory /web/docs>

options +indexes -followsymlinks

</directory>

loglevel warn

<ifmodule log_config_module>

logformat "%h %l %u %t \"%r\" %>s %b \"%{referer}i\" \"%{user-agent}i\"" combined   #預設

logformat "%h %l %u %t \"%r\" %>s %b" common

</ifmodule>

[root@node02 html]# cat index.html

<title>京東(jd.com)-正品低價、品質保障、配送及時、輕松購物!</title>

welcome to magdu

<html>

<head>

<title>html語言

</title>

</head>

<body>

<img src="sunflower.jpg" >

<img src="https://img10.360buyimg.com/img/jfs/t1/159353/17/2928/457625/5ffd107fe2b4a7a10/e0ab266497850f64.gif" >

标題1

<p><a rel="nofollow" href=http://node02/test2.html>馬哥教育</a>歡迎你</p>;

</body>

</html>

[root@node02 html]# cat test2.html

test2

<location /status>

sethandler server-status

require all granted  ##reauire ip 192.168.137.6

[root@node02 ~]# cat /etc/httpd/conf.d/test.conf

listen 8001

listen 8002

listen 8003

<virtualhost *:8001>

documentroot /data/web1

servername www.a.com

<directory /data/web1>

</virtualhost>

<virtualhost *:8002>

documentroot /data/web2

<directory /data/web2>

<virtualhost *:8003>

documentroot /data/web3

<directory /data/web3>

<virtualhost 192.168.100.30:80>

<virtualhost 192.168.100.40:80>

<virtualhost 192.168.100.50:80>

[root@node02 ~]# cat /etc/httpd/conf.d/test.conf

logformat "%h %l %u %{%y-%m-%d %h:%m:%s}t \"%r\" %>s %b \"%{referer}i\" \"%{user-agent}i\"" testlog

customlog "logs/access_log" testlog

<virtualhost *:80>

customlog "logs/a_access_log" testlog

errorlog "logs/a_error_log"

<virtualhost *:80>

servername www.b.com

customlog "logs/b_access_log" testlog

errorlog "logs/b_error_log"

servername www.c.com

customlog "logs/c_access_log" testlog

errorlog "logs/c_error_log"

curl -i -x options www.a.com

[root@centos6 ~]#curl -i www.360buy.com

http/1.1 301 moved permanently

302: 響應封包location指明資源臨時新位置 moved temporarily

[root@centos6 ~]#curl -i www.jd.com

http/1.1 302 moved temporarily

httpd

curl -a "ie" http://192.168.137.47 代理伺服器:

192.168.137.6 - - [09/aug/2018:20:09:45 +0800] "get / http/1.1" 200 31 "-" "ie"

curl -a "ie20" -e "http://www.baidu.com" http://192.168.137.47 網址的來源url

192.168.137.6 - - [09/aug/2018:20:15:44 +0800] "get / http/1.1" 200 31 "http://www.baidu.com" "ie20"

curl -h “host":www.a.com www.a.com /data/web2 主機頭:

curl -i -v www.a.com

curl -v -h "host: www.c.com" www.a.com 主機頭:通過主機頭判斷通路的是哪個網站

--basic使用http 基本認證:

c

curl -l www.jd.com 顯示網站資訊

curl -0 www.a.com 顯示版本1.0

curl -v www.a.coom

curl -c cookie.log 192.168.137.47/setcookie.php下載下傳cookie

cat cookie.log

curl -i -x options 192.168.137.47 想代理伺服器發送指定請求方法;

links 192.168.137.47

links 192.168.47 -dump 文字

links 192.168.137.47 -source 看源碼

country name (2 letter code) [xx]:cn

state or province name (full name) []:beijing

locality name (eg, city) [default city]:beijing

organization name (eg, company) [default company ltd]:magedu.com

organizational unit name (eg, section) []:opt

common name (eg, your name or your server's hostname) []:ca.magedu.com

organization name (eg, company) [default company ltd]magedu.com

common name (eg, your name or your server's hostname) []:www.magedu.com

email address []:

header always set strict-transport-security "max-age=31536000"

rewriteengine on

rewriterule ^(/.*)$ https://%{http_host}$1 [redirect=302]

上一篇: httpd
下一篇: HTTPD