【httpd】

#httpd

文章目录


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

//LoadModule mpm_NAME_module modules/mod_mpm_NAME.so
//NAME有三种,分别是:
prefork
event
worker

    [root@localhost ~]# yum -y install httpd
Last metadata expiration check: 2:46:59 ago on Thu 21 Jul 2022 07:17:10 AM EDT.
Dependencies resolved.
=======================================================================================
 Package            Arch   Version                                     Repo       Size
=======================================================================================
Installing:
 httpd              x86_64 2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1    appstream 1.4 M
Installing dependencies:
 apr                x86_64 1.6.3-12.el8                                appstream 129 k
 apr-util           x86_64 1.6.1-6.el8                                 appstream 105 k
 centos-logos-httpd noarch 85.8-2.el8                                  appstream  75 k
 httpd-filesystem   noarch 2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1    appstream  41 k
 httpd-tools        x86_64 2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1    appstream 108 k
 mod_http2          x86_64 1.15.7-5.module_el8.6.0+1111+ce6f4ceb       appstream 155 k
Installing weak dependencies:
 apr-util-bdb       x86_64 1.6.1-6.el8                                 appstream  25 k
 apr-util-openssl   x86_64 1.6.1-6.el8                                 appstream  27 k
Enabling module streams:
 httpd                     2.4                                                        

Transaction Summary
=======================================================================================
Install  9 Packages

Total download size: 2.1 M
Installed size: 5.6 M
Downloading Packages:
(1/9): apr-1.6.3-12.el8.x86_64.rpm                     370 kB/s | 129 kB     00:00    
(2/9): apr-util-1.6.1-6.el8.x86_64.rpm                 172 kB/s | 105 kB     00:00    
(3/9): apr-util-openssl-1.6.1-6.el8.x86_64.rpm          82 kB/s |  27 kB     00:00    
(4/9): centos-logos-httpd-85.8-2.el8.noarch.rpm        240 kB/s |  75 kB     00:00    
(5/9): httpd-filesystem-2.4.37-47.module_el8.6.0+1111+ 516 kB/s |  41 kB     00:00    
(6/9): httpd-tools-2.4.37-47.module_el8.6.0+1111+ce6f4 1.0 MB/s | 108 kB     00:00    
(7/9): mod_http2-1.15.7-5.module_el8.6.0+1111+ce6f4ceb 1.3 MB/s | 155 kB     00:00    
(8/9): apr-util-bdb-1.6.1-6.el8.x86_64.rpm             9.4 kB/s |  25 kB     00:02    
(9/9): httpd-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1. 642 kB/s | 1.4 MB     00:02    
---------------------------------------------------------------------------------------
Total                                                  442 kB/s | 2.1 MB     00:04     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                               1/1 
  Installing       : apr-1.6.3-12.el8.x86_64                                       1/9 
  Running scriptlet: apr-1.6.3-12.el8.x86_64                                       1/9 
  Installing       : apr-util-bdb-1.6.1-6.el8.x86_64                               2/9 
  Installing       : apr-util-openssl-1.6.1-6.el8.x86_64                           3/9 
  Installing       : apr-util-1.6.1-6.el8.x86_64                                   4/9 
  Running scriptlet: apr-util-1.6.1-6.el8.x86_64                                   4/9 
  Installing       : httpd-tools-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64   5/9 
  Running scriptlet: httpd-filesystem-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.n   6/9 
  Installing       : httpd-filesystem-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.n   6/9 
  Installing       : centos-logos-httpd-85.8-2.el8.noarch                          7/9 
  Installing       : mod_http2-1.15.7-5.module_el8.6.0+1111+ce6f4ceb.x86_64        8/9 
  Installing       : httpd-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64         9/9 
  Running scriptlet: httpd-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64         9/9 
  Verifying        : apr-1.6.3-12.el8.x86_64                                       1/9 
  Verifying        : apr-util-1.6.1-6.el8.x86_64                                   2/9 
  Verifying        : apr-util-bdb-1.6.1-6.el8.x86_64                               3/9 
  Verifying        : apr-util-openssl-1.6.1-6.el8.x86_64                           4/9 
  Verifying        : centos-logos-httpd-85.8-2.el8.noarch                          5/9 
  Verifying        : httpd-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64         6/9 
  Verifying        : httpd-filesystem-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.n   7/9 
  Verifying        : httpd-tools-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64   8/9 
  Verifying        : mod_http2-1.15.7-5.module_el8.6.0+1111+ce6f4ceb.x86_64        9/9 
Installed products updated.

Installed:
  apr-1.6.3-12.el8.x86_64                                                              
  apr-util-1.6.1-6.el8.x86_64                                                          
  apr-util-bdb-1.6.1-6.el8.x86_64                                                      
  apr-util-openssl-1.6.1-6.el8.x86_64                                                  
  centos-logos-httpd-85.8-2.el8.noarch                                                 
  httpd-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64                                
  httpd-filesystem-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.noarch                     
  httpd-tools-2.4.37-47.module_el8.6.0+1111+ce6f4ceb.1.x86_64                          
  mod_http2-1.15.7-5.module_el8.6.0+1111+ce6f4ceb.x86_64                               

