httpd

httpd

1. httpd简介

httpd是Apache超文本传输协议(HTTP)服务器的主程序。被设计为一个独立运行的后台进程,它会建立一个处理请求的子进程或线程的池。

通常,httpd不应该被直接调用,而应该在类Unix系统中由apachectl调用,在Windows中作为服务运行。

2. httpd版本

本文主要介绍httpd的两大版本,httpd-2.2和httpd-2.4。

  • CentOS6系列的版本默认提供的是httpd-2.2版本的rpm包
  • CentOS7系列的版本默认提供的是httpd-2.4版本的rpm包

2.1 httpd的特性

httpd有很多特性,下面就分别来说说httpd-2.2版本和httpd-2.4版本各自的特性。

版本特性
2.2事先创建进程
按需维持适当的进程
模块化设计,核心比较小,各种功能通过模块添加(包括PHP),支持运行时配置,支持单独编译模块
支持多种方式的虚拟主机配置,如基于ip的虚拟主机,基于端口的虚拟主机,基于域名的虚拟主机等
支持https协议(通过mod_ssl模块实现)
支持用户认证
支持基于IP或域名的ACL访问控制机制
支持每目录的访问控制(用户访问默认主页时不需要提供用户名和密码,但是用户访问某特定目录时需要提供用户名和密码)
支持URL重写
支持MPM(Multi Path Modules,多处理模块)。用于定义httpd的工作模型(单进程、单进程多线程、多进程、多进程单线程、多进程多线程)
2.4httpd-2.4的新特性:
MPM支持运行DSO机制(Dynamic Share Object,模块的动态装/卸载机制),以模块形式按需加载
支持event MPM,eventMPM模块生产环境可用
支持异步读写
支持每个模块及每个目录分别使用各自的日志级别
每个请求相关的专业配置,使用来配置
增强版的表达式分析器
支持毫秒级的keepalive timeout
基于FQDN的虚拟主机不再需要NameVirtualHost指令
支持用户自定义变量
支持新的指令(AllowOverrideList)
降低对内存的消
工作模型工作方式
prefork多进程模型,预先生成进程,一个请求用一个进程响应
一个主进程负责生成n个子进程,子进程也称为工作进程
每个子进程处理一个用户请求,即使没有用户请求,也会预先生成多个空闲进程,随时等待请求到达,最大不会超过1024个
worker基于线程工作,一个请求用一个线程响应(启动多个进程,每个进程生成多个线程)
event基于事件的驱动,一个进程处理多个请求

2.2 httpd-2.4新增的模块

httpd-2.4在之前的版本基础上新增了几大模块,下面就几个常用的来介绍一下。

模块功能
mod_proxy_fcgi反向代理时支持apache服务器后端协议的模块
mod_ratelimit提供速率限制功能的模块
mod_remoteip基于ip的访问控制机制被改变,不再支持使用Order,Deny,Allow来做基于IP的访问控制

3. httpd基础

3.1 httpd自带的工具程序

工具功能
htpasswdbasic认证基于文件实现时,用到的帐号密码生成工具
apachectl httpd自带的服务控制脚本,支持start,stop,restart
apxs 由httpd-devel包提供的,扩展httpd使用第三方模块的工具
rotatelogs日志滚动工具
suexec访问某些有特殊权限配置的资源时,临时切换至指定用户运行的工具
abapache benchmark,httpd的压力测试工具

3.2 rpm包安装的httpd程序环境

