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

【无标题】web+http协议+nginx搭建+nginx反向代理(环境准备)

一.Web

为用户提供互联网上浏览信息的服务,web服务是动态的,可交互的。

1.安装httpd

yum -y install httpd

2.启动

systemctl start httpd

3.关闭防火墙

systemctl stop firewalld

[root@rs html]# echo "我手机号是" > index.html

[root@rs html]# ls

index.html

4.在浏览器中输入ip地址进行访问

二.http协议

1.http特点:

静态文件和动态文件

生成一个大文件

dd if=/dev/zero of=/var/www/html/a.txt bs=30M count=1

2.UEI和URL的区别

http状态码:

三.Apache

最早的web服务,基于http提供浏览器浏览

1.查看华为云主机所有打开的端口

firewall-cmd --list-ports

2.在虚拟机上停用防火墙,远程主机就无法访问web服务

3.搭建apache服务器

(1)查看安装情况

[root@rs ~]# rpm -qa|grep httpd

(2)配置文件

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

启(3)启动http服务

[root@rs ~]# systemctl start httpd

(4)在浏览器访问

(5)在windows客户端scp一张图到/var/www/html下

[root@rs ~]# cd /var/www/html

[root@rs html]# mkdir img

[root@rs html]# vim /var/www/html/index.html

<!doctype html>

<html>

        <head>

                <meta charset="utf-8">

                <title>正方形</title>

                <style>

                        div{

                                background-color:red;

                                width:120px;

                                height:120px;

                        }

                </style>

        </head>

        <body>

                <div>正方形</div>

                <img src="img/000.jpg" />

        </body>

</html>

(6)在浏览器访问

四.Nginx

开源,轻量级,高性能的http和反向代理服务器

1.特点:占用内存少,并发能力强

2.作用:用来做负载均衡和反向代理

安装nginx

源码编译安装

3.下载源码包

[root@web ~]# wget https://nginx.org/download/nginx-1.26.1.tar.gz

4.解压

[root@web ~]# tar -zxvf nginx-1.26.1.tar.gz

[root@web ~]# yum -y install gcc gcc-c++

[root@web ~]# yum -y install openssl-devel

[root@web ~]# yum -y install pcre-devel

[root@web ~]# yum -y install make

5.编译安装nginx

[root@web nginx-1.26.1]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-stream

[root@web nginx-1.26.1]# make && make install

[root@web nginx-1.26.1]# useradd -s /bin/nologin -M nginx  //创建nginx用户和组不然无法启动

6.检查目录

[root@web nginx-1.26.1]# tree /usr/local/nginx/

7.启动nginx

[root@web nginx]# ./sbin/nginx

8.查看主要配置文件

vim /usr/local/nginx/conf/nginx.conf

9.优化nginx服务控制

[root@web nginx]# ln -s /usr/local/nginx/sbin/nginx /usr/bin/  //做一个软连接

[root@web nginx]# nginx

之所以指令能在命令行使用,是因为在$PATH目录中能找到这个可执行文件或者是可执行文件的链接文件

(1)修改配置文件后重载nginx服务

./nginx -s reload

(2)脚本启动nginx

[root@web nginx]# vim ~/nginx.sh

#!/bin/bash

/usr/local/sbin/nginx &> /dev/null

netstat -lnput|grep nginx

if [ $? -eq 0 ];then

    echo "nginx正在执行,或者80端口被占用"

fi

[root@web nginx]# source ~/nginx.sh

(3)以systemctl控制nginx

[root@web nginx]# ls /usr/lib/systemd/system

[root@web nginx]# vim /usr/lib/systemd/system/nginx.service

[Unit]
Description=nginx
After=network.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=Flase

[Install]
WantedBy=multi-user.target

[root@web nginx]# systemctl daemon-reload  //重置systemctl进程

如果使用sbin目录下的nginx,就无法使用systemctl

优化注意事项

10.开启nginx状态监听模块

(1)修改配置文件

[root@web ~]# vim /usr/local/nginx/conf/nginx.conf  //在48行添加

location /status {

            stub_status on;    #nginx状态的监听模块

            access_log off;

        }

(2)重启nginx

[root@web ~]# systemctl reload nginx

(3)在浏览器访问,查看nginx状态信息

192.168.2.35/status

11.nginx虚拟主机配置

⼀个“location”相当于⼀个虚拟主机,也就是⽤户访问⽹站时,

点击跳转的另⼀个⻚⾯。

location 内可以添加 nginx 各种功能模块。

配置多个虚拟主机

[root@server ~]# vim /usr/local/nginx/conf/nginx.conf

......省略部分内容......

