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

网站演示代码如何制作一个自己的网页

网站演示代码,如何制作一个自己的网页,网站建设过程发生的费用,网站备案 企业一、环境说明系统版本:CentOS 7.9内核版本:3.10.0-1160.119.1Nginx版本:1.26.3第三方检测模块及版本:nginx_upstream_check_module(v0.4.0,兼容nginx 1.20)二、nginx安装部署2.1 下载检测模块目…

一、环境说明

        系统版本:CentOS 7.9

        内核版本:3.10.0-1160.119.1

        Nginx版本:1.26.3

        第三方检测模块及版本:nginx_upstream_check_module(v0.4.0,兼容nginx 1.20+)

二、nginx安装部署

        2.1 下载检测模块

        目前程序包的模块已经升级,升级后支持nginx 1.20以上的版本,源码包下载地址如下:

https://github.com/yaoweibin/nginx_upstream_check_module/archive/refs/tags/v0.4.0.tar.gz

        2.2 安装相关依赖包

        在执行部署之前,需要安装相关依赖包,如nginx所需的gcc、gcc-c++、openssl、zlib、pcre等,以及nginx_upstream_check_module执行补丁命令时所需的patch组件。

        由于现在CentOS 7官方源已经无法使用,因此需要使用国内的其他yum源,或者使用CentOS 7.9镜像来配置本地的yum源,以安装相关依赖包。这里就不做过多说明,不熟悉的小伙伴,可以自行联网查询相关配置方法。

2.3 执行安装

        2.3.1 上传相关包

        将nginx以及nginx_upstream_check_module的源码包上传到Linux服务器的/usr/local/src目录下,并解压。

[root@vm-localsystem src]# ls 
nginx-1.26.3.tar.gz  nginx_upstream_check_module-0.4.0.tar.gz
[root@vm-localsystem src]# tar -xzf nginx-1.26.3.tar.gz 
[root@vm-localsystem src]# tar -xzf nginx_upstream_check_module-0.4.0.tar.gz 
[root@vm-localsystem src]# ls
nginx-1.26.3  nginx-1.26.3.tar.gz  nginx_upstream_check_module-0.4.0  nginx_upstream_check_module-0.4.0.tar.gz

        2.3.2 执行patch操作

[root@vm-localsystem src]# cd nginx-1.26.3/
[root@vm-localsystem nginx-1.26.3]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src
[root@vm-localsystem nginx-1.26.3]# patch -p1 < ../nginx_upstream_check_module-0.4.0/check_1.20.1+.patch 
patching file src/http/modules/ngx_http_upstream_hash_module.c
patching file src/http/modules/ngx_http_upstream_ip_hash_module.c
patching file src/http/modules/ngx_http_upstream_least_conn_module.c
patching file src/http/ngx_http_upstream_round_robin.c
patching file src/http/ngx_http_upstream_round_robin.h

        2.3.3 创建用户和组

这里使用普通用户和组来安装和运行nginx,用户和组(如:app)需要提前创建。

[root@vm-localsystem ~]# groupadd app
[root@vm-localsystem ~]# useradd -d /data -g app app
[root@vm-localsystem ~]# chown -R app:app /data

        2.3.4 编译和安装nginx

        编译和安装的时候还是需要使用root用户的,但是需要在编译参数里面增加--group=app --user=app这样的参数,另外还需要增加引入nginx_upstream_check_module-0.4.0模块的参数--add-module=../nginx_upstream_check_module-0.4.0。

        编译安装成功后,记得将nginx安装目录的用户和组设置为app:app。

[root@vm-localsystem ~]# cd /usr/local/src/nginx-1.26.3/
[root@vm-localsystem nginx-1.26.3]# ./configure --prefix=/data/nginx --with-threads --with-http_ssl_module --with-http_stub_status_module --add-module=../nginx_upstream_check_module-0.4.0 --group=app --user=app[root@vm-localsystem nginx-1.26.3]# make[root@vm-localsystem nginx-1.26.3]# make install[root@vm-localsystem nginx-1.26.3]# chown -R app:app /data/nginx/

        2.3.5 nginx配置修改

        这里需要注意的是,由于nginx使用使用普通用户运行,因此不能使用默认的80监听端口了,我这里修改为了8081端口。其他配置可根据需要自行修改。

        2.3.6 启动nginx服务

        nginx配置校验通过后,即可启动nginx服务,可使用-V检查nginx的编译参数。

