当前位置: 首页 > ds >正文

http网页部署

Web服务:http网页部署

虚拟主机:
为了实现多站点部署

部署虚拟主机的3种方式
相同ip,不同的端口
不同ip,相同端口
相同ip,相同端口,不同FQDN

一、简单的http网站部署
http服务器:主机2:
(1)配置yum仓库,安装http服务
[root@stw2 ~]# cd /etc/yum.repos.d/
[root@stw2 yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
[root@stw2 yum.repos.d]# rm -rf *
[root@stw2 yum.repos.d]# vim server.repo
[root@stw2 yum.repos.d]# mount /dev/cdrom /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@stw2 yum.repos.d]# yum -y install httpd
(2)重启服务,关闭防火墙,修改selinux
[root@stw2 ~]# systemctl restart httpd
[root@stw2 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@stw2 ~]# systemctl stop firewalld.service 
[root@stw2 ~]# systemctl disable firewalld.service 
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@stw2 ~]# setenforce 0
[root@stw2 ~]# 
客户端(主机3):

在这里插入图片描述

在这里插入图片描述

客户端:
[root@stw3 ~]# cd /etc/sysconfig/network-scripts/
[root@stw3 network-scripts]# vim ifcfg-ens33
[root@stw3 network-scripts]# systemctl restart network

在这里插入图片描述

DNS服务器端(主机1):已经配置了DNS服务,只用在正向解析中添加主机1的条目,使客户端能够访问
[root@stw ~]# cd /var/named
[root@stw named]# ls
chroot   data     named.ca     named.localhost  slaves
com.stw  dynamic  named.empty  named.loopback   stw.com
[root@stw named]# vim stw.com
[root@stw named]# systemctl restart named
[root@stw named]# systemctl enable named

在这里插入图片描述

客户端(主机3):

在这里插入图片描述

在这里插入图片描述

可以更改网页内容
http服务器端(主机2):
[root@stw2 ~]# cd /var/www/html
[root@stw2 html]# ls
[root@stw2 html]# echo "welcome to luoqi" > index.html
[root@stw2 html]# ls
index.html
[root@stw2 html]# cat index.html
welcome to luoqi
客户端(主机3)查看:

在这里插入图片描述

也可以更改网页内容的存放位置
[root@stw2 ~]# mkdir /html
[root@stw2 ~]# cd /html
[root@stw2 html]# echo stw > index.html
[root@stw2 html]# cat index.html
stw
[root@stw2 ~]# vim /etc/httpd/conf/httpd.conf 
[root@stw2 ~]# systemctl restart httpd

在这里插入图片描述

客户端查看:

在这里插入图片描述

先将配置文件恢复
[root@stw2 ~]# vim /etc/httpd/conf/httpd.conf 
[root@stw2 ~]# systemctl restart httpd

在这里插入图片描述

二、相同IP,不同端口

192.168.100.20:80

192.168.100.20:8080

例:

yyxq /var/www/yyqx/index.html---------yyqx

luoqi /var/www/luoqi/index,html--------luoqi

服务器端:
[root@stw2 ~]# cd /var/www      //先到/var/www的目录下创建两个需要的目录
[root@stw2 www]# ls
cgi-bin  html
[root@stw2 www]# mkdir yyqx
[root@stw2 www]# mkdir luoqi
[root@stw2 www]# echo yyqx > yyqx/index.html    //将文件内容存放进去
[root@stw2 www]# echo luoqi > luoqi/index.html
[root@stw2 www]# cd /etc/httpd/conf           //这个目录下没有虚拟主机的配置文件
[root@stw2 conf]# ls
httpd.conf  magic
[root@stw2 conf]# cd /etc/httpd/ 
[root@stw2 httpd]# ls
conf  conf.d  conf.modules.d  logs  modules  run
[root@stw2 httpd]# cd conf.d          //虚拟主机的配置文件存放路径/etc/httpd/conf.d
[root@stw2 conf.d]# ls
autoindex.conf  README  userdir.conf  welcome.conf
[root@stw2 conf.d]# find / -name *vhost*.conf
/usr/share/doc/httpd-2.4.6/httpd-vhosts.conf
[root@stw2 conf.d]# cd
[root@stw2 ~]# cp -p /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d
//将虚拟主机的配置文件内容复制到/etc/httpd/conf.d中
[root@stw2 ~]# cd /etc/httpd
[root@stw2 httpd]# ls
conf  conf.d  conf.modules.d  logs  modules  run
[root@stw2 httpd]# cd conf.d
[root@stw2 conf.d]# ls
autoindex.conf  httpd-vhosts.conf  README  userdir.conf  welcome.conf
[root@stw2 conf.d]# vim httpd-vhosts.conf 
[root@stw2 conf.d]# systemctl restart httpd
设置端口需要监听对应的端口,80端口在主配置文件中已经监听

