用linux配置web服务器

一、要求:

基于httpd的web服务器

1、配置软件仓库并安装软件
2、修改配置文件
3、停止防火墙
4、自定义页面并启动服务
5、通过Windows系统的浏览器访问

二、解答

1、配置软件仓库并安装软件

1、系统需要先创建好仓库,有了仓库再下载并安装包

[root@localhost ~]# cd /etc/yum.repos.d/

[root@localhost yum.repos.d]# vim baser.repo

[baseos]
name=baseos
baseurl=/mnt/BaseOS
gpgcheck=0
[appstream]
name=appTream
baseurl=/mnt/AppStream
gpgcheck=0

参考文章链接:https://www.cnblogs.com/galsnag/p/13896354.htm

2、系统有IP 可以通过dhclient获取 ; ifconfig查询

在这里插入图片描述

3、系统里面已经安装好了Vim ;如果没有,可以通过以下命令下载

 mount /dev/sr0 /mnt	先挂载
yum install vim -y   	下载
或dnf install vim -y   	下载

4、修改配置文件

[root@localhost yum.repos.d]# vim /etc/httpd/conf/httpd.conf

	(复制并更改代码,一般在98行:ServerName 0.0.0.0:80)

在这里插入图片描述

5、启动服务器,停止防火墙

systemctl start httpd		启动服务器

systemctl stop firewalld	停止防火墙

([root@localhost yum.repos.d]# systemctl status httpd	查看状态)

如果服务器启动成功,通过本地浏览器输入虚拟机ip地址查看会显示当前操作系统的一个测试页面
在这里插入图片描述

6、自定义页面并启动服务

echo welcome > /var/www/html/index.html
	上面的“welcome”为自己在网页写入的内容

在这里插入图片描述

Guess you like

Origin blog.csdn.net/weixin_53002381/article/details/120891203