server {

listen 80; #监听端⼝

server_name localhost;

charset utf-8;  #中文字符集

#access_log logs/host.access.log main;

location /status {

stub_status on;

access_log off;

}

location / {

root html; #⽹站在服务器上的⽬ 录,默认为/usr/local/nginx/html

index index.html index.htm; #跳转到的⽹站⾸⻚

}

}

......省略部分内容......

[root@server ~]# systemctl restart nginx.service

#重启nginx

12.nginx反向代理

再准备一台机器---tomcat 跟上面一样安装nginx编译并安装

[root@server ~]# wget https://nginx.org/download/nginx-1.26.1.tar.gz

解压

[root@server ~]# tar -zxvf nginx-1.26.1.tar.gz

[root@server ~]# yum -y install gcc gcc-c++

[root@server ~]# yum -y install openssl-devel

[root@server ~]# yum -y install pcre-devel

[root@server ~]# yum -y install make

编译安装nginx

[root@server nginx-1.26.1]# ./configure --prefix=/usr/local/nginx

[root@server nginx-1.26.1]# make && make install

[root@server nginx-1.26.1]# useradd -s /bin/nologin -M nginx

[root@server nginx-1.26.1]# echo "我是后端服务" > /usr/local/nginx/html/index.html

[root@server nginx-1.26.1]# firewall-cmd --zone=public --add-port=80/tcp --permanent //打开端口

success

[root@server nginx-1.26.1]# firewall-cmd --reload  //重新加载防火墙

Success

[root@server nginx-1.26.1]# vim /usr/local/nginx/conf/nginx.conf

[root@server nginx-1.26.1]# /usr/local/nginx/sbin/nginx

相关文章:

【无标题】web+http协议+nginx搭建+nginx反向代理(环境准备)

一&#xff0e;Web 为用户提供互联网上浏览信息的服务&#xff0c;web服务是动态的&#xff0c;可交互的。 1.安装httpd yum -y install httpd 2.启动 systemctl start httpd 3.关闭防火墙 systemctl stop firewalld [rootrs html]# echo "我手机号是" > …...

c-periphery RS485串口库文档serial.md(serial.h)(非阻塞读)(VMIN、VTIME)

c-peripheryhttps://github.com/vsergeev/c-periphery 文章目录 NAMESYNOPSISENUMERATIONS关于奇偶校验枚举类型 DESCRIPTIONserial_new()serial_open()关于流控制软件流控制&#xff08;XON/XOFF&#xff09;硬件流控制&#xff08;RTS/CTS&#xff09;选择流控制方法 serial_…...

Matlab arrayfun 与 bsxfun——提高编程效率的利器!

许多人知道 MATLAB 向量化编程&#xff0c;少用 for 循环 可以提高代码运行效率&#xff0c;但关于代码紧凑化编程&#xff0c; arrayfun 与 bsxfun 两个重要函数却鲜有人能够用好&#xff0c;今天针对这两个函数举例说明其威力。 Matlab arrayfun 概述 arrayfun 是 Matlab …...

【Unity编辑器拓展】GraphView自定义可视化节点

1、创建节点区域脚本 其中的new class UxmlFactory&#xff0c;可以让该元素显示在UI Builder中&#xff0c;我们就可以在Library-Project中看到我们新建的这两个UI元素&#xff0c;就可以拖入我们的UI窗口编辑了 public class NodeTreeViewer : GraphView {public new class…...

教程系列4 | 趋动云『社区项目』极速体验 LivePortrait 人脸表情“移花接木”大法

LivePortrait LivePortrait 由快手可灵大模型团队开源&#xff0c;只需 1 张原图就能生成动态视频。 LivePortrait 的核心优势在于其卓越的表情"迁移"技术&#xff0c;能够令静态图像中的人物瞬间焕发活力&#xff0c;无论是眨眼、微笑还是转头&#xff0c;皆栩栩如…...

WGS84、GCJ-02、BD09三大坐标系详解

文章目录 前言WGS84坐标系定义应用WGS84 Web 墨卡托投影 GCJ-02坐标系&#xff08;火星坐标系&#xff09;定义应用GCJ-02经纬度投影与Web墨卡托投影 BD09坐标系&#xff08;百度坐标系&#xff09;定义应用BD09经纬度投影与Web墨卡托投影 坐标系之间的区别与注意事项总结 前言…...

css上下动画 和淡化

.popup_hidden_bg { transition: opacity .5s ease-out; opacity: 0; pointer-events: none; /* 防止在隐藏时仍然能点击 */ } keyframes popupShop { from { transform: translateY(100%); opacity: 0; } to {transform: translateY(0);opacity: 1; }} keyframes popupHidd…...