文件/目录对应的功能
/var/log/httpd/access.log访问日志
/var/log/httpd/error_log错误日志
/var/www/html/站点文档目录
/usr/lib64/httpd/modules/模块文件路径
/etc/httpd/conf/httpd.conf主配置文件
/etc/httpd/conf.modules.d/*.conf模块配置文件
/etc/httpd/conf.d/*.conf辅助配置文件
mpm:以DSO机制提供,配置文件为/etc/httpd/conf.modules.d/00-mpm.conf

3.3 web相关的命令

3.3.1 curl命令

curl是基于URL语法在命令行方式下工作的文件传输工具,它支持FTP,FTPS,HTTP,HTTPS,GOPHER,TELNET,DICT,FILE及LDAP等协议。

curl支持以下功能:

  • https认证
  • http的POST/PUT等方法
  • ftp上传
  • kerberos认证
  • http上传
  • 代理服务器
  • cookies
  • 用户名/密码认证
  • 下载文件断点续传
  • socks5代理服务器
  • 通过http代理服务器上传文件到ftp服务器
//语法:curl [options] [URL ...]
//常用的options:
    -A/--user-agent <string>    //设置用户代理发送给服务器
    -basic              //使用Http基本认证
    --tcp-nodelay       //使用TCP_NODELAY选项
    -e/--referer <URL>      //来源网址
    --cacert <file>     //CA证书(SSL)
    --compressed        //要求返回时压缩的格式
    -H/--header <line>  //自定义请求首部信息传递给服务器
    -I/--head           //只显示响应报文首部信息
    --limit-rate <rate>     //设置传输速度
    -u/--user <user[:password]>     //设置服务器的用户和密码
    -0/--http1      //使用http 1.0版本,默认使用1.1版本。这个选项是数字0而不是字母o
    -o/--output     //把输出写到文件中
    -#/--progress-bar       //进度条显示当前的传送状态

//通过curl下载文件
[root@cl ~]# curl -o myblog.html http://blog.51cto.com/itchentao
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   312  100   312    0     0    475      0 --:--:-- --:--:-- --:--:--   475
3.3.2 httpd命令
//语法:httpd [options]
//常用的options:
    -l      //查看静态编译的模块,列出核心中编译了哪些模块。 \
            //它不会列出使用LoadModule指令动态加载的模块
    -M      //输出一个已经启用的模块列表,包括静态编译在服务 \
            //器中的模块和作为DSO动态加载的模块
    -v      //显示httpd的版本,然后退出
    -V      //显示httpd和apr/apr-util的版本和编译参数,然后退出
    -X      //以调试模式运行httpd。仅启动一个工作进程,并且 \
            //服务器不与控制台脱离
    -t      //检查配置文件是否有语法错误
[root@cl ~]# httpd -l
Compiled in modules:
  core.c
  mod_so.c
  http_core.c
[root@cl ~]# httpd -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe79:1a87. 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)
...
  proxy_wstunnel_module (shared)
 systemd_module (shared)
 cgid_module (shared)
 http2_module (shared)
 proxy_http2_module (shared)
[root@cl ~]# httpd -v
Server version: Apache/2.4.37 (centos)
Server built:   Nov 12 2021 04:57:27
[root@cl ~]# 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
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" 

4. 编译安装httpd-2.4

//安装开发环境
[root@cl ~]# yum groups mark install "Development Tools"
Last metadata expiration check: 0:11:13 ago on Thu 21 Jul 2022 08:49:46 PM CST.
Dependencies resolved.
===============================================================================
 Package           Architecture     Version            Repository         Size
===============================================================================
Installing Groups:
 Development Tools                                                            

Transaction Summary
===============================================================================

Is this ok [y/N]: y
Complete!
[root@cl ~]# useradd apache
[root@cl ~]# yum -y install openssl-devel pcre-devel expat-devel libtool
//下载并安装apr-1.4+和apr-util-1.4+
[root@cl ~]# cd /usr/local/
[root@cl local]# ls
apr-1.6.5.tar.gz bin games lib libexec share
apr-util-1.6.1.tar.gz etc include lib64 sbin src
[root@cl local]# tar -zxvf apr-1.6.5.tar.gz
[root@cl local]# tar -zxvf apr-util-1.6.1.tar.gz
[root@cl local]# ll
total 1604
drwxr-xr-x. 27 1001 1001 4096 Sep 11 2018 apr-1.6.5
-rw-r--r--. 1 root root 1073556 Jul 21 14:30 apr-1.6.5.tar.gz
drwxr-xr-x. 20 1001 1001 4096 Oct 18 2017 apr-util-1.6.1
-rw-r--r--. 1 root root 554301 Jul 21 14:30 apr-util-1.6.1.tar.gz
[root@cl local]# cd apr-1.6.5
[root@cl apr-1.6.5]# vim configure
cfgfile=${ofile}T
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
# $RM "$cfgfile" //将此行加上注释,或者删除此行
[root@cl apr-1.6.5]# ./configure --prefix=/usr/local/apr
[root@cl apr-1.6.5]# make && make install
[root@cl apr-1.6.5]# cd /usr/local/apr-util-1.6.1
[root@cl apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --wit
h-apr=/usr/local/apr
//编译安装httpd
[root@cl local]# ls
apr apr-util-1.6.1.tar.gz include share
apr-1.6.5 bin lib src
apr-1.6.5.tar.gz etc lib64
apr-util games libexec
apr-util-1.6.1 httpd-2.4.54.tar.gz sbin
[root@cl local]# tar -zxvf httpd-2.4.54.tar.gz
[root@cl httpd-2.4.54]# ./configure --prefix=/usr/local/apache --sysconf
dir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite -
-with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/loc
al/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=pr
efork
[root@cl httpd-2.4.54]# make && make instal

5. httpd常用配置

切换使用MPM(编辑/etc/httpd/conf.modules.d/00-mpm.conf文件):

//LoadModule mpm_NAME_module modules/mod_mpm_NAME.so
//NAME有三种,分别是:
    prefork
    event
    worker
[root@cl ~]# cd /etc/httpd/conf.modules.d/
[root@cl conf.modules.d]# pwd
/etc/httpd/conf.modules.d
[root@cl conf.modules.d]# ls
00-base.conf  00-mpm.conf       00-systemd.conf  10-proxy_h2.conf
00-dav.conf   00-optional.conf  01-cgi.conf      README
00-lua.conf   00-proxy.conf     10-h2.conf
[root@cl conf.modules.d]# vim 00-mpm.conf 

# Select the MPM module which should be used by uncommenting exactly
# one of the following LoadModule lines.  See the httpd.conf(5) man
# page for more information on changing the MPM.

# prefork MPM: Implements a non-threaded, pre-forking web server
# See: http://httpd.apache.org/docs/2.4/mod/prefork.html
#
# NOTE: If enabling prefork, the httpd_graceful_shutdown SELinux
# boolean should be enabled, to allow graceful stop/shutdown.
#
#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

# worker MPM: Multi-Processing Module implementing a hybrid
# multi-threaded multi-process web server
# See: http://httpd.apache.org/docs/2.4/mod/worker.html
#
#LoadModule mpm_worker_module modules/mod_mpm_worker.so

# event MPM: A variant of the worker MPM with the goal of consuming
# threads only for connections with active processing
# See: http://httpd.apache.org/docs/2.4/mod/event.html
#
LoadModule mpm_event_module modules/mod_mpm_event.so

访问控制法则:

法则功能
Require all granted允许所有主机访问
Require all deny拒绝所有主机访问
Require ip IPADDR授权指定来源地址的主机访问
Require not ip IPADDR拒绝指定来源地址的主机访问
Require host HOSTNAME授权指定来源主机名的主机访问
Require not host HOSTNAME拒绝指定来源主机名的主机访问
IPADDR的类型HOSTNAME的类型
IP:192.168.1.1
Network/mask:192.168.1.0/255.255.255.0
Network/Length:192.168.1.0/24
Net:192.168
FQDN:特定主机的全名
DOMAIN:指定域内的所有主机

注意:httpd-2.4版本默认是拒绝所有主机访问的,所以安装以后必须做显示授权访问

[root@cl ~]# cat /usr/local/apache2.4/htdocs/index.html 
<html><body><h1>chenlang</h1></body></html>
[root@cl html]# vim /etc/httpd/conf/httpd.conf
<Directory "/var/www/html">
<RequireAll>
Require all granted //允许所有主机访问
</RequireAll>
</Directory> 
[root@cl html]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.58.130. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@cl html]# curl http://192.168.58.130
chenlang

在这里插入图片描述

6.httpd配置三种虚拟主机访问控制和配置https安全加密模块

6.1httpd配置三种虚拟主机访问控制

虚拟主机:
虚拟主机有三类:

  • 相同IP不同端口
  • 不同IP相同端口
  • 相同IP相同端口不同域名

1.相同IP不同端口

//准备好html包
[root@cl ~]# cd /var/www/html/
[root@cl html]# ls
坦克.zip  斗地主.zip
//解压安装包
[root@cl html]# unzip 坦克.zip
[root@cl html]# unzip 斗地主.zip
[root@cl html]# ls
 Battle_City  'HTML5 canvas移动端斗地主小游戏'   坦克.zip   斗地主.zip
 [root@cl html]# rm -rf 坦克.zip 斗地主.zip 
[root@cl html]# ls
 Battle_City  'HTML5 canvas移动端斗地主小游戏'
[root@cl html]# mv Battle_City/ tanke
[root@cl html]# mv 'HTML5 canvas移动端斗地主小游戏'/ doudizhu
[root@cl html]# ls
doudizhu  tanke

//查找虚拟主机配置文件
[root@cl html]# find / -name *hosts.conf
/root/httpd-2.4.51/docs/conf/extra/httpd-vhosts.conf
/usr/share/doc/httpd/httpd-vhosts.conf
/usr/local/apache2.4/conf/extra/httpd-vhosts.conf
/usr/local/apache2.4/conf/original/extra/httpd-vhosts.conf
//复制其中的配置文件到/etc/httpd/conf.d/中
[root@cl ~]# cp /root/httpd-2.4.51/docs/conf/extra/httpd-vhosts.conf /etc/httpd/conf.d/
[root@cl ~]# cd /etc/httpd/conf.d/
[root@cl conf.d]# ls
autoindex.conf  httpd-vhosts.conf  README  userdir.conf  welcome.conf
//更改httpd-vhosts.conf中的配置
[root@cl conf.d]# vim httpd-vhosts.conf
<VirtualHost *:80>
    DocumentRoot "/var/www/html/doudizhu"
    ServerAlias www.doudizhu.com
    ErrorLog "/var/log/httpd/www.doudizhu.com-error_log"
    CustomLog "/var/log/httpd/www.doudizhu.com-access_log" common
</VirtualHost>

Listen 81  
<VirtualHost *:81>
    DocumentRoot "/var/www/html/tanke"
    ServerAlias www.tanke.com
    ErrorLog "/var/log/httpd/www.tanke.com-error_log"
    CustomLog "/var/log/httpd/www.tanke.com-access_log" common
</VirtualHost>
//重启服务
[root@cl conf.d]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe79:1a87%eth0. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@cl conf.d]# systemctl restart httpd
[root@cl conf.d]# ss -anlt
State   Recv-Q  Send-Q   Local Address:Port   Peer Address:Port  Process  
LISTEN  0       128            0.0.0.0:22          0.0.0.0:*              
LISTEN  0       128                  *:81                *:*              
LISTEN  0       128               [::]:22             [::]:*              
LISTEN  0       128                  *:80                *:*

//查看效果
在这里插入图片描述在这里插入图片描述

2.不同IP相同端口

//添加一个临时ip
[root@cl ~]# ip addr add 192.168.58.132/24 dev eth0
//修改配置文件
[root@cl ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf 
<VirtualHost 192.168.58.130:80>
    DocumentRoot "/var/www/html/doudizhu"
    ServerAlias www.doudizhu.com
    ErrorLog "/var/log/httpd/www.doudizhu.com-error_log"
    CustomLog "/var/log/httpd/www.doudizhu.com-access_log" common
</VirtualHost>

<VirtualHost 192.168.58.132:80>
    DocumentRoot "/var/www/html/tanke"
    ServerAlias www.tanke.com
    ErrorLog "/var/log/httpd/www.tanke.com-error_log"
    CustomLog "/var/log/httpd/www.tanke.com-access_log" common
</VirtualHost>
//重启服务
[root@cl ~]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe79:1a87%eth0. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@cl ~]# systemctl restart httpd

//效果展示
在这里插入图片描述
在这里插入图片描述

3.相同IP相同端口不同域名

//在本机C盘修改hosts文件
在C:\Windows\System32\drivers\etc\hosts文件中
添加192.168.58.130 www.doudizhu.com 
192.168.58.130 www.tanke.com 
[root@cl ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf
<VirtualHost 192.168.58.130:80>
    DocumentRoot "/var/www/html/doudizhu"
    ServerAlias www.doudizhu.com
    ErrorLog "/var/log/httpd/www.doudizhu.com-error_log"
    CustomLog "/var/log/httpd/www.doudizhu.com-access_log" common
</VirtualHost>

<VirtualHost 192.168.58.130:80>
    DocumentRoot "/var/www/html/tanke"
    ServerAlias www.tanke.com
    ErrorLog "/var/log/httpd/www.tanke.com-error_log"
    CustomLog "/var/log/httpd/www.tanke.com-access_log" common
</VirtualHost>
//重启服务
[root@cl ~]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe79:1a87%eth0. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@cl ~]# systemctl restart httpd

//效果展示
在这里插入图片描述
在这里插入图片描述

6.2配置https安全加密模块

httpds

HTTPS - Hyper Text Transfer Protocol over SecureSocket Layer,是以安全为目标的HTTP通道,在HTTP的基础上通过传输加密和身份认证保证了传输过程的安全性;HTTPS在HTTP的基础下加入SSL层,HTTPS的安全基础是SSL,因此加密的详细内容就需要SSL;HTTPS存在不同于HTTP的默认端口及一个加密/身份验证层(在HTTP与TCP之间)这个系统提供了身份验证与加密通讯方法,它被广泛用于万维网上安全敏感的通讯;服务端口为443

mod_ssl模块:
这个模块提供了使用安全套接字层 (SSL v2/v3)和传输层安全 (TLS v1)协议实现高强度加密传输的功能。 它由mod_ssl项目的作者Ralf S. Engeschall贡献,而mod_ssl最早是基于Ben Laurie的工作开发的。

openssl实现私有CA
//下载ssl启用模块和openssl对称
[root@cl ~]# yum -y install mod_ssl openssl
[root@cl ~]# systemctl restart httpd 
[root@cl ~]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe79:1a87%eth0. Set the 'ServerName' directive globally to suppress this message
Syntax OK
使用openssl实现私有CA:
CA的配置文件:/etc/pki/tls/openssl.cnf
1.CA生成一对密钥
[root@cl ~]# mkdir /etc/pki/CA
[root@cl ~]# cd /etc/pki/CA
[root@cl CA]# mkdir private
[root@cl CA]# (umask 077;openssl genrsa -out private/cakey.pem 2048)
Generating RSA private key, 2048 bit long modulus (2 primes)
................................................................................+++++
......+++++
e is 65537 (0x010001)
[root@cl CA]# openssl rsa -in private/cakey.pem -pubout
writing RSA key
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArTHnl8fonE1bjhTc/8vO
V1UhHlVx7U1GfGH/YplAuYsXQThM2QE/DFOMumIV3mhkEw9bYunQHypLTdKZyIXk
9PJDld+BwPi4XhegT5wCHIkHbXXQ9n9T55CQ55t/KUJxH7GtLuDrqrNlwfiKahV5
T8zSTnOaY1ycW7CQq7IBfmXe4hTXt7apLm+E4swVR8amHslfgQjYOM8N2hrmo2/n
oYHH5oFED0Nr1Jb2peHgq2ze5s5LD4pKcie2npOmKVssHy9dr9G1kMzox1tyfENk
B5SLdCz71vyXi83kPZMJYwWwQB77Mzx9XwvuTwGgEK2ikqWxQNslzZe+tIYXqdEF
KQIDAQAB
-----END PUBLIC KEY-----
2.CA生成自签署证书
[root@cl CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 365
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:cn    //国家
State or Province Name (full name) []:hb  //省份
Locality Name (eg, city) [Default City]:wh  //城市
Organization Name (eg, company) [Default CompanyLtd]:cl   //公司
Organizational Unit Name (eg, section) []:xs    //职位
Common Name (eg, your name or your server's hostname) []:www.doudizhu.com //域名 
[root@cl CA]# mkdir certs newcerts crl
[root@cl CA]# touch index.txt && echo 01 > serial

3.客户端(例如httpd服务器)生成密钥
[root@cl CA]# cd /etc/httpd && mkdir ssl && cd ssl
[root@cl ssl]# (umask 077;openssl genrsa -out httpd.key 2048)
Generating RSA private key, 2048 bit long modulus (2 primes)
..+++++
.............................................................+++++
e is 65537 (0x010001)

4.客户端生成证书签署请求
[root@cl ssl]# openssl req -new -key httpd.key -days 365 -out httpd.csr
Ignoring -days; not generating a certificate
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:cn
State or Province Name (full name) []:hb
Locality Name (eg, city) [Default City]:wh
Organization Name (eg, company) [Default Company Ltd]:cl
Organizational Unit Name (eg, section) []:xs
Common Name (eg, your name or your server's hostname) []:www.doudizhu.com
Email Address []:3042277527@qq.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:1
string is too short, it needs to be at least 4 bytes long
A challenge password []:chen
An optional company name []:chen

5.CA签署客户端提交上来的证书
[root@cl ssl]# openssl ca -in ./httpd.csr -out httpd.crt -days 365
Certificate is to be certified until Jul 24 08:13:41 2023 GMT (365 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
[root@cl ssl]# ls
httpd.crt  httpd.csr  httpd.key
httpd-ssl.conf的配置
[root@cl ssl]# cd /etc/httpd/conf.d/
[root@cl conf.d]# vim ssl.conf
//注释取消,修改指定路径和指定域名
DocumentRoot "/var/www/html/doudizhu"
ServerName www.doudizhu.com:443
//在httpd-ssl.conf中修改证书的位置
SSLCertificateFile /etc/httpd/ssl/httpd.crt
SSLCertificateKeyFile /etc/httpd/ssl/httpd.key
[root@cl conf.d]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe79:1a87%eth0. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@cl conf.d]# systemctl restart httpd
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值