美文网首页
Centos8 启动httpd服务

Centos8 启动httpd服务

作者: 陈有朴 | 来源:发表于2022-03-04 23:02 被阅读0次

    今天想着是要重新配置一下我的Centos8虚拟机,目的是为了以后搭自己的博客有一个站点,同时在自己电脑上使劲造,也不用怕学校服务器出事怪到我头上。

    于是就开始了下面这一步:

    # 启动httpd服务
    systemctl start httpd.service
    

    运行上述命令的时候,会出现如下报错

    Failed to start httpd.service: Unit httpd.service not found.
    

    然后,就想着用yum安装httpd,然而。。。

    yum install httpd -y
    # 报错信息如下:
    CentOS Linux 8 - AppStream                                                                                   0.0  B/s |   0  B     01:27    
    Errors during downloading metadata for repository 'appstream':
      - Curl error (7): Couldn't connect to server for http://vault.centos.org/centos/8/AppStream/x86_64/os/repodata/repomd.xml [Failed to connect to vault.centos.org port 80: Connection refused]
    Error: Failed to download metadata for repo 'appstream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
    

    再后续,就在看这个博客了:

    centos8重新配置yum源(Errors during downloading metadata for repository ‘AppStream‘)

    我也去阿里云社区凑凑热闹,发现Centos 8以后就停止维护了,如下:

    image.png

    但是现在还是将就着用吧(毕竟维护啥的,我又不是开发人员)

    cd /etc/yum.repos.d/
    # 查看已存在的repo
    ls -l 
    
    # 备份原有repo
    mkdir bakup
    mv *repo bakup/
    
    # 下载最近repo
    wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
    # 查看下载的repo
    ll
    # [train@Centos8(4.4) /etc/yum.repos.d]$ ls -lh
    # total 8.0K
    # drwxr-xr-x. 2 root root 4.0K Mar  4 22:19 bakup
    # -rw-r--r--. 1 root root 2.5K Feb 14 21:16 CentOS-Base.repo
    
    # 运行 yum makecache 生成缓存
    yum makecache
    # CentOS-8.5.2111 - Base - mirrors.aliyun.com                                                                  1.5 MB/s | 4.6 MB     00:03    
    # CentOS-8.5.2111 - Extras - mirrors.aliyun.com                                                                 63 kB/s |  10 kB     00:00    
    # CentOS-8.5.2111 - AppStream - mirrors.aliyun.com                                                             271 kB/s | 8.4 MB     00:31    
    # Last metadata expiration check: 0:00:01 ago on Fri 04 Mar 2022 10:20:24 PM CST.
    # Metadata cache created.
    

    现在就可以正常使用yum命令了

    sudo yum install httpd
    # 启用网站服务
    systemctl start httpd.service                
    # 设置服务开机启动
    systemctl enable httpd.service 
    

    参考资料

    [1] https://blog.csdn.net/wt334502157/article/details/123189000
    [2] https://developer.aliyun.com/article/823269?spm=a2c6h.14164896.0.0.1e67ebe7vUbSFZ

    相关文章

      网友评论

          本文标题:Centos8 启动httpd服务

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