使用yum安装httpd服务时出现错误

[root@2022 ~]# yum install httpd
已加载插件:langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
file:///medir/cdrom/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /medir/cdrom/repodata/repomd.xml"
正在尝试其它镜像。


 One of the configured repositories failed (rhe17),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:

            yum-config-manager --disable rhe17

     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=rhe17.skip_if_unavailable=true

failure: repodata/repomd.xml from rhe17: [Errno 256] No more mirrors to try.
file:///medir/cdrom/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /medir/cdrom/repodata/repomd.xml"

原因是我们还没有配置Yum软件仓库,所以我们需要配置

步骤:

1.进入到/etc/yum.repos.d/目录(该目录存放着Yum软件仓库的配置文件)

2.使用vim编辑器创建一个名为rhe17.repo的新配置文件(文件名称可随便,但后缀必须为.repo)

root@2022 ~]# cd /etc/yum.repos.d/
[root@2022 yum.repos.d]# vim rhe17.repo

[rhe17]
name=rhe17
baseurl=file:///media/cdrom
enabled=1
gpgcheck=0
~                                                                                      
~                                                                                      
~                                                                                      
~                                                                                      
~                                                                                      
~                                                                                      
~                                                                                      
~                                                                                      
~              

3.把光盘设备的系统镜像挂载到/media/cdrom目录

[root@2022~]# mkdir -p /media/cdrom
[root@2022 ~]# mount /dev/cdrom /media/cdrom
mount: /dev/sr0 写保护,将以只读方式挂载

4.动手安装Apache服务程序。注意,使用yum命令进行安装时,跟在命令后面的Apache服务的软件包名称为httpd。如果直接执行yum install apache命令,则系统会报错

yum install httpd
已加载插件:langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhe17                                                           | 4.1 kB  00:00:00     
(1/2): rhe17/group_gz                                           | 134 kB  00:00:00     
(2/2): rhe17/primary_db                                         | 3.4 MB  00:00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-17.el7 将被 安装
--> 正在处理依赖关系 httpd-tools = 2.4.6-17.el7,它被软件包 httpd-2.4.6-17.el7.x86_64 需要
--> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-17.el7.x86_64 需要
--> 正在处理依赖关系 libapr-1.so.0()(64bit),它被软件包 httpd-2.4.6-17.el7.x86_64 需要
--> 正在处理依赖关系 libaprutil-1.so.0()(64bit),它被软件包 httpd-2.4.6-17.el7.x86_64 需要
--> 正在检查事务
---> 软件包 apr.x86_64.0.1.4.8-3.el7 将被 安装
---> 软件包 apr-util.x86_64.0.1.5.2-6.el7 将被 安装
---> 软件包 httpd-tools.x86_64.0.2.4.6-17.el7 将被 安装
——----------忽略部分信息-------
作为依赖被安装:
  apr.x86_64 0:1.4.8-3.el7                     apr-util.x86_64 0:1.5.2-6.el7           
  httpd-tools.x86_64 0:2.4.6-17.el7            mailcap.noarch 0:2.1.41-2.el7           

完毕!

5.启用httpd服务程序并将其加入到开机启动项中,使其能够随系统开机而运行,从而持续为用户提供web服务

[root@2022 ~]# systemctl start httpd
[root@2022 ~]# systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'

6.大家可以使用浏览器(以firefox浏览器为例)的地址栏输入本机127.0.0.1,就可以看到用于提供web服务程序的默认界面

 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