1.事先创建进程,并且适量维持适量的进程
2.模块较小,核心较小,各种功能通过模块添加或者运行时也可配置
3.支持单独编译模块,使用时添加
4.支持多种虚拟主机配置(一个主机部署多个网站)如ip,端口和域名
5.支持https协议(证书加密)
6.用户认证
7.限制所有的ip和域名访问
8.目录的访问控制,用户访问某特定目录时需要提供用户名和密码,访问默认不需要
9.支持URL重写
10.多处理模块
1.支持动态共享对象模块的装/卸载机制(装载,功能启用,卸载功能关闭)
2.支持事件驱动(event mpm),电脑点一个文件,CPU很快会反映过来
3.异步读写(io)(做一件事没做完等待的时间去做别的事情)能提升效率
4.支持每个模块及每个目录分别使用各自的日志级别
5.每个请求相关的专业配置,使用来配置
6.增强版的表达式分析器
7.降低对内存的消耗
8.keepalive timeout(长连接做完一整件事,连接超时)
9.FQDN(完全限定域名)
[root@SYL3 ~]# hostnamectl set-hostname SYL3.example.com
[root@SYL3 ~]# bash
[root@SYL3 ~]# hostname
SYL3.example.com //完全限定域名
[root@SYL3 ~]# syl3主机名
10.支持用户自定义变量
11.支持新的指令(AllowOverrideList)
单进程、单进程多线程、多进程、多进程单线程、多进程多线程
线程包含在进程中,一个进程中可以并发多个线程
模型
prefork — 多进程模型
worker
event
1.htpasswd
功能:basic认证生成工具
2.apachectl
功能:源码装自带服务器控制脚本,支持启动(start),停止(stop),重启(restart)
3.apxs
功能:扩展httpd使用第三方模块的工具,由httpd-devel提供
4.rotatelogs
日志滚动工具
5.suexec
临时切换至指定用户运行的工具
6.ab
httpd的压力测试工具,模拟多少用户来访问
[root@SYL3 ~]# which htpasswd
/usr/bin/htpasswd
[root@SYL3 ~]# which apachectl
/usr/sbin/apachectl
[root@SYL3 ~]# which apxs
/usr/bin/which: no apxs in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[root@SYL3 ~]# which rotatelogs
/usr/sbin/rotatelogs
[root@SYL3 ~]# which suexec
/usr/sbin/suexec
[root@SYL3 ~]# which ab
/usr/bin/ab
[root@SYL3 ~]# which apxs
/usr/bin/apxs
[root@SYL3 ~]#
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-G6JEW5Sh-1657286989402)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220414171138029.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-BsfVyGAz-1657286989403)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220414180435663.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-sJ6R8HAe-1657286989403)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220414171554490.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-VP4L8HD7-1657286989403)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220414171634420.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-SajtBT2s-1657286989404)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220414202453094.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2X03RHFT-1657286989404)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220414202406705.png)]
安装httpd
[root@SYL3 ~]# yum -y install httpd
Failed to set locale, defaulting to C.UTF-8
Updating Subscription Management repositories.
Unable to read consumer identity
[root@SYL3 httpd]# ls
[root@SYL3 httpd]# systemctl disable --now firewalld //关闭防火墙
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@SYL3 httpd]# setenforce 0 关闭selinux防火墙
[root@SYL3 httpd]# systemctl enable --now httpd 开机自启apache
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@SYL3 httpd]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; e>
Active: active (running) since Thu 2022-04-14 20:37:25 C>
Docs: man:httpd.service(8)
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Ao8VDKOr-1657286989405)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220414204049459.png)]
[root@SYL3 ~]# ls
abc anaconda-ks.cfg htmlxunakuhei htmlxunakuhei.zip
[root@SYL3 ~]# cd htmlxunakuhei
[root@SYL3 htmlxunakuhei]# ls
'#U670d#U52a1#U5668#U4e4b#U5bb6.url'
'#U7cbe#U54c1#U514d#U8d39#U5546#U4e1a#U6e90#U7801#U4e0b#U8f7d.url'
css
fonts
images
index.html
js
m
[root@SYL3 htmlxunakuhei]# cp -r * /var/www/html/ //复制到httpd中
[root@SYL3 htmlxunakuhei]#
[root@SYL3 httpd]# ls /var/www/html/
'#U670d#U52a1#U5668#U4e4b#U5bb6.url'
'#U7cbe#U54c1#U514d#U8d39#U5546#U4e1a#U6e90#U7801#U4e0b#U8f7d.url'
css
fonts
images
index.html
js
m
[root@SYL3 httpd]#
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Z9k0WmhU-1657286989406)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20220414205537985.png)]
访问日志,错误日志
[root@SYL3 ~]# ls /var/log/httpd/
access_log //访问日志
error_log //错误日志
[root@SYL3 ~]#
站点文档目录
[root@SYL3 ~]# ls /var/www/html/
'#U670d#U52a1#U5668#U4e4b#U5bb6.url'
'#U7cbe#U54c1#U514d#U8d39#U5546#U4e1a#U6e90#U7801#U4e0b#U8f7d.url'
css
fonts
images
index.html
js
m
[root@SYL3 ~]#
模块文件路径
[root@SYL3 ~]# ls /usr/lib64/httpd/
modules
[root@SYL3 ~]#
主配置文件
[root@SYL3 ~]# cd /etc/httpd/conf
[root@SYL3 conf]# ls
httpd.conf //主配置文件
magic
模块配置文件
[root@SYL3 ~]# ls /etc/httpd/conf.modules.d/
//这个目录下咦.conf文件
00-base.conf 00-optional.conf 10-h2.conf
00-dav.conf 00-proxy.conf 10-proxy_h2.conf
00-lua.conf 00-systemd.conf README
00-mpm.conf 01-cgi.conf
[root@SYL3 ~]#
辅助配置文件
[root@SYL3 ~]# ls /etc/httpd/conf.d/
//以.conf文件结尾的文件是辅助配置文件
README autoindex.conf userdir.conf welcome.conf
[root@SYL3 ~]#
mpm:配置动态共享对象文件
[root@SYL3 ~]# ls /etc/httpd/conf.modules.d/
00-mpm.conf
[root@SYL3 ~]# vim /etc/httpd/conf.modules.d/00-mpm.conf //配置工作模式
#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
#LoadModule mpm_worker_module modules/mod_mpm_worker.so
LoadModule mpm_event_module modules/mod_mpm_event.so
//默认用的是事件驱动,三种模式只能用一个
curl是基于URL语法在命令行方式下工作的文件传输工具,它支持FTP,FTPS,HTTP,HTTPS,GOPHER,TELNET,DICT,FILE及LDAP等协议。
curl支持以下功能:
访问网站
[root@SYL3 ~]# curl http://192.168.232.128
<!DOCTYPE html>
<!--
⣿⣿⣿⣿⣿⣿⣧⢸⡿⣟⣿⡇⢸⣯⣟⣮⢧⡈⢿⣞⡿⣦⠘⠏⣹⣿⣽⢿⣿⣿⣿⣿⣯⣿⣿⣿⡇⢸⣿⣿⣾⡆⠹⢀⣠⣾⣟⣷⡈⢿
⣿⣿⣿⣿⣿⣿⣿⡈⣿⢿⣽⡇⠘⠛⠛⠛⠓⠓⠈⠛⠛⠟⠇⢀⢿⣻⣿⣯⢿⣿⣿⣿⣷⢿⣿⣿⠁⣾⣿⣿⣿⣧⡄⠇⣹⣿⣾⣯⣿⡄
⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⡽⡇⢸⣿⣿⣿⣿⣿⣞⣆⠰⣶⣶⡄⢀⢻⡿⣯⣿⡽⣿⣿⣿⢯⣟⡿⢀⣿⣿⣿⣿⣿⣧⠐⣸⣿⣿⣷⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⠘⣯⡿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣧⡈⢿⣳⠘⡄⠻⣿⢾⣽⣟⡿⣿⢯⣿⡇⢸⣿⣿⣿⣿⣿⣿⡀⢾⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⠇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠻⡇⢹⣆⠹⣟⣾⣽⣻⣟⣿⣽⠁⣾⣿⣿⣿⣿⣿⣿⣇⣿⣿⠿⠛⠛⠉
⣿⣿⣿⣿⣿⣿⣿⣿⣿⡈⣿⡃⢼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡙⠌⣿⣆⠘⣿⣞⡿⣞⡿⡞⢠⣿⣿⣿⣿⣿⡿⠛⠉⠁⢀⣀⣠⣤⣤
⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠘⠁⠉⠉⠉⠉⠉⠉⠉⠉⠉⠙⠛⠛⢿⣄⢻⣿⣧⠘⢯⣟⡿⣽⠁⣾⣿⣿⣿⣿⣿⡃⢀⢀⠘⠛⠿⢿⣻⣟
⣿⣿⣿⣟⣿⣿⣿⣿⣶⣶⡆⢀⣿⣾⣿⣾⣷⣿⣶⠿⠚⠉⢀⢀⣤⣿⣷⣿⣿⣷⡈⢿⣻⢃⣼⣿⣿⣿⣿⣻⣿⣿⣿⡶⣦⣤⣄⣀⡀⠉
⣿⢿⣿⣿⣻⣿⣿⣿⣿⣿⡿⠐⣿⣿⣿⣿⠿⠋⠁⢀⢀⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣌⣥⣾⡿⣿⣿⣷⣿⣿⢿⣷⣿⣿⣟⣾⣽⣳⢯⣟
⣿⣻⣿⣿⡷⣿⣿⣿⣿⣿⡗⣦⠸⡿⠋⠁⢀⢀⣠⣴⢿⣿⣽⣻⢽⣾⣟⣷⣿⣟
⡄⢿⣿⣷⢀⠹⣟⣆⠻⣿⣿⣆⢀⣀⠉⠻⣿⡽⣯⣿⣿⣷⣈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⢀⣠
Time: 2021-11-3 原创:庞金明
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Anle 一款酷黑风个人引导页</title>
<!--页面核心样式-->
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<!--页面核心JS-->
<script type="text/javascript" src="js/uaredirect.js"></script>
<script type="text/javascript">browserRedirect("/m");</script>
<script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="js/respond.min.js"></script>
</head>
<body>
<div class="container slideTxtBox">
<div class="header flex flex-pack-justify flex-align-center">
<div class="user-info flex flex-align-center">
<div class="portrait"><img src="https://www.678cnn.com/content/uploadfile/tpl_options//logopic.png" ></div>
<div class="name PangMenZhengDao">zzvips</div><!--左上角 Logo+站名-->
</div>
<div class="link te_c p_r hd">
<ul class="flex flex-align-center">
<li class="p_r"><a href="javascript:void(0);" class="transition OPPOSans-R di_bl">关于我</a></li>
<li class="p_r"><a href="javascript:void(0);" class="transition OPPOSans-R di_bl">朋友们</a></li>
</ul>
<div class="move-bg"></div><!--右上方 部件-->
</div>
</div>
<!--页面内容-->
<div class="bd">
<!--左侧小部件-MacBook Air-->
<div class="content p_r">
<div class="en_box flex flex-align-center flex-pack-center">
<div class="macbook">
<div class="inner">
<div class="screen">
<div class="face-one">
<div class="camera"></div>
<div class="display">
<div class="shade"></div>
</div>
</div>
<img src="http://www.clker.com/cliparts/i/s/H/f/4/T/apple-logo-white.svg" class="logo">
</div>
<div class="body">
<div class="face-one">
<div class="touchpad">
</div>
<!--居中内容-->
<div class="r_content">
<div class="con p_r flex">
<!--你的名字-->
<div class="name flex flex-align-center flex-pack-center OPPOSans-M p_r" id="one_part">
zzvips
<div class="tips te_c OPPOSans-B transition"><span class="p_r c1">455px</span></div>
</div>
<!--小部件-GIF-->
<div class="flex flex-align-center flex-pack-center iphone"><img src="images/icon_APP.gif"></div>
<div class="flex flex-align-center flex-pack-center web"><img src="images/icon_WEB.gif"></div>
<div class="flex flex-align-center flex-pack-center vr"><img src="images/icon_VR.gif"></div>
</div>
[root@SYL3 html]# curl -o index.html https://www.baidu.com
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--100 2443 100 2443 0 0 3571 0 --:--:-- --:--:-- --:--:-- 3571
[root@SYL3 html]# ls
index.html
[root@SYL3 html]#
-l 查看静态编译的模块
-M 输出一个已经启用的模块列表,包括静态编译在服务器中的模块和作为DSO动态加载的模块
-v 显示httpd的版本,然后退出
-V 显示httpd和apr/apr-util的版本和编译参数,然后退出
-X 以调试模式运行httpd。仅启动一个工作进程,并且 服务器不与控制台脱离
-t 检查配置文件是否有语法错误
-l 查看静态编译的模块
[root@SYL3 ~]# httpd -l
Compiled in modules:
core.c
mod_so.c
http_core.c
-M 输出一个已经启用的模块列表,包括静态编译在服务器中的模块和作为DSO动态加载的模块
[root@SYL3 ~]# httpd -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe88:169d. Set the 'ServerName' directive globally to suppress this message
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
access_compat_module (shared)
actions_module (shared)
alias_module (shared)
allowmethods_module (shared)
auth_basic_module (shared)
auth_digest_module (shared)
authn_anon_module (shared)
authn_core_module (shared)
authn_dbd_module (shared)
authn_dbm_module (shared)
authn_file_module (shared)
authn_socache_module (shared)
authz_core_module (shared)
authz_dbd_module (shared)
authz_dbm_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_owner_module (shared)
authz_user_module (shared)
autoindex_module (shared)
brotli_module (shared)
cache_module (shared)
cache_disk_module (shared)
cache_socache_module (shared)
data_module (shared)
dbd_module (shared)
deflate_module (shared)
dir_module (shared)
dumpio_module (shared)
echo_module (shared)
env_module (shared)
expires_module (shared)
ext_filter_module (shared)
filter_module (shared)
headers_module (shared)
include_module (shared)
info_module (shared)
log_config_module (shared)
logio_module (shared)
macro_module (shared)
mime_magic_module (shared)
mime_module (shared)
negotiation_module (shared)
remoteip_module (shared)
reqtimeout_module (shared)
request_module (shared)
rewrite_module (shared)
setenvif_module (shared)
slotmem_plain_module (shared)
slotmem_shm_module (shared)
socache_dbm_module (shared)
socache_memcache_module (shared)
socache_shmcb_module (shared)
status_module (shared)
substitute_module (shared)
suexec_module (shared)
unique_id_module (shared)
unixd_module (shared)
userdir_module (shared)
version_module (shared)
vhost_alias_module (shared)
watchdog_module (shared)
dav_module (shared)
dav_fs_module (shared)
dav_lock_module (shared)
lua_module (shared)
mpm_event_module (shared)
proxy_module (shared)
lbmethod_bybusyness_module (shared)
lbmethod_byrequests_module (shared)
lbmethod_bytraffic_module (shared)
lbmethod_heartbeat_module (shared)
proxy_ajp_module (shared)
proxy_balancer_module (shared)
proxy_connect_module (shared)
proxy_express_module (shared)
proxy_fcgi_module (shared)
proxy_fdpass_module (shared)
proxy_ftp_module (shared)
proxy_http_module (shared)
proxy_hcheck_module (shared)
proxy_scgi_module (shared)
proxy_uwsgi_module (shared)
proxy_wstunnel_module (shared)
systemd_module (shared)
cgid_module (shared)
http2_module (shared)
proxy_http2_module (shared)
[root@SYL3 ~]#
[root@SYL3 ~]# httpd -v
Server version: Apache/2.4.37 (centos)
Server built: Nov 12 2021 04:57:27
[root@SYL3 ~]#
[root@SYL3 ~]# httpd -V
Server version: Apache/2.4.37 (centos)
Server built: Nov 12 2021 04:57:27
Server's Module Magic Number: 20120211:83
Server loaded: APR 1.6.3, APR-UTIL 1.6.1
Compiled using: APR 1.6.3, APR-UTIL 1.6.1
Architecture: 64-bit //结构 64位
Server MPM: event //模型
threaded: yes (fixed thread count)//混合线程
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
[root@SYL3 ~]#
root@SYL3 ~]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe88:169d. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@SYL3 ~]# httpd -t
AH00526: Syntax error on line 34 of /etc/httpd/conf/httpd.conf:
Invalid command '11111erverRoot', perhaps misspelled or defined by a module not included in the server configuration
pache_runtime_status"
-D DEFAULT_ERRORLOG=“logs/error_log”
-D AP_TYPES_CONFIG_FILE=“conf/mime.types”
-D SERVER_CONFIG_FILE=“conf/httpd.conf”
[root@SYL3 ~]#
- 检查配置文件是否有语法错误 -t
```basic
root@SYL3 ~]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe88:169d. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@SYL3 ~]# httpd -t
AH00526: Syntax error on line 34 of /etc/httpd/conf/httpd.conf:
Invalid command '11111erverRoot', perhaps misspelled or defined by a module not included in the server configuration