Httpd的简单介绍html
web服务:nginx
其监听的端口http: 80/TCPweb
https: 443/TCPapache
http协议响应码:安全
1××:信息服务器
2××:常响应信息ide
3××:重定向ui
4××:客户端错误加密
5××:服务器端错误spa
web服务器软件:
apache
iis
lighttpd
nginx 对于静态请求
CGI:common gateway interface
同一个服务器上的进程,每次启动都要经过服务器的调用
module:当启用应用进程的时候是跑在web进程的里边
httpd -M 查看安装了哪些模块
NPM:Multipath Processing Module 多路(道)处理模块
prefork:每个请求用一个进程来响应
稳定性、安全性好
worker:每个请求用一个线程来响应(线程是进程的机制)
轻量级建立/销毁,资源消耗率低
主配置文件 /etc/httpd/conf/http.conf
里面所包含的信息介绍:
ServerTokens OS(显示操做系统信息)
它能够有如下几种方式:
ServerTokens Prod[uctOnly]
Server sends (e.g.): Server: Apache
ServerTokens Major
Server sends (e.g.): Server: Apache/2
ServerTokens Minor
Server sends (e.g.): Server: Apache/2.0
ServerTokens Min[imal]
Server sends (e.g.): Server: Apache/2.0.41
ServerTokens OS
Server sends (e.g.): Server: Apache/2.0.41 (Unix)
ServerTokens Full (or not specified)
Server sends (e.g.): Server: Apache/2.0.41 (Unix) PHP/4.2.2 MyMod/1.2
ServerRoot "/etc/httpd" 服务器起点的安装路径
PidFile run/httpd.pid pid文件的路径
KeepAlive Off 是否开启保持链接
MaxKeepAliveRequests 100
KeepAliveTimeout 15
Timeout 120
<IfModule prefork.c> 查看模块是否存在
StartServers 8 启动是启动几个进程
MinSpareServers 5 最少空闲进程数
MaxSpareServers 20 最多空闲进程数
ServerLimit 256 最大启动的进程数
MaxClients 256 最多多少个请求
MaxRequestsPerChild 4000 一个进程最多响应多少个请求
</IfModule>
Listen 80 监听的端口
ExtendedStatus On 是否开启扩展状态
DocumentRoot "/var/www/html" 网页文件的存放位置
Options Indexes FollowSymLinks
Indexes 容许索引,表示若是没有主页的则列出/var/www/html下的内容
FollowSymLinks 跟踪连接
SymLinksifOwnerMatch 容许用户跟踪连接
Order allow,deny 基于客户端来源的ACL,放在后面的默认最早的规则
deny from 后面能够跟IP地址 域名
AllowOverride AuthConfig
AuthName "feng" 认证名称
AuthType Basic 认证类型
AuthUserFile /etc/httpd/conf/.htpasswd 用户的认证文件位置
AuthGroupFile /etc/httpd/conf/.htgroup 只有列在这个组中的用户才能访问的文件
.htgroup文件中内容的格式是 组名:用户 用户
Require user gentoo 指定容许谁访问
Require valid-user 容许在.htpasswd文件中有密码的用户访问
Require group developers
#service httpd configtest 检查配置文件是否有语法错误
#httpd -t 检查配置文件是否有语法错误
#htpasswd -c 建立密码文件当文件不存在时才用
-m 采用md5加密
-D 删除某个用户
UserDir public_html 让用户本身的家目录可使用网页文件
先在本身的家目录里建立目录public_html,在目录中编写网页文件,在咱们访问的时候输入ip的后面加上/~用户名便可
DirectoryIndex 默认主页面
ErrorLog logs/error_log 错误日志,全路径是/etc/httpd/logs/error_log
LogLevel warn 定义日志级别 显示的都是超过此级别的信息
错误级别debug(调试级别), info(), notice(注意), warn(警告), error(错误), crit(蓝色预警),alert(×××预警), emerg(红色警惕)
日志格式:
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
%h 远端主机的IP地址 %l 表示登陆名称 %u 远程用户的用户名 %t 访问时间
%r 请求信息首部的第一行 %s 状态码 %b 响应信息的大小 %{Referer}i 访问当页面是从哪跳过来的 %{User-Agent}i 用户代理
CustomLog logs/access_log combined(使用的哪一种格式) 访问日志的格式
Alias /icons/ "/var/www/icons/" 定义别名,可让不在/var/www/html目录下的其余网页也能够访问
启用status 能够查看进程的详细信息
<Location /status>
SetHandler server-status
Order deny,allow
# Deny from all
# Allow from .example.com
</Location>
虚拟主机的创建:
一个物理主机上只有一个httpd,但能运行N个站点
虚拟主机的类型:
基于IP
基于端口
基于主机头FQDN
<VirtualHost 172.16.100.1:80>
DocumentRoot "/path/to/somewhere"
ServerName www.magedu.com
<Directory "/path/to/somewhere">
Options Indexes
AllowOverride none
Order allow,deny
Allow from 172.16
</Directory>
ErrorLog /var/log/httpd/www.magedu.com_error_log
CustomLog /var/log/httpd/www.magedu.com_access_log combined
ServerAdmin webmaster@magedu.com
alias
scriptalias
</VirtualHost>
要是开启虚拟主机要把#DocumentRoot "/var/www/html"这一项禁用了,
要是基于主机头就要把 NameVirtualHost *:80 这一项开启