CentOS7中apache的部署与配置

一、apache的部署

输入命令

yum list | grep httpd

查看可安装的软件包,选择“httpd.x86_64”安装。

输入命令

yum install httpd

二、apache文件目录简介

描述 文件/目录
服务目录 /etc/httpd
配置文件 /etc/httpd/conf/httpd.conf
网站数据目录 /var/www/html
访问日志 /var/log/httpd/access_log
错误日志 /var/log/httpd/error_log

/etc/httpd/conf/httpd.conf配置简介

CustomLog      访问日志文件
ServerRoot     服务目录
ServerAdmin    管理员邮箱
User           运行服务的用户
Group          运行服务的用户组
ServerName     网站服务器的域名
DocumentRoot   网站数据目录
Listen         监听的IP地址与端口号
DirectoryIndex 默认的索引页页面
ErrorLog       错误日志文件
CustomLog      访问日志文件
Timeout        网页超时时间,默认为300秒
Include        需要加载的其他文件

三、apache服务的启动和停止

1. 开放防火墙80端口

查看防火墙所有开放端口

firewall-cmd --zone=public --list-port

设置防火墙开放80端口,参数permanent表示永久有效

firewall-cmd --zone=public --add-port=80/tcp --permanent

重启防火墙

firewall-cmd reload

设置防火墙关闭80端口

firewall-cmd --zone=public --remove-port=80/tcp --permanent

2. 启动apache

查看apache运行状态

systemctl status httpd.service

启动apache

systemctl start httpd.service

重启apache

systemctl restart httpd.service

停止apache

systemctl stop httpd.service
原文地址:https://www.cnblogs.com/HanYG/p/14657922.html