Complete!
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# ss -antl
State    Recv-Q    Send-Q       Local Address:Port       Peer Address:Port   Process   
LISTEN   0         32           192.168.122.1:53              0.0.0.0:*                
LISTEN   0         128                0.0.0.0:22              0.0.0.0:*                
LISTEN   0         5                127.0.0.1:631             0.0.0.0:*                
LISTEN   0         128                0.0.0.0:111             0.0.0.0:*                
LISTEN   0         128                   [::]:22                 [::]:*                
LISTEN   0         5                    [::1]:631                [::]:*                
LISTEN   0         128                   [::]:111                [::]:*                
LISTEN   0         128                      *:80                    *:*      
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0
[root@localhost ~]# cd /etc/httpd/conf.modules.d/
[root@localhost conf.modules.d]# pwd
/etc/httpd/conf.modules.d
[root@localhost conf.modules.d]# ls
00-base.conf  00-lua.conf  00-optional.conf  00-systemd.conf  10-h2.conf        README
00-dav.conf   00-mpm.conf  00-proxy.conf     01-cgi.conf      10-proxy_h2.conf
[root@localhost conf.modules.d]# 
[root@localhost 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

##访问控制法则:

法则功能
Require all granted允许所有主机访问
Require all deny拒绝所有主机访问
Require ip IPADDR授权指定来源地址的主机访问
Require not ip IPADDR拒绝指定来源地址的主机访问
Require host HOSTNAME授权指定来源主机名的主机访问
Require not host HOSTNAME拒绝指定来源主机名的主机访问
Alt text

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

示例:

<Directory /var/www/html/www>
    <RequireAll>
        Require not ip 192.168.1.20
        Require all granted
    </RequireAll>
</Directory>

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

相同IP不同端口
不同IP相同端口
相同IP相同端口不同域名
linux或者mac /e tc/hosts
windows:
c:/windows/system32/drivers/etc/hosts
准备工作

[root@localhost ~]# cd /var/www/html/
[root@localhost html]# mkdir youxi
[root@localhost html]# cd youxi/
[root@localhost youxi]# ls
feijiedazhan.zip  坦克.zip
[root@localhost ~]# mkdir youxi
[root@localhost ~]# cd youxi/
[root@localhost youxi]# ls
[root@localhost youxi]# ls
[root@localhost youxi]# cd
[root@localhost ~]# cd /var/www/html/

hello

[root@localhost html]# mkdir youxi
mkdir: cannot create directory ‘youxi’: File exists
[root@localhost html]# cd youxi/
[root@localhost youxi]# ls
feijiedazhan.zip  坦克.zip
[root@localhost youxi]# \
> 
[root@localhost youxi]# rm -rf 坦克.zip
[root@localhost youxi]# mv Battle_City tanke
mv: cannot stat 'Battle_City': No such file or directory
[root@localhost youxi]# rm -rf 坦克.zip
[root@localhost youxi]# mv Battle_City tanke
mv: cannot stat 'Battle_City': No such file or directory
[root@localhost youxi]# unzip 坦克.zip
unzip:  cannot find or open 坦克.zip, 坦克.zip.zip or 坦克.zip.ZIP.
[root@localhost youxi]# mv Battle_City tanke
mv: cannot stat 'Battle_City': No such file or directory
[root@localhost youxi]# ls
feijiedazhan.zip
[root@localhost youxi]# unzip 坦克.zip
unzip:  cannot find or open 坦克.zip, 坦克.zip.zip or 坦克.zip.ZIP.
[root@localhost youxi]# ls
feijiedazhan.zip  坦克.zip
[root@localhost youxi]# unzip 坦克.zip
Archive:  坦克.zip
                 q T T T T T T T T T T T T T T T r
                 U        Դ      ֮             U
   q T T T T T T      http://www.mycodes.net       T T T T T T r
   U             U      :http://www.mycodes.net  U             U
   U             U  ̳http://bbs.mycodes.net     U             U
   U             t T T T T T T T T T T T T T T T s             U
   U                                                           U
   U                                                           U
   U   1)   վ    ֤   ṩ                 ԺͰ ȫ ԡ          U
   U   2)     ʹ  ǰ 鶾                                       U
   U   4) ת ر վ ṩ    Դ    ɾ    ˵   ļ                  U
   U   5)   վ ṩ ij     Ϊ     Ѽ        ó    漰   ֺ      U
   U       İ Ȩ      д  ֪ͨ   ǡ                            U
   U   6)   վ ṩ    ֻ ɹ  о ʹ ã         24Сʱ  ɾ  ,    U
   U                ҵ  ;   ɴ     һ к    뱾վ ޹ء        U
   U                                                           U
   U             ̳:http://bbs.mycodes.net                     U
   U                                                           U
   U     1.  Ƽ ʹ ã WinRAR V3.2   ϰ汾  ѹ  վ              U
   U     2.   վ ռ ֧  :http://www.goodidc.com                U
   U                                                           U
   U                                                           U
   U         Դ    ֮   : http://www.mycodes.net               U
   U         Դ       ̳: http://bbs.mycodes.net               U
   U                     : http://www.goodidc.com              U
   U            ̳: http://bbs.mycodes.net                     U
   U                                                           U
   U     q                                               r     U
   t T T         Դ  ֮   http://www.mycodes.net           T T s
         t                                               s
            ʾ:
              MD5     ļ      ֲ ֪         ģ 
             ݿ  л          ܵ    ݰ 
      7a57a5a743894a0e  (16λ)
      21232f297a57a5a743894a0e4a801fc3  (32λ)
      7a57a5a743894a0e4a801fc343894a0e4a801fc3  (40λ) 
        ô        admin
   creating: Battle_City/
   creating: Battle_City/audio/
  inflating: Battle_City/audio/attack.mp3  
  inflating: Battle_City/audio/bulletCrack.mp3  
  inflating: Battle_City/audio/move.mp3  
  inflating: Battle_City/audio/playerCrack.mp3  
  inflating: Battle_City/audio/prop.mp3  
  inflating: Battle_City/audio/start.mp3  
  inflating: Battle_City/audio/tankCrack.mp3  
   creating: Battle_City/css/
  inflating: Battle_City/css/default.css  
   creating: Battle_City/images/
  inflating: Battle_City/images/menu.gif  
  inflating: Battle_City/images/tankAll.gif  
  inflating: Battle_City/images/Thumbs.db  
  inflating: Battle_City/index.html  
   creating: Battle_City/js/
  inflating: Battle_City/js/bullet.js  
  inflating: Battle_City/js/Collision.js  
  inflating: Battle_City/js/const.js  
  inflating: Battle_City/js/crackAnimation.js  
  inflating: Battle_City/js/Helper.js  
  inflating: Battle_City/js/jquery.min.js  
  inflating: Battle_City/js/keyboard.js  
  inflating: Battle_City/js/level.js  
  inflating: Battle_City/js/main.js  
  inflating: Battle_City/js/map.js   
  inflating: Battle_City/js/menu.js  
  inflating: Battle_City/js/num.js   
  inflating: Battle_City/js/prop.js  
  inflating: Battle_City/js/stage.js  
  inflating: Battle_City/js/tank.js  
