Server - Apache - 基本操作: 安装, 卸载, 启停

blog01

  1. 概述
    1. apache 基本操作
  2. 背景
    1. 当了好久的咸鱼, 尝试了解一下, 自己完全不了解的东西...
  3. 环境
    1. OS
      1. CentOS7.2

1. 确认

  1. 概述
    1. 确认是否自带了 apache
  2. 命令

    # 你要找的是 apache, 关我 httpd 什么事
    # httpd 就是 apache...
    > systemctl status httpd
    > rpm -qa | grep http
    httpd-manual-2.4.6-89.el7.centos.noarch
    httpd-2.4.6-89.el7.centos.x86_64
    http-parser-2.7.1-5.el7_4.x86_64
    httpd-tools-2.4.6-89.el7.centos.x86_64
  3. 结果
    1. 命令1

      # 已经装了 httpd
      ● httpd.service - The Apache HTTP Server
         Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
         Active: inactive (dead)
           Docs: man:httpd(8)
                 man:apachectl(8)
    2. 命令2

      # httpd 就是我们要找的 apache
      httpd-manual-2.4.6-89.el7.centos.noarch
      httpd-2.4.6-89.el7.centos.x86_64
      http-parser-2.7.1-5.el7_4.x86_64
      httpd-tools-2.4.6-89.el7.centos.x86_64

2. 卸载

  1. 概述
    1. 卸载 现有的版本
  2. 命令

    > yum remove httpd
  3. 结果

    # 卸载完毕
    Removed:
      httpd.x86_64 0:2.4.6-89.el7.centos                                                                                              
    Dependency Removed:
      httpd-manual.noarch 0:2.4.6-89.el7.centos      mod_fcgid.x86_64 0:2.3.9-4.el7_4.1      mod_ssl.x86_64 1:2.4.6-89.el7.centos

3. 重新安装

  1. 概述
    1. 装个新的
  2. 命令

    > yum search httpd
    > yum install httpd

4. 再次验证

  1. 概述
    1. 验证之前的安装
  2. 命令

    > rpm -qa| grep httpd
    > systemctl status httpd
  3. 结果
    1. 命令1

      httpd-tools-2.4.6-90.el7.centos.x86_64
      httpd-2.4.6-90.el7.centos.x86_64
    2. 命令2

      ● httpd.service - The Apache HTTP Server
         Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
         Active: inactive (dead)
           Docs: man:httpd(8)
                 man:apachectl(8)
    3. 区别
      1. 版本
        1. 2.4.6-89 > 2.4.6-90
        1. 少了两个包

5. 启动与停止

  1. 概述
    1. 使用 systemctl 来启停
  2. 命令

    # 启动
    > systemctl start httpd
    # 停止
    > systemctl stop httpd
  3. 遇到了些问题
    1. 启动失败

      Jan 13 01:34:49 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
      Jan 13 01:34:49 localhost.localdomain httpd[2104]: AH00558: httpd: Could not reliably determine the server's fully qualifi...ssage
      Jan 13 01:34:49 localhost.localdomain httpd[2104]: httpd (pid 1966) already running
      Jan 13 01:34:49 localhost.localdomain kill[2106]: kill: cannot find process ""
      Jan 13 01:34:49 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
      Jan 13 01:34:49 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
      Jan 13 01:34:49 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
      Jan 13 01:34:49 localhost.localdomain systemd[1]: httpd.service failed.
    2. 查询进程

      # 卧槽, 这都是啥
      # 不知道咋来的
      # 杀掉了 1966, 还是不行
      > ps -ef | grep httpd
      apache    1966     1  0 01:29 ?        00:00:00 /usr/sbin/httpd --help
      apache    1967     1  0 01:29 ?        00:00:00 /usr/sbin/httpd --help
      apache    1968     1  0 01:29 ?        00:00:00 /usr/sbin/httpd --help
      apache    1969     1  0 01:29 ?        00:00:00 /usr/sbin/httpd --help
      apache    1970     1  0 01:29 ?        00:00:00 /usr/sbin/httpd --help
      apache    1971     1  0 01:29 ?        00:00:00 /usr/sbin/httpd --help
      root      2139  1208  0 01:36 pts/1    00:00:00 grep --color=auto httpd
    3. 最后
      1. 重启了
        1. 重启没有这些 乱七八糟的 httpd 了
      2. 尝试启动
        1. 成功

ps

  1. 后续
    1. apache
      1. apache 有一个自带的 apachectl, 也可以做到 启停
    2. systemctl
      1. 这玩意虽然经常在用, 但还是有点不知道在说啥
    3. 测试使用
      1. 简单的 http 使用
      2. 可能还得了解一些 协议
    4. curl
      1. 目前暂时不关注 css, js, 所以不需要浏览器, 就能做一些测试
      2. 这玩意得稍微复习一下了
    5. C
      1. apache 是 C 语言写的, 但愿我有朝一日, 能够稍微理解一下这门语言

相关推荐