CentOS7 最小化安装后,安装配置并启动httpd的步骤
来源:互联网 发布:ptc三维软件 编辑:程序博客网 时间:2024/06/07 00:07
记录供查阅
1 安装httpd软件包
yum install httpd
针对CentOS7,httpd有专门的版本,此版本提供了针对systemd的单元文件,如下所示
-bash-4.2# rpm -ql httpd | grep service
/usr/lib/systemd/system/htcacheclean.service
/usr/lib/systemd/system/httpd.service
2 启动httpd服务并把此服务单元加入当前运行级
systemctl start httpd.service
systemctl enable httpd
此时,这个配置文件被链接到了/etc/systemd/system/multi-user.target.wants/httpd.service,如下图
-bash-4.2# ll /etc/systemd/system/multi-user.target.wants/
total 0
lrwxrwxrwx. 1 root root 38 Sep 16 19:08 auditd.service -> /usr/lib/systemd/system/auditd.service
lrwxrwxrwx. 1 root root 44 Sep 16 19:08 avahi-daemon.service -> /usr/lib/systemd/system/avahi-daemon.service
lrwxrwxrwx. 1 root root 37 Sep 16 19:08 crond.service -> /usr/lib/systemd/system/crond.service
lrwxrwxrwx. 1 root root 37 Sep 17 02:38 httpd.service -> /usr/lib/systemd/system/httpd.service
lrwxrwxrwx. 1 root root 42 Sep 16 19:08 irqbalance.service -> /usr/lib/systemd/system/irqbalance.service
lrwxrwxrwx. 1 root root 37 Sep 16 19:08 kdump.service -> /usr/lib/systemd/system/kdump.service
lrwxrwxrwx. 1 root root 46 Sep 16 19:08 NetworkManager.service -> /usr/lib/systemd/system/NetworkManager.service
lrwxrwxrwx. 1 root root 39 Sep 16 19:08 postfix.service -> /usr/lib/systemd/system/postfix.service
lrwxrwxrwx. 1 root root 40 Sep 16 19:08 remote-fs.target -> /usr/lib/systemd/system/remote-fs.target
lrwxrwxrwx. 1 root root 39 Sep 16 19:08 rsyslog.service -> /usr/lib/systemd/system/rsyslog.service
lrwxrwxrwx. 1 root root 36 Sep 16 19:08 sshd.service -> /usr/lib/systemd/system/sshd.service
lrwxrwxrwx. 1 root root 37 Sep 16 19:08 tuned.service -> /usr/lib/systemd/system/tuned.service
3 打开firewalld防火墙的80端口
firewall-cmd --add-service=http (即时打开)
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 other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
<service name="dhcpv6-client"/>
<service name="http"/>
<service name="ssh"/>
<service name="https"/>
</zone>
注意不要将此处firewalld管理的service与systemd中的sevice配置单元混淆,两者没有任何关系。
http服务是安装firewalld时自动安装的,这个服务的配置文件为 /usr/lib/firewalld/services/http.xml,我们来看看这个文件。
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>WWW (HTTP)</short>
<description>HTTP is the protocol used to serve Web pages. If you plan to make your Web server publicly available, enable this option. This option is not required for viewing pages locally or developing Web pages.</description>
<port protocol="tcp" port="80"/>
</service>
据此知道http服务对应的就是tcp协议的80端口。firewalld根据zone配置文件中的服务名http,依次在/etc/firwalld/services/目录,/usr/lib/firewalld/services/目录查找名为http.xml的文件,找到即停止继续查找,所以位于/etc/firwalld/services/目录的配置文件优先级更高。
4 与CentOS6.5的区别
总体思路是一致的,都是防火墙放行,把服务加入运行级配置文件。只是CentOS7中防火墙和运行级管理程序均发生彻底改变了。firewalld代替iptables,systemd代替SystemV init,所以需要重新熟悉相关命令。个人感觉新的程序更加人性化,操作也很容易。 配置文件也都采用了标准的xml格式,放弃了容易出错的老式配置文件。
- CentOS7 最小化安装后,安装配置并启动httpd的步骤
- centos7 最小化安装后配置
- CentOS7 最小化安装后,安装配置NFS
- CentOS7 最小化安装后,安装配置NFS
- CentOS7最小化安装配置
- 虚拟机最小化安装 Centos7 的网络配置
- centos7安装配置apache/httpd
- CentOS7 yum安装Apache(httpd)并实现多域名配置
- CentOS7 最小化安装完配置
- CentOS7最小化安装后,安装图形界面
- 网络版最小化安装Debian后的配置
- 网络版最小化安装Debian后的配置
- 最小化安装debian后的配置
- 最小化安装centos6后的一些配置
- 最小化安装Centos7后的部署(个人)
- CentOS7 最小化安装后无法联网
- CentOS7最小化安装后搭建LAMP环境
- centos7 最小化安装后再装上界面
- poj 3923 模拟
- java软件开发技术面试2015---持续更新中。。。
- div style常用属性
- matlab中size的简单使用
- Cocos2d-x 3.0正式版及android环境搭建详细教程
- CentOS7 最小化安装后,安装配置并启动httpd的步骤
- Android JNI开发环境搭建
- Debian Linux下如何以root账号登录桌面
- 求二维整数数组中最长的递减数字串(滑雪算法)
- VS Release下单步调试设置
- 删除本地文件
- [MonoDevelop]Unity3d MonoDevelop格式化代码
- Linux全称
- POJ 3422 Kaka's Matrix Travels (最小费用最大流)