[root@localhost youxi]# ls
Battle_City  feijiedazhan.zip  坦克.zip
[root@localhost youxi]# rm -rf 坦克.zip
[root@localhost youxi]# mv Battle_City tanke
[root@localhost youxi]# mv tanke /var/www/html/
[root@localhost youxi]# cd
[root@localhost youxi]# cd
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# ls
index.html  tanke  youxi
[root@localhost html]# 

          
[root@localhost html]# rm -rf youxi/
[root@localhost html]# cd /var/www/html/
[root@localhost html]# ls
index.html  tanke
[root@localhost html]# unzip feijiedazhan.zip 
unzip:  cannot find or open feijiedazhan.zip, feijiedazhan.zip.zip or feijiedazhan.zip.ZIP.
[root@localhost html]# unzip feijiedazhan.zip 
unzip:  cannot find or open feijiedazhan.zip, feijiedazhan.zip.zip or feijiedazhan.zip.ZIP.
[root@localhost html]# ls
index.html  tanke
[root@localhost html]# ls
feijiedazhan.zip  index.html  tanke
[root@localhost html]# unzip feijiedazhan.zip 
Archive:  feijiedazhan.zip
                 q T T T T T T T T T T T T T T T r
                 U        Դ      ֮             U
   q T T T T T T     www.mycodes.net      T T T T T T r
   U             t T T T T T T T T T T T T T T T s                U
   U                                                                 U
   U                                                             U
   U   1)   վ    ֤   ṩ                 ԺͰ ȫ ԡ          U
   U   2)     ʹ  ǰ 鶾                                       U
   U   4) ת ر վ ṩ    Դ    ɾ    ˵   ļ                  U
   U   5)   վ ṩ ij     Ϊ     Ѽ        ó    漰   ֺ      U
   U       İ Ȩ      д  ֪ͨ   ǡ                            U
   U   6)   վ ṩ    ֻ ɹ  о ʹ ã         24Сʱ  ɾ  ,    U
   U                ҵ  ;   ɴ     һ к    뱾վ ޹ء        U
   U                                                           U
   U                                                           U
   U      Ƽ ʹ ã WinRAR V3.2   ϰ汾  ѹ  վ              U
   U                                                           U
   U                                                           U
   U         Դ    ֮   : www.mycodes.net               U
   U                                                           U
   U     q                                               r     U
   t T T   Դ  ֮   www.mycodes.net           T T s
         t                                               s
            ʾ:
              MD5     ļ      ֲ ֪         ģ 
             ݿ  л          ܵ    ݰ 
      7a57a5a743894a0e  (16λ)
      21232f297a57a5a743894a0e4a801fc3  (32λ)
      7a57a5a743894a0e4a801fc343894a0e4a801fc3  (40λ) 
        ô        admin
   creating: HTML5全民飞机大战小游戏/
   creating: HTML5全民飞机大战小游戏/css/
   creating: HTML5全民飞机大战小游戏/img/
  inflating: HTML5全民飞机大战小游戏/img/.DS_Store  
  inflating: HTML5全民飞机大战小游戏/img/._.DS_Store  
  inflating: HTML5全民飞机大战小游戏/img/._bg.jpg  
  inflating: HTML5全民飞机大战小游戏/img/._bg2.jpg  
  inflating: HTML5全民飞机大战小游戏/img/._bigbg.jpg  
  inflating: HTML5全民飞机大战小游戏/img/._bossbullet.png  
  inflating: HTML5全民飞机大战小游戏/img/._bullet.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy1.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy1boom1.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy1boom2.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy1boom3.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy1boom4.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy1boom5.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy1boom6.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy2.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy2boom1.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy2boom2.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy2boom3.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy2boom4.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy2boom5.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy2boom6.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy3.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy3boom1.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy3boom2.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy3boom3.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy3boom4.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy3boom5.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy3boom6.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy4.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy4boom1.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy4boom2.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy4boom3.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy4boom4.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy4boom5.png  
  inflating: HTML5全民飞机大战小游戏/img/._enemy4boom6.png  
  inflating: HTML5全民飞机大战小游戏/img/._load1.png  
  inflating: HTML5全民飞机大战小游戏/img/._load2.png  
  inflating: HTML5全民飞机大战小游戏/img/._load3.png  
  inflating: HTML5全民飞机大战小游戏/img/._load4.png  
  inflating: HTML5全民飞机大战小游戏/img/._load5.png  
  inflating: HTML5全民飞机大战小游戏/img/._load6.png  
  inflating: HTML5全民飞机大战小游戏/img/._load7.png  
  inflating: HTML5全民飞机大战小游戏/img/._load8.png  
  inflating: HTML5全民飞机大战小游戏/img/._load9.png  
  inflating: HTML5全民飞机大战小游戏/img/._myplane1.png  
  inflating: HTML5全民飞机大战小游戏/img/._myplane1boom1.png  
  inflating: HTML5全民飞机大战小游戏/img/._myplane1boom2.png  
  inflating: HTML5全民飞机大战小游戏/img/._myplane1boom3.png  
  inflating: HTML5全民飞机大战小游戏/img/._myplane1boom4.png  
  inflating: HTML5全民飞机大战小游戏/img/._myplane1boom5.png  
  inflating: HTML5全民飞机大战小游戏/img/._myplane1boom6.png  
  inflating: HTML5全民飞机大战小游戏/img/._myplane1boom7.png  
  inflating: HTML5全民飞机大战小游戏/img/._myplane1boom8.png  
  inflating: HTML5全民飞机大战小游戏/img/._myplane1boom9.png  
  inflating: HTML5全民飞机大战小游戏/img/._myplane2.png  
  inflating: HTML5全民飞机大战小游戏/img/._myplane3.png  
  inflating: HTML5全民飞机大战小游戏/img/._planeboss.png  
  inflating: HTML5全民飞机大战小游戏/img/._starthead.png  
  inflating: HTML5全民飞机大战小游戏/img/._starting.png  
  inflating: HTML5全民飞机大战小游戏/img/._warning1.png  
  inflating: HTML5全民飞机大战小游戏/img/._warning2.png  
  inflating: HTML5全民飞机大战小游戏/img/bg.jpg  
  inflating: HTML5全民飞机大战小游戏/img/bg2.jpg  
  inflating: HTML5全民飞机大战小游戏/img/bigbg.jpg  
  inflating: HTML5全民飞机大战小游戏/img/bossbullet.png  
  inflating: HTML5全民飞机大战小游戏/img/bullet.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy1.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy1boom1.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy1boom2.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy1boom3.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy1boom4.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy1boom5.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy1boom6.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy2.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy2boom1.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy2boom2.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy2boom3.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy2boom4.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy2boom5.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy2boom6.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy3.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy3boom1.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy3boom2.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy3boom3.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy3boom4.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy3boom5.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy3boom6.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy4.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy4boom1.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy4boom2.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy4boom3.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy4boom4.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy4boom5.png  
  inflating: HTML5全民飞机大战小游戏/img/enemy4boom6.png  
  inflating: HTML5全民飞机大战小游戏/img/load1.png  
  inflating: HTML5全民飞机大战小游戏/img/load2.png  
  inflating: HTML5全民飞机大战小游戏/img/load3.png  
  inflating: HTML5全民飞机大战小游戏/img/load4.png  
  inflating: HTML5全民飞机大战小游戏/img/load5.png  
  inflating: HTML5全民飞机大战小游戏/img/load6.png  
  inflating: HTML5全民飞机大战小游戏/img/load7.png  
  inflating: HTML5全民飞机大战小游戏/img/load8.png  
  inflating: HTML5全民飞机大战小游戏/img/load9.png  
  inflating: HTML5全民飞机大战小游戏/img/myplane1.png  
  inflating: HTML5全民飞机大战小游戏/img/myplane1boom1.png  
  inflating: HTML5全民飞机大战小游戏/img/myplane1boom2.png  
  inflating: HTML5全民飞机大战小游戏/img/myplane1boom3.png  
  inflating: HTML5全民飞机大战小游戏/img/myplane1boom4.png  
  inflating: HTML5全民飞机大战小游戏/img/myplane1boom5.png  
  inflating: HTML5全民飞机大战小游戏/img/myplane1boom6.png  
  inflating: HTML5全民飞机大战小游戏/img/myplane1boom7.png  
  inflating: HTML5全民飞机大战小游戏/img/myplane1boom8.png  
  inflating: HTML5全民飞机大战小游戏/img/myplane1boom9.png  
  inflating: HTML5全民飞机大战小游戏/img/myplane2.png  
  inflating: HTML5全民飞机大战小游戏/img/myplane3.png  
  inflating: HTML5全民飞机大战小游戏/img/planeboss.png  
  inflating: HTML5全民飞机大战小游戏/img/starthead.png  
  inflating: HTML5全民飞机大战小游戏/img/starting.png  
  inflating: HTML5全民飞机大战小游戏/img/warning1.png  
  inflating: HTML5全民飞机大战小游戏/img/warning2.png  
  inflating: HTML5全民飞机大战小游戏/index.html  
   creating: HTML5全民飞机大战小游戏/js/
  inflating: HTML5全民飞机大战小游戏/js/.DS_Store  
  inflating: HTML5全民飞机大战小游戏/js/._.DS_Store  
  inflating: HTML5全民飞机大战小游戏/js/._index.js  
  inflating: HTML5全民飞机大战小游戏/js/index.js  
  [root@localhost html]# ls
