1.下载安装并启动Apache
[root@xiaolu conf]# yum install -y httpd #yum 安装
[root@xiaolu conf]# systemctl start httpd #使用systemctl命令启动Apche
Job for httpd.service failed because the control process exited with error code.
See “systemctl status httpd.service” and “journalctl -xe” for details.
#注意这里报错,httpd启动失败,我们使用lsof命令查看一下Apache服务的默认端口80
[root@xiaolu conf]# lsof -i:80 #lsof是一个列出当前系统打开文件的工具,-i选项列出符合条件的进程,-i用法:在i后接4、6、协议、:端口、 @ip
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 1083 root 8u IPv4 27484 0t0 TCP *:http (LISTEN)
nginx 1085 nobody 8u IPv4 27484 0t0 TCP *:http (LISTEN)
#分析:可以看到80端口被nginx服务占用了
[root@xiaolu conf]# systemctl stop nginx.service #关闭nginx服务
[root@xiaolu conf]# lsof -i:80 #回车无其他显示证明无任何服务进程占用80端口
[root@xiaolu conf]# systemctl start httpd #开启Apache服务
[root@xiaolu conf]# systemctl status httpd #开启查看Apache服务状态,显示active运行成功
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2021-04-16 20:33:39 CST; 3min 21s ago
2.在浏览器上查看Apache服务
首先打开浏览器,输入http://IP地址,UP主的地址是172.16.70.10,所以输入的是http://172.16.70.10 ,回车后效果如下图所示:
3.制作Apache网页
[root@xiaolu conf]# cd /var/www/html #切换到Apache的主目录
[root@xiaolu html]# vi index.html #创建并编辑一个名为index.html的文件
[root@xiaolu html]# cat index.html #查看文件内容
www.jane.com
[root@xiaolu html]# systemctl restart httpd #重启Apache服务
[root@xiaolu html]# curl 172.16.70.10 #通过curl命令查看网页内容
www.jane.com
补充:curl命令是一个利用URL规则在命令行下工作的文件传输工具。它支持文件的上传和下载,所以是综合传输工具,但按传统,习惯称curl为下载工具。
#同样也可以在浏览器输入你的IP地址,进行查看