[app@vm-localsystem conf]$ ../sbin/nginx -t
nginx: the configuration file /data/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /data/nginx/conf/nginx.conf test is successful
[app@vm-localsystem conf]$ ../sbin/nginx -V
nginx version: nginx/1.26.3
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/data/nginx --with-threads --with-http_ssl_module --with-http_stub_status_module --add-module=../nginx_upstream_check_module-0.4.0 --group=app --user=app
[app@vm-localsystem conf]$ ../sbin/nginx 
[app@vm-localsystem conf]$ ps -ef| grep nginx| grep -v grep
app        4801      1  0 11:12 ?        00:00:00 nginx: master process ../sbin/nginx
app        4802   4801  2 11:12 ?        00:00:00 nginx: worker process
app        4803   4801  2 11:12 ?        00:00:00 nginx: worker process

三、主动检测功能测试

3.1 启动两个Tomcat实例

        在一台Linux服务器上,启动2个Tomcat实例,部署的应用都为haweb(Oracle官方免费提供的一个测试小应用),为了做区分,对页面做了点改造,以示区别

        

        tomcat1

        
        tomcat2

        

        在nginx中对这两个真实的页面访问地址进行反向代理和负载均衡配置,部分配置如下:

http {include       mime.types;default_type  application/octet-stream;log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';access_log  logs/access.log  main;sendfile        on;tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;gzip  on;upstream haweb {server 192.168.223.96:18170; server 192.168.223.96:18171;#check interval=3000 rise=2 fall=5 timeout=1000 type=tcp;check interval=3000 rise=2 fall=5 timeout=1000 type=http; check_http_send "GET /haweb HTTP/1.0\r\n\r\n";check_http_expect_alive http_2xx http_3xx;}server {listen       8081;server_name  192.168.223.199;charset utf-8;#access_log  logs/host.access.log  main;location / {root   html;index  index.html index.htm;}location /haweb {proxy_pass http://haweb;}location /status {check_status;access_log   off;allow 192.168.223.3;deny all;}

备注:

        1)upstream{}配置,以及两个location{}配置,及/haweb /status;

        2)upstream{}块配置中,启用主动健康检查,检查方式为http,使用http 1.0协议,发送/haweb的get请求。期望返回的正常的http代码为2XX、3XX开头的返回码。

        配置校验没问题,然后热加载,即可通过nginx的IP和端口,来访问后端页面,默认访问策略为轮询,所以,刷新页面会在testPage1和testPage2之间来回切换。

[app@vm-localsystem conf]$ ../sbin/nginx -t
nginx: the configuration file /data/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /data/nginx/conf/nginx.conf test is successful
[app@vm-localsystem conf]$ ../sbin/nginx -s reload
[app@vm-localsystem conf]$ 

        

        

        可以根据配置status模块,来查看探测的结果

        

        把tomcat2的服务进程杀掉后,探测页面及展示出探测失败的告警

        

四、参考

https://www.cnblogs.com/linyouyi/p/11502282.html

https://www.cnblogs.com/LiuChang-blog/p/12494567.html

https://www.cnblogs.com/Xinenhui/p/15944725.html

https://www.cnblogs.com/dance-walter/p/12212607.html

https://github.com/yaoweibin/nginx_upstream_check_module

http://www.dtcms.com/wzjs/65380.html

相关文章:

  • 网站建设的需要是什么网站开发的步骤
  • 网站设置了 不能复制网站优化排名易下拉排名
  • 紫竹桥网站建设哪家公司做seo
  • 怎样建设网站空间计算机基础培训机构
  • 文档做网站优化推广网站怎么做
  • 网站建设英文翻译白云区最新疫情
  • prestashop和wordpressseo技术培训山东
  • dede网站网站google搜索优化
  • 广州在线网页制作工具seo是什么职位缩写
  • 怎么利用网站做淘宝客seo运营是什么意思
  • 营销网站建设视频数据推广公司
  • 建设银行日本分行招聘网站搜索引擎排名2022
  • 自己制作简单的小程序正安县网站seo优化排名
  • 北京网站制作设计与开发服务教育培训网站
  • wordpress 小说模板厦门百度快速优化排名
  • 建设好网站怎么付费推广网站运营主要做什么工作
  • 怎样用网站做单笔外贸单页网站制作教程
  • 网站初期seo怎么做百度新闻最新消息
  • 厦门做直销网站公司APP如何免费制作自己的网站
  • 集约化政府网站建设网站建设的系统流程图
  • 网站开发web服务器控件实验报告南京网站设计公司
  • 无锡网站制作咨询建站cms
  • 网站建设和管理情况爱站seo
  • 优秀的网站建设价格谷歌seo网站排名优化
  • 怎样做旅游网站品牌推广策略分析
  • 湖南平台网站建设哪里有百度 站长工具
  • 成都网站建设公司哪家专业百度推广关键词
  • wordpress jquery插件开发网站seo置顶
  • 广州 骏域网站建设专家by72777最新域名查询
  • B2C网站可使用的交易功能为seo网站关键词