搭建http服务

1.默认http访问界面

关闭防火墙

[root@catyuan ~]# systemctl stop firewalld.service 

关闭selinux

[root@catyuan ~]# setenforce 0

挂载

[root@catyuan ~]# mount /dev/sr0 /mnt
mount: /dev/sr0 is write-protected, mounting read-only

编辑yum源

[root@catyuan ~]# vim /etc/yum.repos.d/base.repo

[base]
name=base
baseurl=file:///mnt
enable=1
gpgcheck=0

安装httpd包

[root@catyuan ~]# yum install httpd -y

......直到出现
Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7         apr-util.x86_64 0:1.5.2-6.el7         httpd-tools.x86_64 0:2.4.6-67.el7        

Complete!

启动http服务

[root@catyuan ~]# systemctl start httpd

此时查看http服务的状态,报错

Mar 19 00:12:15 catyuan.localdomain httpd[42291]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using catyuan.localdomain. Set the 'ServerName' directive globally to suppress this message
无法可靠地确定服务器的完全限定域名。

在/etc/httpd/conf/httpd.conf文件中修改第95行, 去掉注释ServerName www.example.com:80

[root@catyuan ~]# vim /etc/httpd/conf/httpd.conf 

进入配置文件后 :set nu显示行号
 第95行:ServerName 0.0.0.0:80

重启http服务

[root@catyuan ~]# systemctl restart httpd.service 

浏览器中输入IP地址,显示如下界面,则表示安装成功
在这里插入图片描述

2http访问静态页面

http默认的网站根目录是/var/www/html/,使用echo命令写入内容

[root@catyuan ~]# echo this is test >  /var/www/html/index.html

此时刷新浏览器

在这里插入图片描述

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值