基于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.配置本地安装光盘为安装源
[[email protected]~]# mount /dev/sr0 /mnt
2、安装web软件
[[email protected] ~]# yum install httpd -y
3、启动服务
[[email protected] ~]# systemctl enable --now httpd
4、防火墙和selinux设置
基于http搭建网站 firewall&selinux开启
基于http搭建网站 firewall&selinux开启

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