在这里插入图片描述

客户端测试:

在这里插入图片描述

在这里插入图片描述

三、相同端口,不同的IP

192.168.100.20:80

192.168.100.200:80

服务器:
[root@stw2 ~]# cd /etc/sysconfig/network-scripts/
[root@stw2 network-scripts]# vim ifcfg-ens33
[root@stw2 network-scripts]# systemctl restart network

在这里插入图片描述

在这里插入图片描述

[root@stw2 ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf 

在这里插入图片描述

客户端测试:

在这里插入图片描述

在这里插入图片描述

四、相同的IP和端口,不同的FQDN

192.168.100.20----80----yyqx.example.com-----yyqx(内容)

192.168.100.20----80----lq.example.com-------luoqi(内容)

先在DNS服务器(主机1)中将两个FQDN加入到正向解析
[root@stw named]# vim stw.com
[root@stw named]# systemctl restart named

在这里插入图片描述

客户端:能够解析得到这两个FQDN的地址
[root@stw3 ~]# nslookup
> yyqx.example.com
Server:		192.168.100.10
Address:	192.168.100.10#53Name:	yyqx.example.com
Address: 192.168.100.20
> lq.example.com
Server:		192.168.100.10
Address:	192.168.100.10#53Name:	lq.example.com
Address: 192.168.100.20
> 
http服务器中更改配置文件
[root@stw2 ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf 
[root@stw2 ~]# systemctl restart httpd

在这里插入图片描述

客户端测试:

在这里插入图片描述

在这里插入图片描述

http://www.xdnf.cn/news/17844.html

相关文章:

  • 【从零开始java学习|第四篇】IntelliJ IDEA 入门指南
  • C++方向知识汇总(四)
  • Ansible 自动化介绍
  • 如何在idea中导入外来文件
  • 基于大数据的在线教育评估系统 Python+Django+Vue.js
  • C++中template、 implicit 、explicit关键字详解
  • Rust 项目编译故障排查:从 ‘onnxruntime‘ 链接失败到 ‘#![feature]‘ 工具链不兼容错误
  • Rust:构造函数 new() 如何进行错误处理?
  • Xshell远程连接Ubuntu 24.04.2 LTS虚拟机
  • HCIP项目之OSPF综合实验
  • [Robotics_py] 路径规划算法 | 启发式函数 | A*算法
  • Linux系统编程Day13 -- 程序地址空间
  • git config的配置全局或局部仓库的参数: local, global, system
  • MaxKB+合合信息TextIn:通过API实现PDF扫描件的文档审核
  • 如何构建PHP表单页面及验证相关原理(PHP基础)
  • 自动驾驶决策算法 —— 有限状态机 FSM
  • Android 引导式访问(屏幕固定 Screen Pinning)完整指南
  • Fluent Bit 日志合并正则表达式(上)
  • Docker守护进程安全加固在香港VPS环境的操作标准
  • n8n、Workflow实战
  • PyCharm Community 2024.2.3.exe 安装教程(详细步骤,附安装包下载)
  • 2-1〔O҉S҉C҉P҉ ◈ 研记〕❘ 漏洞扫描▸理论基础与NSE脚本
  • 《飞算JavaAI:新一代智能编码引擎,革新Java研发范式》
  • python3.10.6+flask+sqlite开发一个越南留学中国网站的流程与文件组织结构说明
  • 微调入门:为什么微调
  • LeetCode 分割回文串
  • MySQL-单表查询
  • GitHub的简单使用方法----(5)
  • C++联合体的定义
  • 春日花园动画