在命令行中输入:
yum install httpd
会得到类似如下输出:
[root@localhost ~]# yum install httpd 已加载插件:fastestmirror base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 extras/7/x86_64/primary_db | 191 kB 00:00:01 Determining fastest mirrors * base: mirror.bit.edu.cn * extras: centos.ustc.edu.cn * updates: mirror.bit.edu.cn 正在解决依赖关系 --> 正在检查事务 ---> 软件包 httpd.x86_64.0.2.4.6-45.el7.centos.4 将被 安装 --> 正在处理依赖关系 httpd-tools = 2.4.6-45.el7.centos.4,它被软件包 httpd-2.4.6-45.el7.centos.4.x86_64 需要 --> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-45.el7.centos.4.x86_64 需要 --> 正在处理依赖关系 libaprutil-1.so.0()(64bit),它被软件包 httpd-2.4.6-45.el7.centos.4.x86_64 需要 --> 正在处理依赖关系 libapr-1.so.0()(64bit),它被软件包 httpd-2.4.6-45.el7.centos.4.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-45.el7.centos.4 将被 安装 ---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决 ======================================================================================================== Package 架构 版本 源 大小 ======================================================================================================== 正在安装: httpd x86_64 2.4.6-45.el7.centos.4 updates 2.7 M 为依赖而安装: apr x86_64 1.4.8-3.el7 base 103 k apr-util x86_64 1.5.2-6.el7 base 92 k httpd-tools x86_64 2.4.6-45.el7.centos.4 updates 84 k mailcap noarch 2.1.41-2.el7 base 31 k 事务概要 ======================================================================================================== 安装 1 软件包 (+4 依赖软件包) 总下载量:3.0 M 安装大小:10 M Is this ok [y/d/N]: y Downloading packages: (1/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:06 (2/5): apr-1.4.8-3.el7.x86_64.rpm | 103 kB 00:00:07 (3/5): httpd-tools-2.4.6-45.el7.centos.4.x86_64.rpm | 84 kB 00:00:06 (4/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:01 (5/5): httpd-2.4.6-45.el7.centos.4.x86_64.rpm | 2.7 MB 00:00:42 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 总计 72 kB/s | 3.0 MB 00:00:42 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : apr-1.4.8-3.el7.x86_64 1/5 正在安装 : apr-util-1.5.2-6.el7.x86_64 2/5 正在安装 : httpd-tools-2.4.6-45.el7.centos.4.x86_64 3/5 正在安装 : mailcap-2.1.41-2.el7.noarch 4/5 正在安装 : httpd-2.4.6-45.el7.centos.4.x86_64 5/5 验证中 : httpd-tools-2.4.6-45.el7.centos.4.x86_64 1/5 验证中 : mailcap-2.1.41-2.el7.noarch 2/5 验证中 : apr-1.4.8-3.el7.x86_64 3/5 验证中 : httpd-2.4.6-45.el7.centos.4.x86_64 4/5 验证中 : apr-util-1.5.2-6.el7.x86_64 5/5 已安装: httpd.x86_64 0:2.4.6-45.el7.centos.4 作为依赖被安装: 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-45.el7.centos.4 mailcap.noarch 0:2.1.41-2.el7 完毕! [root@localhost ~]#
Apache服务相关命令:
systemctl start httpd.service #启动apache systemctl stop httpd.service #停止apache systemctl restart httpd.service #重启apache systemctl enable httpd.service #设置apache开机启动
启动Apache后,打开防火墙端口:
firewall-cmd --permanent --add-port=80/tcp firewall-cmd --state
然后,在宿主机中浏览器里输入虚拟网卡的IP地址:
http://192.168.56.1
看到如下输出,说明Apache服务启动成功:
原文链接:https://www.f2er.com/centos/376035.html