feijiedazhan.zip  HTML5全民飞机大战小游戏  index.html  tanke
[root@localhost html]# mv HTML5全民飞机大战小游戏 feiji
[root@localhost html]# ls
feiji  feijiedazhan.zip  index.html  tanke
[root@localhost html]# rm -rf feijiedazhan.zip 
[root@localhost html]# ls
feiji  index.html  tanke
[root@localhost html]# 

##相同IP不同端口

[root@localhost html]# cp /usr/share/doc/httpd/httpd-vhosts.conf/etc/httpd/c
cp: missing destination file operand after '/usr/share/doc/httpd/httpd-vhosts.conf/etc/httpd/c'
Try 'cp --help' for more information.
[root@localhost html]# onf.d/
bash: onf.d/: No such file or directory
[root@localhost html]# cp /usr/share/doc/httpd/httpd-vhosts.conf/etc/httpd/conf.d/
cp: missing destination file operand after '/usr/share/doc/httpd/httpd-vhosts.conf/etc/httpd/conf.d/'
Try 'cp --help' for more information.
[root@localhost html]# cd\
> 
[root@localhost ~]# cp /usr/share/doc/httpd/httpd-vhosts.conf/etc/httpd/conf.d/
cp: missing destination file operand after '/usr/share/doc/httpd/httpd-vhosts.conf/etc/httpd/conf.d/'
Try 'cp --help' for more information.
[root@localhost ~]# cp /usr/share/doc/httpd/httpd-vhosts.conf /etc/httpd/conf.d/
[root@localhost ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf 

<VirtualHost *:80>
DocumentRoot "/var/www/html/tanke"
ServerName www.tanke1.com
ErrorLog "/var/log/httpd/www.tanke1.com-error_log"
CustomLog "/var/log/httpd/www.tanke1.com-access_log" common
</VirtualHost>

Listen 81
<VirtualHost *:81>
DocumentRoot "/var/www/html/feiji"
ServerName www.feiji1.com
ErrorLog "/var/log/httpd/feiji1.com-error_log"
CustomLog "/var/log/httpd/feiji1.com-access_log
[root@localhost ~]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# 
[root@localhost html]# systemctl restart httpd
[root@localhost html]# cd
[root@localhost ~]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl stop firewalld.service 
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl restart httpd

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-QKlIWLuu-1658471021471)(./1658426932032.png)]

