CentOS 7安装httpd服务
2017-05-25 22:49
127 查看
书写此博文的前提:在学习[b]CentOS 7中,发现在安装httpd服务的时候,老是报错,不和CentOS 6的命令相同,在网上查了很多资料以后,找到一个很好的解决办法,发表出来,大家共同学习。[/b]1、安装httpd软件包查看是否安装httpd服务 [root@localhost ~]rpm –qa | grep http如果没有安装[root@localhost ~] yum –y install httpd(或者通过yum search httpd选择安装的httpd版本) 针对CentOS7,httpd有专门的版本,此版本提供了针对systemd的单元文件,如下所示 [root@localhost ~]rpm -ql httpd | grep service
/usr/lib/systemd/system/htcacheclean.service
/usr/lib/systemd/system/httpd.service
[b]在自己安装httpd以后,使用systemctl status httpd.service命令,会发现如下问题,httpd服务未打开:[/b][b]
[/b]这是解决途径: 2、启动httpd服务并把此服务单元加入当前运行级亲测在CentOS7中,必须把服务加入服务单元中,否则无法正常访问,在加入防火墙中,还是最好加入。[root@localhost ~]systemctl start httpd.service #开启httpd服务[root@localhost ~]systemctl enable httpd 此时,这个配置文件被链接到了/etc/systemd/system/multi-user.target.wants/httpd.service,如下图
[root@localhost ~] # ll /etc/systemd/system/multi-user.target.wants/
显示httpd服务已加入 3、打开firewalld防火墙的80端口[root@localhost ~]firewall-cmd--add-service=http (即时打开)[root@localhost ~]firewall-cmd --permanent --add-service=http (写入配置文件)
此时,httpd这个服务添加到了/etc/firewalld/zones/public.xml这个zone配置文件中,所以firewalld才能够据此放行。此文件如下所示:<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas. You do not trust the othercomputers on networks to not harm your computer. Only selected incomingconnections are accepted.</description>
<service name="dhcpv6-client"/>
<service name="http"/>
<servicename="ssh"/>
<service name="https"/>
</zone>经过这么几步的操作,再使用systemctl status httpd.service命令
此时用浏览器就能顺利打开网址
再次感谢http://blog.csdn.net/smstong/article/details/39343543的博文作者smstong。
/usr/lib/systemd/system/htcacheclean.service
/usr/lib/systemd/system/httpd.service
[b]在自己安装httpd以后,使用systemctl status httpd.service命令,会发现如下问题,httpd服务未打开:[/b][b]
[/b]这是解决途径: 2、启动httpd服务并把此服务单元加入当前运行级亲测在CentOS7中,必须把服务加入服务单元中,否则无法正常访问,在加入防火墙中,还是最好加入。[root@localhost ~]systemctl start httpd.service #开启httpd服务[root@localhost ~]systemctl enable httpd 此时,这个配置文件被链接到了/etc/systemd/system/multi-user.target.wants/httpd.service,如下图
[root@localhost ~] # ll /etc/systemd/system/multi-user.target.wants/
显示httpd服务已加入 3、打开firewalld防火墙的80端口[root@localhost ~]firewall-cmd--add-service=http (即时打开)[root@localhost ~]firewall-cmd --permanent --add-service=http (写入配置文件)
此时,httpd这个服务添加到了/etc/firewalld/zones/public.xml这个zone配置文件中,所以firewalld才能够据此放行。此文件如下所示:<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas. You do not trust the othercomputers on networks to not harm your computer. Only selected incomingconnections are accepted.</description>
<service name="dhcpv6-client"/>
<service name="http"/>
<servicename="ssh"/>
<service name="https"/>
</zone>经过这么几步的操作,再使用systemctl status httpd.service命令
此时用浏览器就能顺利打开网址
再次感谢http://blog.csdn.net/smstong/article/details/39343543的博文作者smstong。
相关文章推荐
- centos6.4下安装apache的httpd服务
- centos 7 安装卸载apache(httpd)服务
- Linux(CentOS)系统下安装好apache(httpd)服务后,其他电脑无法访问的原因
- CentOS 7源码安装httpd服务
- Linux(CentOS)系统下安装好apache(httpd)服务后,其他电脑无法访问的原因
- centos httpd服务做yum本地源,以及安装Mysql
- centos 7 安装 apache http 服务 httpd 和 php
- Linux(CentOS)系统下安装好apache(httpd)服务后,其他电脑无法访问的原因
- centos环境下下httpd服务基于源码的安装
- [shell]CentOS 5.6安装web服务及相关软件(php 5.3, MySQL Server, memcache, spawn-fcgi, nginx, coreseek)
- CentOS LAMP 安装 配置 httpd 2.4 Mysql 5.5
- Centos下telnet服务的安装
- centos 6.2 ubuntu 12.04 上安装apache(httpd2.4) nginx1.2 php5.3.10 mysql5.3
- CentOS 5.5安装与配置mail服务-Postfix
- Centos-Server-Mysql服务(Cmake编译安装)--(一)
- CentOS 中安装rstatd服务
- centos 系统安装各种服务(八) —— Sun JDK / Tomcat
- 将httpd加入centos的系统服务
- CentOS 5.2 安装httpd(Apache)服务器后无法访问解决方法
- 01_Linux 安装 httpd-2.2.21 Apache服务