基于http搭建网站 firewall&selinux开启

1.要求搭建web服务器通过端口8909能够访问到网页内容为“小胖,你咋这么胖呢!”
2.建立httpd服务器,要求:
提供两个基于名称的虚拟主机:
(a)www1.stuX.com,页面文件目录为/web/vhosts/www1;错误日志为/var/log/httpd/www1.err,访问日志为/var/log/httpd/www1.access;
(b)www2.stuX.com,页面文件目录为/web/vhosts/www2;错误日志为/var/log/httpd/www2.err,访问日志为/var/log/httpd/www2.access;
©为两个虚拟主机建立各自的主页文件index.html,内容分别为其对应的主机名;

注意:要求防火墙启用,SELinux开启
配置一:
1.配置本地安装光盘为安装源
[root@kaikai~]# mount /dev/sr0 /mnt
2、安装web软件
[root@kaikai ~]# yum install httpd -y
3、启动服务
[root@kaikai ~]# systemctl enable --now httpd
4、防火墙和selinux设置
在这里插入图片描述
在这里插入图片描述

5.创建目录编辑网页内容,编辑子配置文件
[root@kaikai ~]# mkdir /aaa
[root@kaikai ~]# echo “小胖,你咋这么胖呢?” > /aaa/index.html
在这里插入图片描述
6.重启服务测试
[root@kaikai ~]# systemctl restart httpd
客户端测试:在这里插入图片描述
配置二:
1、增加一个ip地址
[root@kaikai ~]# nmcli connection modify eno16777736 +ipv4.address 192.168.233.141/24
[root@kaikai ~]# nmcli connection up eno16777736
[root@kaikai ~]# nmcli con reload
2、创建网页目录结构
[root@kaikai html]# mkdir /web/vhosts/www{1,2} -p
3、虚拟主机网页
[root@kaikai html]# echo www1 > /web/vhosts/www1/index.html
[root@kaikai html]# echo www2 > /web/vhosts/www2/index.html
4、编辑子配置文件
[root@kaikai ~]# vim /etc/httpd/conf.d/vhosts.conf
在这里插入图片描述
5.防火墙和selinux,重启服务
[root@kaikai html]# chcon -R -t httpd_sys_content_t /web
[root@kaikai html]# systemctl restart httpd
6==.客户端添加域名解析==
在这里插入图片描述
7.测试在这里插入图片描述

发布了47 篇原创文章 · 获赞 11 · 访问量 2199

猜你喜欢

转载自blog.csdn.net/qq_45630589/article/details/104463947