不同 IP 相同端口

[root@localhost ~]# ip addr add 192.168.139.136/24 dev ens160
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:d5:b9:22 brd ff:ff:ff:ff:ff:ff
    inet 192.168.139.134/24 brd 192.168.139.255 scope global dynamic noprefixroute ens160
       valid_lft 1488sec preferred_lft 1488sec
    inet 192.168.139.136/24 scope global secondary ens160
       valid_lft forever preferred_lft forever
    inet6 fe80::9c92:7dc9:f434:87a0/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:a2:32:51 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:a2:32:51 brd ff:ff:ff:ff:ff:ff
    [root@localhost ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf 
<VirtualHost *:192.168.139.136:80>
[root@localhost ~]# httpd -t
[Thu Jul 21 14:16:30.381774 2022] [core:error] [pid 5023:tid 140119625603392] (EAI 2)Name or service not known: AH00547: Could not resolve host name *:192.168.139.136 -- ignoring!
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@localhost ~]# systemctl restart httpd

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ekghvUkw-1658471021472)(./1658427474053.png)]

相同 IP 相同端口不同域名

<VirtualHost *:80>
DocumentRoot "/var/www/html/tanke"
ServerName www.tanke1.com
ErrorLog "/var/log/httpd/www.tanke1.com-error_log"
CustomLog "/var/log/httpd/www.tanke1.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/html/feiji"
ServerName www.feiji1.com
ErrorLog "/var/log/httpd/feiji1.com-error_log"
CustomLog "/var/log/httpd/feiji1.com-access_log" common
</VirtualHost>
[root@localhost ~]# httpd -t
Syntax OK
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf 
<VirtualHost *:80>
DocumentRoot "/var/www/html/tanke"
ServerName www.tanke1.com
ErrorLog "/var/log/httpd/www.tanke1.com-error_log"
CustomLog "/var/log/httpd/www.tanke1.com-access_log" common
</VirtualHost>


<VirtualHost *:80>
DocumentRoot "/var/www/html/feiji"
ServerName www.feiji1.com
ErrorLog "/var/log/httpd/feiji1.com-error_log"
CustomLog "/var/log/httpd/feiji1.com-access_log" common
</VirtualHost>
[root@localhost ~]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# 

域名映射
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-wlsnSvju-1658471021473)(./1658427834928.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-yLxE5DU8-1658471021473)(./1658427970764.png)]

