1.安装httpd服务
yum install httpd -y
yum install httpd-manual -y
systemctl start httpd
systemctl enable httpd
ss -antlp |grep httpd ##查看监听端口
2.配置apache
/etc/httpd/conf/httpd.conf ##apache主配置文件
ServerRoot "/etc/httpd" ##用于指定Apache的运行目录
Listen 80 ##监听端口
User apache ##运行apache程序的用户和组
Group apache
DocumentRoot "/var/www/html" ##网页文件的存放目录
<Directory "/var/www/html"> <Directory>语句块自定义目录权限
Require all granted
</Directory>
ErrorLog "logs/error_log" ##错误日志存放位置
AddDefaultCharset UTF-8 ##默认支持的语言
IncludeOptional conf.d/*.conf ##加载其它配置文件
DirectoryIndex index.html ##默认主页名称
3.虚拟主机
虚拟主机允许从一个httpd服务器同时为多个网站提供服务。
[root@server4 ~]# cd /etc/httpd/conf.d/
[root@server4 conf.d]# vim default.con