- 安装httpd
yum install -y httpd
- 检查是否已经安装:
Rpm -qa | grep httpd
配置文件在/etc/httpd/conf中,为httpd.Conf
Cd /etc/httpd/conf
Mv httpd.conf httpd.conf.bak
Grep -v ‘#’ httpd.conf.bak >httpd.conf
Vim httpd.conf
默认无需做任何修改
- 默认网站目录为/var/www/html
进入该目录
Cd /var/www/html
- 创建index.html文件并编辑
Touch index.html
Vim index.html
- 写入以下内容(不写这个也行,反正要写个html):
<html>
<head>
<title>这里是标题</title>
</head>
<body>
<p><center>这里是正文区域</center></p>
</body>
</html>
- 启动httpd服务
Systemctl start httpd
curl http://该机器ip
- 能正常显示以上html文件内容,表示web服务已经正常运行
如果不能正常显示,则需要关闭selinux
setenforce 0
再次在外部浏览器中,访问网站,发现已经好了