//创建网页目录并修改属主属组

[root@localhost ~]# cd /var/www/html/
[root@localhost html]# ls
feiji  index.html  tanke
[root@localhost html]# mkdir www blog
[root@localhost html]# ll
total 4
drwxr-xr-x. 2 root root  6 Jul 21 14:28 blog
drwxr-xr-x. 5 root root 56 Apr 17  2020 feiji
-rw-r--r--. 1 root root  6 Jul 21 14:03 index.html
drwxr-xr-x. 6 root root 72 Sep 24  2015 tanke
drwxr-xr-x. 2 root root  6 Jul 21 14:28 www
[root@localhost html]# 
[root@localhost html]# chown -R apache.apache blog
[root@localhost html]# chown -R apache.apache www
[root@localhost html]# ll
total 4
drwxr-xr-x. 2 apache apache  6 Jul 21 14:28 blog
drwxr-xr-x. 5 root   root   56 Apr 17  2020 feiji
-rw-r--r--. 1 root   root    6 Jul 21 14:03 index.html
drwxr-xr-x. 6 root   root   72 Sep 24  2015 tanke
drwxr-xr-x. 2 apache apache  6 Jul 21 14:28 www

//启动服务并查看是否有80端口

[root@localhost html]# systemctl restart httpd
[root@localhost html]# ss -anlt
State    Recv-Q   Send-Q      Local Address:Port       Peer Address:Port   Process   
LISTEN   0        128               0.0.0.0:111             0.0.0.0:*                
LISTEN   0        32          192.168.122.1:53              0.0.0.0:*                
LISTEN   0        128               0.0.0.0:22              0.0.0.0:*                
LISTEN   0        5               127.0.0.1:631             0.0.0.0:*                
LISTEN   0        128                  [::]:111                [::]:*                
LISTEN   0        128                     *:80                    *:*                
LISTEN   0        128                  [::]:22                 [::]:*                
LISTEN   0        5                   [::1]:631                [::]:*                
[root@localhost html]# 

#CA证书
ssl:
启用模块:编辑/etc/httpd/conf.modules.d/00­base.conf文件,添加下面这行,如果已经有了但是注
释了,则取消注释即可
LoadModule ssl_module modules/mod_ssl.so

##下载ssl服务

[root@localhost html]# dnf -y install mod_sll*
Last metadata expiration check: 4:07:47 ago on Thu 21 Jul 2022 10:39:36 AM EDT.
No match for argument: mod_sll*
Error: Unable to find a match: mod_sll*
[root@localhost html]# systemctl restart httpd
[root@localhost html]# ss -antl
State    Recv-Q   Send-Q      Local Address:Port       Peer Address:Port   Process   
LISTEN   0        128               0.0.0.0:111             0.0.0.0:*                
LISTEN   0        32          192.168.122.1:53              0.0.0.0:*                
LISTEN   0        128               0.0.0.0:22              0.0.0.0:*                
LISTEN   0        5               127.0.0.1:631             0.0.0.0:*                
LISTEN   0        128                  [::]:111                [::]:*                
LISTEN   0        128                     *:80                    *:*                
LISTEN   0        128                  [::]:22                 [::]:*                
LISTEN   0        5                   [::1]:631                [::]:*  

###生成证书

