天天看点

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