深入解析C#中的URI和URL编码:理解EscapeDataString、EscapeUriString和UrlEncode的区别及字符编码错误处理

在C#中&#xff0c;处理URI&#xff08;统一资源标识符&#xff09;和URL&#xff08;统一资源定位符&#xff09;时&#xff0c;可以使用Uri.EscapeDataString、Uri.EscapeUriString和HttpUtility.UrlEncode&#xff08;或WebUtility.UrlEncode&#xff09;方法来编码字符串。…...

【CSS】给图片设置 max-width

.logo img{width:100%; /* 缩成父盒子的100% */max-width:100%; /* (谁小用谁的百分之百) *//* max-width:100%;【1】图片比盒子大&#xff0c;缩成父盒子的100%【2】图片比盒子小&#xff0c;图片自身的100%*/ }示例 设置样式 .el-image {width: 100%;max-width: 100%;max-…...

区块链——代码格式检查(prettier、solhint)

一、引入依赖 // 导入prettier prettier-plugin-solidity yarn add --dev prettier prettier-plugin-solidity yarn add --dev solhint二、创建.prettierrc文件 {"tabWidth": 2,"semi": false,"useTabs": false,"singleQuote": fals…...

搭建自动化 Web 页面性能检测系统 —— 部署篇

作为一个前端想去做全栈的项目时&#xff0c;可能第一个思路是 node vue/react。一开始可能会新建多个工程目录去实现&#xff0c;假设分别为 web 和 server&#xff0c;也许还有管理后台的代码 admin&#xff0c;那么就有了三个工程的代码。此时为了方便管理就需要在远程仓库…...

知识图谱增强的RAG(KG-RAG)详细解析

转自&#xff1a;知识图谱科技 这是一个与任务无关的框架&#xff0c;它将知识图谱&#xff08;KG&#xff09;的显性知识与大型语言模型&#xff08;LLM&#xff09;的隐含知识结合起来。这是该工作的arXiv预印本 https://arxiv.org/abs/2311.17330 。 我们在这里利用一个名为…...

python中list的深拷贝和浅拷贝

其实这还是涉及到python中的可变对象和不可变对象的概念。 https://www.cnblogs.com/poloyy/p/15073168.html # -*- coding: utf-8 -*-person [name, [savings, 100.00]] hubby person[:] # slice copy wifey list(person) # fac func copy a [id(x) for x in person] b …...

【LeetCode】字母异位词分组

题目描述&#xff1a; 给你一个字符串数组&#xff0c;请你将字母异位词组合在一起。可以按任意顺序返回结果列表。 字母异位词 是由重新排列源单词的所有字母得到的一个新单词。 示例 1: 输入: strs [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”] 输出: [[“bat”…...

Golang | Leetcode Golang题解之第295题数据流的中位数

题目&#xff1a; 题解&#xff1a; type MedianFinder struct {nums *redblacktree.Treetotal intleft, right iterator }func Constructor() MedianFinder {return MedianFinder{nums: redblacktree.NewWithIntComparator()} }func (mf *MedianFinder) AddNum(…...

【C语言】C语言期末突击/考研--数据的输入输出

目录 一、printf()输出函数介绍 二、scanf读取标准输入 &#xff08;一&#xff09;scanf函数的原理 &#xff08;二&#xff09;多种数据类型混合输入 三、练习题 今天我们学习printf和scanf读取标准输入。下面我们开始正式的学习吧。 C语言中有很多内置函数&#xff0c;今…...

How can I fix my Flask server‘s 405 error that includes OpenAi api?

题意&#xff1a;解决包含OpenAI API的Flask服务器中出现的405错误&#xff08;Method Not Allowed&#xff0c;即方法不允许&#xff09; 问题背景&#xff1a; Im trying to add an API to my webpage and have never used any Flask server before, I have never used Java…...

LeetCode Hot100 将有序数组转换为二叉搜索树

给你一个整数数组 nums &#xff0c;其中元素已经按 升序 排列&#xff0c;请你将其转换为一棵 平衡 二叉搜索树。 示例 1&#xff1a; 输入&#xff1a;nums [-10,-3,0,5,9] 输出&#xff1a;[0,-3,9,-10,null,5] 解释&#xff1a;[0,-10,5,null,-3,null,9] 也将被视为正确…...

【Linux】线程的控制

目录 线程等待 线程退出 线程的优缺点 线程独占和共享的数据 我们说Linux是用进程模拟的线程&#xff0c;所以Linux中只有轻量级进程的概念&#xff0c;但是&#xff0c;用户是只认线程的&#xff0c;所以我们有一个叫原生线程库的东西&#xff0c;它就负责把轻量级进程的系…...

Vue3自研开源Tree组件:人性化的拖拽API设计

针对Element Plus Tree组件拖拽功能API用的麻烦&#xff0c;小卷开发了一个API使用简单的JuanTree组件。拖拽功能用起来非常简单&#xff01; 文章目录 使用示例allowDragallowDrop支持节点勾选支持dirty检测后台API交互 源码实现 使用示例 组件的使用很简单&#xff1a; 通过…...

HTML 语义化

目录 HTML 语义化HTML5 新特性HTML 语义化的好处语义化标签的使用场景最佳实践 HTML 语义化 HTML5 新特性 标准答案&#xff1a; 语义化标签&#xff1a; <header>&#xff1a;页头<nav>&#xff1a;导航<main>&#xff1a;主要内容<article>&#x…...

DeepSeek 赋能智慧能源:微电网优化调度的智能革新路径

目录 一、智慧能源微电网优化调度概述1.1 智慧能源微电网概念1.2 优化调度的重要性1.3 目前面临的挑战 二、DeepSeek 技术探秘2.1 DeepSeek 技术原理2.2 DeepSeek 独特优势2.3 DeepSeek 在 AI 领域地位 三、DeepSeek 在微电网优化调度中的应用剖析3.1 数据处理与分析3.2 预测与…...

线程同步:确保多线程程序的安全与高效!

全文目录&#xff1a; 开篇语前序前言第一部分&#xff1a;线程同步的概念与问题1.1 线程同步的概念1.2 线程同步的问题1.3 线程同步的解决方案 第二部分&#xff1a;synchronized关键字的使用2.1 使用 synchronized修饰方法2.2 使用 synchronized修饰代码块 第三部分&#xff…...

《基于Apache Flink的流处理》笔记

思维导图 1-3 章 4-7章 8-11 章 参考资料 源码&#xff1a; https://github.com/streaming-with-flink 博客 https://flink.apache.org/bloghttps://www.ververica.com/blog 聚会及会议 https://flink-forward.orghttps://www.meetup.com/topics/apache-flink https://n…...

稳定币的深度剖析与展望

一、引言 在当今数字化浪潮席卷全球的时代&#xff0c;加密货币作为一种新兴的金融现象&#xff0c;正以前所未有的速度改变着我们对传统货币和金融体系的认知。然而&#xff0c;加密货币市场的高度波动性却成为了其广泛应用和普及的一大障碍。在这样的背景下&#xff0c;稳定…...

如何在网页里填写 PDF 表格?

有时候&#xff0c;你可能希望用户能在你的网站上填写 PDF 表单。然而&#xff0c;这件事并不简单&#xff0c;因为 PDF 并不是一种原生的网页格式。虽然浏览器可以显示 PDF 文件&#xff0c;但原生并不支持编辑或填写它们。更糟的是&#xff0c;如果你想收集表单数据&#xff…...

USB Over IP专用硬件的5个特点

USB over IP技术通过将USB协议数据封装在标准TCP/IP网络数据包中&#xff0c;从根本上改变了USB连接。这允许客户端通过局域网或广域网远程访问和控制物理连接到服务器的USB设备&#xff08;如专用硬件设备&#xff09;&#xff0c;从而消除了直接物理连接的需要。USB over IP的…...

Python+ZeroMQ实战:智能车辆状态监控与模拟模式自动切换

目录 关键点 技术实现1 技术实现2 摘要&#xff1a; 本文将介绍如何利用Python和ZeroMQ消息队列构建一个智能车辆状态监控系统。系统能够根据时间策略自动切换驾驶模式&#xff08;自动驾驶、人工驾驶、远程驾驶、主动安全&#xff09;&#xff0c;并通过实时消息推送更新车…...

用鸿蒙HarmonyOS5实现中国象棋小游戏的过程

下面是一个基于鸿蒙OS (HarmonyOS) 的中国象棋小游戏的实现代码。这个实现使用Java语言和鸿蒙的Ability框架。 1. 项目结构 /src/main/java/com/example/chinesechess/├── MainAbilitySlice.java // 主界面逻辑├── ChessView.java // 游戏视图和逻辑├──…...

echarts使用graphic强行给图增加一个边框(边框根据自己的图形大小设置)- 适用于无法使用dom的样式

pdf-lib https://blog.csdn.net/Shi_haoliu/article/details/148157624?spm1001.2014.3001.5501 为了完成在pdf中导出echarts图&#xff0c;如果边框加在dom上面&#xff0c;pdf-lib导出svg的时候并不会导出边框&#xff0c;所以只能在echarts图上面加边框 grid的边框是在图里…...