[root@localhost html]# mkdir /etc/pki/CA
[root@localhost html]# cd /etc/pki/CA
[root@localhost CA]# mkdir private
[root@localhost 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@localhost CA]# openssl rsa -in private/cakey.pem -pubout
writing RSA key
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0+TAlYYENomZOpL+/Rvx
7ah+9iJbSKAT6n6K+i1rTEB5OQi3mVmjjoii/8xr89No88oRbe1dD4hE1CF4SEX1
ld5RU9LuGzZOUojL++OLKik/1vNl8c/iogYhFDwKj/9aazP5uj7zTTOK5moxHFR9
bEI9KuM8T1wMO8h3SCWh6TZ/6riVYLPdrJEcuY0gktXqQ/BydkNOWs5cVKSkI+Og
0eLuXsfRZHerxZxTVCW+/adEdNQo9BD07tDxWfvSqX0qHWH45rb4Kv/esBFgPmbJ
UsFLZwrS3+YsHKf1o6CVGll61pEy6jokGeZK/fIX2l8mF6tnGeDfO6ObYtqIZ9iq
nwIDAQAB
-----END PUBLIC KEY-----
[root@localhost CA]# 
[root@localhost 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]:
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]:runtime
Organizational Unit Name (eg, section) []:edu
Common Name (eg, your name or your server's hostname) []:www.tanke1.com
Email Address []:1@2.com
[root@localhost CA]# 
[root@localhost CA]# openssl x509 -text -in cacert.pem
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            01:4f:70:8d:6a:91:4d:bf:78:ef:c4:9b:68:de:f2:40:b6:42:22:6e
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: C = cn, ST = hb, L = wh, O = runtime, OU = edu, CN = www.tanke1.com, emailAddress = 1@2.com
        Validity
            Not Before: Jul 21 18:54:17 2022 GMT
            Not After : Jul 21 18:54:17 2023 GMT
        Subject: C = cn, ST = hb, L = wh, O = runtime, OU = edu, CN = www.tanke1.com, emailAddress = 1@2.com
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                RSA Public-Key: (2048 bit)
                Modulus:
                    00:d3:e4:c0:95:86:04:36:89:99:3a:92:fe:fd:1b:
                    f1:ed:a8:7e:f6:22:5b:48:a0:13:ea:7e:8a:fa:2d:
                    6b:4c:40:79:39:08:b7:99:59:a3:8e:88:a2:ff:cc:
                    6b:f3:d3:68:f3:ca:11:6d:ed:5d:0f:88:44:d4:21:
                    78:48:45:f5:95:de:51:53:d2:ee:1b:36:4e:52:88:
                    cb:fb:e3:8b:2a:29:3f:d6:f3:65:f1:cf:e2:a2:06:
                    21:14:3c:0a:8f:ff:5a:6b:33:f9:ba:3e:f3:4d:33:
                    8a:e6:6a:31:1c:54:7d:6c:42:3d:2a:e3:3c:4f:5c:
                    0c:3b:c8:77:48:25:a1:e9:36:7f:ea:b8:95:60:b3:
                    dd:ac:91:1c:b9:8d:20:92:d5:ea:43:f0:72:76:43:
                    4e:5a:ce:5c:54:a4:a4:23:e3:a0:d1:e2:ee:5e:c7:
                    d1:64:77:ab:c5:9c:53:54:25:be:fd:a7:44:74:d4:
                    28:f4:10:f4:ee:d0:f1:59:fb:d2:a9:7d:2a:1d:61:
                    f8:e6:b6:f8:2a:ff:de:b0:11:60:3e:66:c9:52:c1:
                    4b:67:0a:d2:df:e6:2c:1c:a7:f5:a3:a0:95:1a:59:
                    7a:d6:91:32:ea:3a:24:19:e6:4a:fd:f2:17:da:5f:
                    26:17:ab:67:19:e0:df:3b:a3:9b:62:da:88:67:d8:
                    aa:9f
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Subject Key Identifier: 
                A8:E7:F1:D2:C7:C2:6E:0A:FF:32:04:4C:E8:63:04:67:ED:D5:F7:B8
            X509v3 Authority Key Identifier: 
                keyid:A8:E7:F1:D2:C7:C2:6E:0A:FF:32:04:4C:E8:63:04:67:ED:D5:F7:B8

            X509v3 Basic Constraints: critical
                CA:TRUE
    Signature Algorithm: sha256WithRSAEncryption
         3d:09:67:4c:34:7e:f1:cb:9b:00:3f:58:a5:a8:81:69:be:9b:
         eb:ad:8b:98:b7:be:d9:1b:cd:86:cc:58:9a:f2:94:92:81:29:
         5c:1e:7b:bb:0a:fe:55:e8:c0:95:0a:1f:16:0d:3a:6b:64:70:
         88:c8:5c:8d:3e:bf:87:41:38:f8:75:31:01:73:53:94:4d:75:
         3b:aa:eb:f8:f2:eb:e5:28:67:89:10:99:2e:33:0d:f2:f2:1e:
         60:1c:42:a8:a4:9a:ea:b7:8f:c8:b9:28:f3:04:70:7f:d6:74:
         d1:24:f3:6f:79:cc:9d:c7:c1:f0:ff:7e:c4:28:ba:cd:f5:31:
         85:da:80:aa:24:6f:be:d3:c7:e1:e8:fc:87:d2:70:a9:77:d1:
         39:39:f0:da:7b:ea:67:b9:39:64:c9:97:97:03:39:bf:ed:39:
         9b:bc:cd:ad:67:7d:fa:9e:66:69:06:dc:f5:e0:94:d6:ce:e4:
         93:fb:fb:75:44:1e:a5:b7:2f:8e:88:ab:ac:f0:0c:c8:ac:5f:
         c2:20:94:17:76:d2:2d:0f:a3:9a:e5:a1:ed:5a:d8:6e:b0:2b:
         37:b1:02:30:58:5d:87:bd:74:b9:28:aa:e7:34:b7:0d:90:ac:
         6b:30:2f:00:2c:71:a1:c4:41:ac:38:33:35:ee:58:9d:9d:69:
         d8:b5:7b:00
-----BEGIN CERTIFICATE-----
MIID0TCCArmgAwIBAgIUAU9wjWqRTb9478SbaN7yQLZCIm4wDQYJKoZIhvcNAQEL
BQAweDELMAkGA1UEBhMCY24xCzAJBgNVBAgMAmhiMQswCQYDVQQHDAJ3aDEQMA4G
A1UECgwHcnVudGltZTEMMAoGA1UECwwDZWR1MRcwFQYDVQQDDA53d3cudGFua2Ux
LmNvbTEWMBQGCSqGSIb3DQEJARYHMUAyLmNvbTAeFw0yMjA3MjExODU0MTdaFw0y
MzA3MjExODU0MTdaMHgxCzAJBgNVBAYTAmNuMQswCQYDVQQIDAJoYjELMAkGA1UE
BwwCd2gxEDAOBgNVBAoMB3J1bnRpbWUxDDAKBgNVBAsMA2VkdTEXMBUGA1UEAwwO
d3d3LnRhbmtlMS5jb20xFjAUBgkqhkiG9w0BCQEWBzFAMi5jb20wggEiMA0GCSqG
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDT5MCVhgQ2iZk6kv79G/HtqH72IltIoBPq
for6LWtMQHk5CLeZWaOOiKL/zGvz02jzyhFt7V0PiETUIXhIRfWV3lFT0u4bNk5S
iMv744sqKT/W82Xxz+KiBiEUPAqP/1prM/m6PvNNM4rmajEcVH1sQj0q4zxPXAw7
yHdIJaHpNn/quJVgs92skRy5jSCS1epD8HJ2Q05azlxUpKQj46DR4u5ex9Fkd6vF
nFNUJb79p0R01Cj0EPTu0PFZ+9KpfSodYfjmtvgq/96wEWA+ZslSwUtnCtLf5iwc
p/WjoJUaWXrWkTLqOiQZ5kr98hfaXyYXq2cZ4N87o5ti2ohn2KqfAgMBAAGjUzBR
MB0GA1UdDgQWBBSo5/HSx8JuCv8yBEzoYwRn7dX3uDAfBgNVHSMEGDAWgBSo5/HS
x8JuCv8yBEzoYwRn7dX3uDAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUA
A4IBAQA9CWdMNH7xy5sAP1ilqIFpvpvrrYuYt77ZG82GzFia8pSSgSlcHnu7Cv5V
6MCVCh8WDTprZHCIyFyNPr+HQTj4dTEBc1OUTXU7quv48uvlKGeJEJkuMw3y8h5g
HEKopJrqt4/IuSjzBHB/1nTRJPNvecydx8Hw/37EKLrN9TGF2oCqJG++08fh6PyH
0nCpd9E5OfDae+pnuTlkyZeXAzm/7TmbvM2tZ336nmZpBtz14JTWzuST+/t1RB6l
ty+OiKus8AzIrF/CIJQXdtItD6Oa5aHtWthusCs3sQIwWF2HvXS5KKrnNLcNkKxr
MC8ALHGhxEGsODM17lidnWnYtXsA
-----END CERTIFICATE-----
[root@localhost CA]# 

[root@localhost CA]# mkdir certs newcerts crl
[root@localhost CA]# touch index.txt && echo 01 > serial
[root@localhost CA]# cd /etc/httpd && mkdir ssl && cd ssl
[root@localhost ssl]# (umask 077;openssl genrsa -out private/cakey.pem 2048)
genrsa: Can't open "private/cakey.pem" for writing, No such file or directory
[root@localhost ssl]# (umask 077;openssl genrsa -out httpd.key 2048)
Generating RSA private key, 2048 bit long modulus (2 primes)
....................................+++++
.......................+++++
e is 65537 (0x010001)
[root@localhost 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]:
[root@localhost 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]:runtime
Organizational Unit Name (eg, section) []:edu
Common Name (eg, your name or your server's hostname) []:www.tanke1.com
Email Address []:1@2.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[root@localhost ssl]# openssl ca -in httpd.csr -out httpd.crt -days 365
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 1 (0x1)
        Validity
            Not Before: Jul 21 19:03:21 2022 GMT
            Not After : Jul 21 19:03:21 2023 GMT
        Subject:
            countryName               = cn
            stateOrProvinceName       = hb
            organizationName          = runtime
            organizationalUnitName    = edu
            commonName                = www.tanke1.com
            emailAddress              = 1@2.com
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Comment: 
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier: 
                86:98:E3:8A:77:A1:3B:70:B3:16:52:B2:F6:BC:47:91:2E:CD:0C:01
            X509v3 Authority Key Identifier: 
                keyid:A8:E7:F1:D2:C7:C2:6E:0A:FF:32:04:4C:E8:63:04:67:ED:D5:F7:B8

Certificate is to be certified until Jul 21 19:03:21 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@localhost ssl]# 

2.配置 httpd.conf
3.在 httpd­vhosts.conf 中配置虚拟主机
4.在 ssl.conf 中配置证书的位置

[root@localhost ssl]# cd /etc/httpd/conf.d/

[root@localhost conf.d]# vim ssl.conf


^[[200~......
DocumentRoot "/var/www/html/tanke"
ServerName www.tanke1.com:443
.....
SSLCertificateFile /etc/httpd/ssl/httpd.crt
.....
SSLCertificateKeyFile /etc/httpd/ssl/httpd.key
[root@localhost conf.d]# httpd -t
AH00526: Syntax error on line 1 of /etc/httpd/conf.d/ssl.conf:
Invalid command '......', perhaps misspelled or defined by a module not included in the server configuration
[root@localhost conf.d]# systemctl restart httpd
Job for httpd.service failed because the control process exited with error code.
See "systemctl status httpd.service" and "journalctl -xe" for details.
[root@localhost conf.d]# ss -antl
State    Recv-Q   Send-Q     Local Address:Port      Peer Address:Port   Process   
LISTEN   0        128              0.0.0.0:111            0.0.0.0:*                
LISTEN   0        32         192.168.122.1:53             0.0.0.0:*                
LISTEN   0        128              0.0.0.0:22             0.0.0.0:*                
LISTEN   0        5              127.0.0.1:631            0.0.0.0:*                
LISTEN   0        128                 [::]:111               [::]:*                
LISTEN   0        128                 [::]:22                [::]:*                
LISTEN   0        5                  [::1]:631               [::]:*                
[root@localhost conf.d]# 

设置 hosts 以便用域名访问

![Alt text](./1658431126795.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值