apache

作者: Tess鱼丸 | 来源:发表于2022-11-22 10:31 被阅读0次
    [root@localhost ~]# rpm -q httpd
    package httpd is not installed
    [root@localhost ~]# 
    [root@localhost ~]# 
    [root@localhost ~]# 
    [root@localhost ~]# 
    [root@localhost ~]# httpd -v
    bash: httpd: command not found...
    [root@localhost ~]# 
    [root@localhost ~]# yum -y install httpd
    Loaded plugins: fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
     * base: ftp.sjtu.edu.cn
     * extras: ftp.sjtu.edu.cn
     * updates: ftp.sjtu.edu.cn
    base                                                     | 3.6 kB     00:00     
    extras                                                   | 2.9 kB     00:00     
    updates                                                  | 2.9 kB     00:00     
    Resolving Dependencies
    --> Running transaction check
    ---> Package httpd.x86_64 0:2.4.6-97.el7.centos.5 will be installed
    --> Processing Dependency: httpd-tools = 2.4.6-97.el7.centos.5 for package: httpd-2.4.6-97.el7.centos.5.x86_64
    --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-97.el7.centos.5.x86_64
    --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-97.el7.centos.5.x86_64
    --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-97.el7.centos.5.x86_64
    --> Running transaction check
    ---> Package apr.x86_64 0:1.4.8-7.el7 will be installed
    ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
    ---> Package httpd-tools.x86_64 0:2.4.6-97.el7.centos.5 will be installed
    ---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ================================================================================
     Package           Arch         Version                     Repository     Size
    ================================================================================
    Installing:
     httpd             x86_64       2.4.6-97.el7.centos.5       updates       2.7 M
    Installing for dependencies:
     apr               x86_64       1.4.8-7.el7                 base          104 k
     apr-util          x86_64       1.5.2-6.el7                 base           92 k
     httpd-tools       x86_64       2.4.6-97.el7.centos.5       updates        94 k
     mailcap           noarch       2.1.41-2.el7                base           31 k
    
    Transaction Summary
    ================================================================================
    Install  1 Package (+4 Dependent packages)
    
    Total download size: 3.0 M
    Installed size: 10 M
    Downloading packages:
    (1/5): apr-util-1.5.2-6.el7.x86_64.rpm                     |  92 kB   00:01     
    (2/5): mailcap-2.1.41-2.el7.noarch.rpm                     |  31 kB   00:00     
    (3/5): httpd-tools-2.4.6-97.el7.centos.5.x86_64.rpm        |  94 kB   00:03     
    (4/5): apr-1.4.8-7.el7.x86_64.rpm                          | 104 kB   00:03     
    (5/5): httpd-2.4.6-97.el7.centos.5.x86_64.rpm              | 2.7 MB   01:46     
    --------------------------------------------------------------------------------
    Total                                               29 kB/s | 3.0 MB  01:46     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : apr-1.4.8-7.el7.x86_64                                       1/5 
      Installing : apr-util-1.5.2-6.el7.x86_64                                  2/5 
      Installing : httpd-tools-2.4.6-97.el7.centos.5.x86_64                     3/5 
      Installing : mailcap-2.1.41-2.el7.noarch                                  4/5 
      Installing : httpd-2.4.6-97.el7.centos.5.x86_64                           5/5 
      Verifying  : apr-1.4.8-7.el7.x86_64                                       1/5 
      Verifying  : mailcap-2.1.41-2.el7.noarch                                  2/5 
      Verifying  : httpd-tools-2.4.6-97.el7.centos.5.x86_64                     3/5 
      Verifying  : apr-util-1.5.2-6.el7.x86_64                                  4/5 
      Verifying  : httpd-2.4.6-97.el7.centos.5.x86_64                           5/5 
    
    Installed:
      httpd.x86_64 0:2.4.6-97.el7.centos.5                                          
    
    Dependency Installed:
      apr.x86_64 0:1.4.8-7.el7                      apr-util.x86_64 0:1.5.2-6.el7   
      httpd-tools.x86_64 0:2.4.6-97.el7.centos.5    mailcap.noarch 0:2.1.41-2.el7   
    
    Complete!
    [root@localhost ~]# 
    
    [root@localhost ~]# systemctl start httpd
    [root@localhost ~]# systemctl status httpd
    鈼[0m httpd.service - The Apache HTTP Server
       Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
       Active: active (running) since Tue 2022-11-22 17:05:23 PST; 58s ago
         Docs: man:httpd(8)
               man:apachectl(8)
     Main PID: 3696 (httpd)
       Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
        Tasks: 6
       CGroup: /system.slice/httpd.service
               鈹溾攢3696 /usr/sbin/httpd -DFOREGROUND
               鈹溾攢3701 /usr/sbin/httpd -DFOREGROUND
               鈹溾攢3702 /usr/sbin/httpd -DFOREGROUND
               鈹溾攢3703 /usr/sbin/httpd -DFOREGROUND
               鈹溾攢3704 /usr/sbin/httpd -DFOREGROUND
               鈹斺攢3705 /usr/sbin/httpd -DFOREGROUND
    
    Nov 22 17:05:23 localhost.localdomain systemd[1]: Starting The Apache HTTP Se...
    Nov 22 17:05:23 localhost.localdomain httpd[3696]: AH00558: httpd: Could not ...
    Nov 22 17:05:23 localhost.localdomain systemd[1]: Started The Apache HTTP Ser...
    Hint: Some lines were ellipsized, use -l to show in full.
    [root@localhost ~]# 
    

    关闭防火墙

    [root@localhost ~]# systemctl stop firewalld.service 
    
    [root@localhost ~]# setenforce 0
    

    此时已经可以访问了

    /etc/httpd/ conf /httpd. conf //apache的主配置文件
    /etc/httpd   //apache的配置目录
    /var/www   //apache存放网页的目录
    

    任务二

    目录列举加固

    [root@localhost sectest]# vim /etc/httpd/conf/httpd.conf 
    ####改成以下内容
        #Options Indexes FollowSymLinks
         Options FollowSymLinks
    

    任务三

    使用HTTP用户登录

    先创建http用户

    ####在当前目录下
    [root@localhost sectest]# pwd
    /var/www/html/sectest
    [root@localhost sectest]# htpasswd -c /usr/local/etc/passwd.httpd testuser
    New password: 
    Re-type new password: 
    Adding password for user testuser
    [root@localhost sectest]# 
    [root@localhost sectest]# cat /usr/local/etc/passwd.httpd 
    testuser:$apr1$jhXeJznP$xCcc.hpxQiMk4OhjFUdjB0
    [root@localhost sectest]# 
    

    添加一下内容

    ####千万别打错字
    <Directory "/var/www/html/sectest">
      Options Indexes FollowSymLinks
      AllowOverride AuthConfig
      AuthType Basic
      AuthName "testuser`s password"
      AuthUserFile /usr/local/etc/passwd.httpd
      Require user testuser
    </Directory>
    

    相关文章

      网友评论

          本文标题:apache

          本文链接:https://www.haomeiwen.com/subject/ubwgxdtx.html