高性能web服务器--nginx

news2024/9/23 15:28:13

下载nginx 

[root@nginx ~]# wget -c https://nginx.org/download/nginx-1.24.0.tar.gz
[root@nginx ~]# tar zxf nginx-1.24.0.tar.gz

创建nginx用户
[root@nginx nginx-1.24.0]# useradd -s /sbin/nologin -M nginx

 先安装依赖

dnf install gcc pcre-devel zlib-devel openssl-devel -y
[root@nginx nginx-1.24.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module

注意:如果没有提前安装依赖,会报以下错误

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

   

可以先一个个  dnf install pcre-devel -y

安装编译

 make && make install
[root@nginx nginx-1.24.0]# ll
total 820
drwxr-xr-x 6 nginx nginx   4096 Aug 15 10:56 auto
-rw-r--r-- 1 nginx nginx 323312 Apr 11  2023 CHANGES
-rw-r--r-- 1 nginx nginx 494234 Apr 11  2023 CHANGES.ru
drwxr-xr-x 2 nginx nginx    168 Aug 15 10:56 conf
-rwxr-xr-x 1 nginx nginx   2611 Apr 11  2023 configure
drwxr-xr-x 4 nginx nginx     72 Aug 15 10:56 contrib
drwxr-xr-x 2 nginx nginx     40 Aug 15 10:56 html
-rw-r--r-- 1 nginx nginx   1397 Apr 11  2023 LICENSE
-rw-r--r-- 1 root  root     438 Aug 15 11:02 Makefile
drwxr-xr-x 2 nginx nginx     21 Aug 15 10:56 man
drwxr-xr-x 3 root  root     174 Aug 15 11:03 objs
-rw-r--r-- 1 nginx nginx     49 Apr 11  2023 README
drwxr-xr-x 9 nginx nginx     91 Aug 15 10:56 src
[root@nginx nginx-1.24.0]# cd objs/
[root@nginx objs]# ls
autoconf.err  nginx    ngx_auto_config.h   ngx_modules.c  src
Makefile      nginx.8  ngx_auto_headers.h  ngx_modules.o
[root@nginx objs]# nginx
bash: nginx: command not found...
Install package 'nginx-core' to provide command 'nginx'? [N/y] n

# 启动nginx
[root@nginx objs]# ./nginx


[root@nginx objs]# ps aux | grep nginx
root       42828  0.0  0.0   9836   928 ?        Ss   11:39   0:00 nginx: master process ./nginx
nginx      42829  0.0  0.1  13724  4844 ?        S    11:39   0:00 nginx: worker process
root       42834  0.0  0.0 221664  2168 pts/0    S+   11:40   0:00 grep --color=auto nginx

关闭nginx

[root@nginx objs]# /usr/local/nginx/sbin/nginx -s stop
[root@nginx objs]# ps aux | grep nginx
root       42837  0.0  0.0 221664  2352 pts/0    S+   11:41   0:00 grep --color=auto nginx

删除nginx

[root@nginx objs]# rm -rf /usr/local/nginx/
[root@nginx objs]# make clean

不启用debug模块

[root@nginx nginx-1.24.0]# vim auto/cc/gcc

nginx软件的执行路径添加到环境变量中

[root@nginx ~]# vim ~/.bash_profile
export PATH=$PATH:/usr/local/nginx/sbin
[root@nginx ~]# source ~/.bash_profile
[root@nginx ~]# nginx

看nginx软件的大小

[root@nginx ~]# du -sh /usr/local/nginx/sbin/nginx
5.5M    /usr/local/nginx/sbin/nginx

 改变服务版本信息

[root@nginx ~]# cd /usr/local/nginx/conf/
[root@nginx conf]# vim nginx.conf
[root@nginx conf]# curl -I 192.168.136.100
HTTP/1.1 200 OK
Server: nginx/1.24.0
Date: Thu, 15 Aug 2024 03:52:15 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Thu, 15 Aug 2024 03:03:35 GMT
Connection: keep-alive
ETag: "66bd7007-267"
Accept-Ranges: bytes

平滑升级和平滑回滚  

下载高版本的

将echo-nginx-module-0.63.tar.gz  上传到本地家目录下

开始编译新版本

[root@nginx nginx-1.26.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx  --add-module=/root/echo-nginx-module-0.63 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module

只要make无需要make install

[root@nginx nginx-1.26.2]# make

查看两个版本

[root@nginx nginx-1.26.2]# ll objs/nginx /usr/local/nginx/sbin/nginx
-rwxr-xr-x 1 root root 6177456 Aug 15 13:06 objs/nginx
-rwxr-xr-x 1 root root 5679504 Aug 15 11:03 /usr/local/nginx/sbin/nginx

把之前的旧版的nginx命令备份

[root@nginx nginx-1.26.2]# cd /usr/local/nginx/sbin/
[root@nginx sbin]# ll
total 5548
-rwxr-xr-x 1 root root 5679504 Aug 15 11:03 nginx
[root@nginx sbin]# mv nginx nginx.old

把新版本的nginx命令复制过去

[root@nginx sbin]# \cp -f /root/nginx-1.26.2/objs/nginx /usr/local/nginx/sbin/

检测一下有没有问题

[root@nginx sbin]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@nginx sbin]# nginx -s restart
[root@nginx sbin]# nginx
[root@nginx sbin]# ps aux | grep nginx
root       47861  0.0  0.0   9836   932 ?        Ss   13:48   0:00 nginx: master process nginx
nginx      47862  0.0  0.1  13724  4816 ?        S    13:48   0:00 nginx: worker process
root       47864  0.0  0.0 221664  2272 pts/0    S+   13:48   0:00 grep --color=auto nginx

[root@nginx sbin]# kill -USR2 47861
[root@nginx sbin]# ps aux | grep nginx
root       47861  0.0  0.0   9836  3196 ?        Ss   13:48   0:00 nginx: master process nginx
nginx      47932  0.0  0.1  13736  4956 ?        S    14:05   0:00 nginx: worker process
root       47939  0.0  0.1   9872  5952 ?        S    14:06   0:00 nginx: master process nginx
nginx      47940  0.0  0.1  13760  4736 ?        S    14:06   0:00 nginx: worker process
root       47942  0.0  0.0 221664  2256 pts/0    S+   14:06   0:00 grep --color=auto nginx

#回收旧版本
[root@nginx sbin]# kill -WINCH 47861

#检测版本信息
[root@nginx sbin]# curl -I localhost
HTTP/1.1 200 OK
Server: nginx/1.26.2
Date: Thu, 15 Aug 2024 06:07:15 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Thu, 15 Aug 2024 03:03:35 GMT
Connection: keep-alive
ETag: "66bd7007-267"
Accept-Ranges: bytes

#平滑回滚
[root@nginx sbin]# kill -HUP 47861

隐藏

[root@nginx nginx]# vim /root/nginx-1.26.2/src/core/nginx.h

Nginx 核心配置详解 

[root@nginx conf]# vim nginx.conf

[root@nginx conf]# nginx -g "worker_processes 6;"
[root@nginx conf]# ps aux | grep nginx
root       48272  0.0  0.0   9872   940 ?        Ss   16:10   0:00 nginx: master process nginx -g worker_processes 6;
nginx      48273  0.0  0.1  13772  4864 ?        S    16:10   0:00 nginx: worker process
nginx      48274  0.0  0.1  13772  4864 ?        S    16:10   0:00 nginx: worker process
nginx      48275  0.0  0.1  13772  4864 ?        S    16:10   0:00 nginx: worker process
nginx      48276  0.0  0.1  13772  4864 ?        S    16:10   0:00 nginx: worker process
nginx      48277  0.0  0.1  13772  4864 ?        S    16:10   0:00 nginx: worker process
nginx      48278  0.0  0.1  13772  4864 ?        S    16:10   0:00 nginx: worker process
root       48280  0.0  0.0 221664  2328 pts/0    S+   16:10   0:00 grep --color=auto nginx

写启动文件

[root@nginx conf]# vim /lib/systemd/system/nginx.service
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

[root@nginx conf]# systemctl daemon-reload
[root@nginx conf]# nginx -s stop
[root@nginx conf]# ps aux | grep nginx
root       48382  0.0  0.0 221664  2268 pts/0    S+   16:19   0:00 grep --color=auto nginx
[root@nginx conf]# systemctl enable --now nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
[root@nginx conf]# ps aux | grep nginx
root       48411  0.0  0.0   9872   944 ?        Ss   16:20   0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx      48412  0.0  0.1  13772  4824 ?        S    16:20   0:00 nginx: worker process
root       48414  0.0  0.0 221664  2196 pts/0    S+   16:20   0:00 grep --color=auto nginx

将Nginx工作进程绑定到指定的CPU核心

worker_cpu_affinity   将Nginx工作进程绑定到指定的CPU核心,默认Nginx是不进行进程绑定的,绑定并不是意味着当前nginx进 程独占以一核心CPU,但是可以保证此进程不运行在其他核心上,这就极大减少了nginx的工作进程在不同的 cpu核心上的来回跳转,减少了CPU对进程的资源分配与回收以及内存管理等,因此可以有效的提升nginx服务 器的性能。

user nginx;  #启动Nginx工作进程的用户
worker_processes 4;  #启动Nginx工作进程的数量,一般设为和CPU核心数相同
worker_cpu_affinity 0001 0010 0100 1000;  
[root@nginx ~]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

实现 nginx 的高并发配置

修改pam限制 

查看ulimit
[root@nginx conf]# sudo -u nginx ulimit -n
1024
[root@nginx conf]# vim /etc/security/limits.conf

设置单个工作进程的最大并发连接数

测试访问 

[root@nginx conf]# ab -n 100 -c 50 http://192.168.136.100/index.html
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.136.100 (be patient).....done


Server Software:        nginx/1.26.2
Server Hostname:        192.168.136.100
Server Port:            80

Document Path:          /index.html
Document Length:        615 bytes

Concurrency Level:      50
Time taken for tests:   0.006 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      84800 bytes
HTML transferred:       61500 bytes
Requests per second:    15444.02 [#/sec] (mean)
Time per request:       3.237 [ms] (mean)
Time per request:       0.065 [ms] (mean, across all concurrent requests)
Transfer rate:          12789.58 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.4      1       2
Processing:     0    1   1.0      1       4
Waiting:        0    1   1.1      1       4
Total:          1    2   1.3      2       5

Percentage of the requests served within a certain time (ms)
  50%      2
  66%      2
  75%      2
  80%      2
  90%      5
  95%      5
  98%      5
  99%      5
 100%      5 (longest request)

新建一个 PC web 站点

配置子配置文件(可选),在主配置文件添加一行

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

[root@nginx ~]# mkdir -p /usr/local/nginx/conf.d
[root@nginx ~]# vim /usr/local/nginx/conf.d/vhost.conf
server {
        listen 80;
        server_name www.jieyu.org;
        root /data/web/html;
        index index.html;
}

[root@nginx ~]# mkdir -p /data/web/html
[root@nginx ~]# echo www.jieyu.org > /data/web/html/index.html
[root@nginx ~]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
^C
[root@nginx ~]# nginx -s reload

 修改C:\Windows\System32\drivers\etc\hosts    添加以下解析 
192.168.136.100 www.jieyu.org

测试访问

root 与 alias

 root:指定web的家目录,在定义location的时候,文件的绝对路径等于 root+location     

 root示例:

[root@nginx ~]# vim /usr/local/nginx/conf.d/vhost.conf
server {
        listen 80;
        server_name www.jieyu.org;
        root /data/web/html;
        index index.html;
        location /test1 {
            root /data/web;
        }
}

[root@nginx ~]# mkdir -p /data/web/test1
[root@nginx ~]# echo /data/web/test1 > /data/web/test1/index.html
[root@nginx ~]# nginx -s reload

测试 

alias:定义路径别名,会把访问的路径重新定义到其指定的路径,文档映射的另一种机制;仅能用于 location上下文,此指令使用较少

server {
        listen 80;
        server_name www.jieyu.org;
        root /data/web/html;
        index index.html;
        location /test1 {
            root /data/web;
        }

        location /test2 {
            alias /data/web/test1;
        }
}

location 的详细使用

在一个server中location配置段可存在多个,用于实现从uri到文件系统的路径映射;

ngnix会根据用户请求的URI来检查定义的所有location,按一定的优先级找出一个最佳匹配, 而后应用其配置在没有使用正则表达式的时候,nginx会先在server中的多个location选取匹配度最 高的一个uri uri是用户请求的字符串,即域名后面的web文件路径 然后使用该location模块中的正则url和字符串,如果匹配成功就结束搜索,并使用此location处理 此请求。

匹配以html或者yu结尾

location ~ .(html|yu)$ {
    root /data/web1;   
}
[root@nginx test]# pwd
/data/web1/test

 

[root@nginx web]# mkdir -p /data/web{1..5}/test
[root@nginx web]# echo web1 > /data/web1/test/index.html
[root@nginx web]# echo web2 > /data/web2/test/index.html
[root@nginx web]# echo web3 > /data/web3/test/index.html
[root@nginx web]# echo web4 > /data/web4/test/index.html
[root@nginx web]# echo web5 > /data/web5/test/index.html

文件和目录的优先级不一样

 

创建默认认证文件 

[root@nginx ~]# htpasswd -cm /usr/local/nginx/.htpasswd yujie  # -c 会覆盖之前的用户
New password:
Re-type new password:
Adding password for user yujie

[root@nginx ~]# htpasswd -m /usr/local/nginx/.htpasswd admin  

[root@nginx ~]# cat /usr/local/nginx/.htpasswd
yujie:$apr1$lqNM/m0v$1E.lLVqwHTc8Ji6UWNfJL.
admin:$apr1$OaJ1Hrgx$kRH2x6iOMt.DN97QrgQYd0

[root@nginx ~]# mkdir /data/web/yu
[root@nginx ~]# echo yu > /data/web/yu/index.html

加用户认证

server {
        listen 80;
        server_name www.jieyu.org;
        root /data/web/html;
        index index.html;

        location /yu {
                root /data/web;
                auth_basic "login password !!";
                auth_basic_user_file "/usr/local/nginx/.htpasswd";
        }
}

用户认证 

自定义错误页 

server {
        listen 80;
        server_name  www.jieyu.org;
        root /data/web/html;
        index index.html;
        error_page 404 /40x.html;

        location /yu {
                root /data/web;
                auth_basic "login password !!";
                auth_basic_user_file "/usr/local/nginx/.htpasswd";
        }
        location = /40x.html {
           root /data/web/errorpage;
        }
}
[root@nginx ~]# mkdir -p /data/web/errorpage
[root@nginx ~]# echo error page > /data/web/errorpage/40x.html
[root@nginx ~]# nginx -s reload

自定义错误日志与访问日志

[root@nginx ~]# mkdir /var/log/jieyu.org/
[root@nginx ~]# nginx -s reload

 

[root@nginx ~]# cat /var/log/jieyu.org/access.log
192.168.136.1 - admin [16/Aug/2024:14:33:02 +0800] "GET /yu/ HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0"

 

[root@nginx ~]# cat /var/log/jieyu.org/error.log
2024/08/16 14:34:13 [error] 2019#0: *19 open() "/data/web/yua" failed (2: No such file or directory), client: 192.168.136.1, server: www.jieyu.org, request: "GET /yua HTTP/1.1", host: "www.jieyu.org"

检测文件是否存在

try_files会按顺序检查文件是否存在,返回第一个找到的文件或文件夹(结尾加斜线表示为文件夹),如果所有文件或文件夹都找不到,会进行一个内部重定向到最后一个参数。只有最后一个参数可以引起一 个内部重定向,之前的参数只设置内部URI的指向。最后一个参数是回退URI且必须存在,否则会出现内部500错误。

示例: 如果不存在页面, 就转到default.html页面

[root@nginx ~]# rm -rf /data/web/html/index.html
[root@nginx ~]# mkdir /data/web/html/error
[root@nginx ~]# echo error default > /data/web/html/error/default.html

长连接配置

长连接的测试工具

[root@nginx ~]# dnf install telnet -y

设定保持连接超时时长,0表示禁止长连接

让客户看到60s  实际65s

作为下载服务器配置

[root@nginx ~]# mkdir /data/web/download
[root@nginx ~]# dd if=/dev/zero of=/data/web/download/yufile bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB, 100 MiB) copied, 0.0395786 s, 2.6 GB/s

测试 

nginx的状态页面

server {
    listen 80;
    server_name status.jieyu.org;
    root /data/web/html;
    index index.html;

    location /status {
        stub_status;
        allow 192.168.136.1;   #指定让谁看
        deny all;
    }
}

更改 C:\Windows\System32\drivers\etc\hosts  文件

192.168.136.100 status.jieyu.org 

因为指定了让192.168.136.1看   所以只能浏览器看

Nginx 压缩功能

Nginx支持对指定类型的文件进行压缩然后再传输给客户端,而且压缩还可以设置压缩比例,压缩后的文 件大小将比源文件显著变小,样有助于降低出口带宽的利用率,降低企业的IT支出,不过会占用相 应的CPU资源。

[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
    gzip  on;                 #启用或禁用gzip压缩,默认关闭
    gzip_comp_level 4;        #压缩比由低到高从1到9,默认为1,值越高压缩后文件越小
    gzip_min_length 1k;       #gzip压缩的最小文件,小于设置值的文件将不会压缩
    gzip_http_version 1.1;    #启用压缩功能时,协议的最小版本,默认HTTP/1.1
    gzip_vary on;     #如果启用压缩,是否在响应报文首部插入“Vary: Accept-Encoding”,一般建议打开
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/gif image/png;     #指明仅对哪些类型的资源执行压缩操作;默认为gzip_types text/html,不用显示指定,

制作大文件,小文件 


[root@nginx ~]# echo hello jieyu > /data/web/html/small.html
[root@nginx ~]# du -sh /usr/local/nginx/logs/access.log
24K     /usr/local/nginx/logs/access.log
[root@nginx ~]# cat /usr/local/nginx/logs/access.log > /data/web/html/big.html

Nginx Rewrite 相关功能 

[root@nginx ~]# vim /etc/hosts
192.168.136.100 vars.jieyu.org
server {
    listen 80;
    server_name var.jieyu.org;
    root /data/web/html;
    index index.html;

    location /var {
        default_type text/html;
        echo $remote_addr;
        echo $args;
        echo $is_args;
        echo $document_root;
        echo $document_uri;
        echo $host;
        echo $remote_port;
        echo $remote_user;
        echo $request_method;
        echo $request_filename;
        echo $request_uri;
        echo $scheme;
        echo $server_protocol;
        echo $server_addr;
        echo $server_name;
        echo $server_port;
        echo $http_user_agent;
        echo $http_cookie;
        echo $cookie_key2;
    }
}

 测试:

[root@nginx ~]# curl -b "key1=yu,key2=yu1" -u yu:123 var.jieyu.org/var?name=lee&&id=6666
192.168.136.100
name=lee
?
/data/web/html
/var
var.jieyu.org
48482
yu
GET
/data/web/html/var
/var?name=lee
http
HTTP/1.1
192.168.136.100
var.jieyu.org
80
curl/7.76.1
key1=yu,key2=yu1
yu1

nginx自定义变量

server {
    listen 80;
    server_name var.jieyu.org;
    root /data/web/html;
    index index.html;

    location /var {
        default_type text/html;
        set $jieyu jie;
        echo $jieyu;
    }
}

测试

[root@nginx ~]#  curl var.jieyu.org/var
jie

if 判定指令 

测试文件是否存在

[root@nginx test2]# cat /usr/local/nginx/conf.d/yu.conf
server {
    listen 80;
    server_name var.jieyu.org;
    root /data/web/html;
    index index.html;

    location /test2 {
    if ( !-e $request_filename ) {
        echo "$request_filename is not exist";
        }
    }
}

 测试

#没文件
[root@nginx test2]# nginx -s reload
[root@nginx test2]# curl var.jieyu.org/test2/index.html
/data/web/html/test2/index.html is not exist

#有文件
[root@nginx test2]# echo test2 > /data/web/html/test2/index.html
[root@nginx test2]# curl var.jieyu.org/test2/index.html
test2

break指令

location /break {
        default_type text/html;
        set $name yu;
        echo $name;
        if ( $http_user_agent = "curl/7.76.1" ){
            break;
        }
        set $id 666;
        echo $id;
    }

测试

[root@nginx test2]# nginx -s reload
[root@nginx test2]# curl var.jieyu.org/break
yu

[root@nginx test2]# curl -A "firefox" var.jieyu.org/break
yu
666

return指令

location /return {
        default_type text/html;
        if ( !-e $request_filename){
            return 301 http://www.baidu.com;
        }
        echo "$request_filename is exist";
    }

测试 

[root@nginx test2]# nginx -s reload
[root@nginx test2]# curl -I var.jieyu.org/return
HTTP/1.1 301 Moved Permanently
Server: nginx/1.26.2
Date: Sun, 18 Aug 2024 03:55:35 GMT
Content-Type: text/html
Content-Length: 169
Connection: keep-alive
Keep-Alive: timeout=60
Location: http://www.baidu.com

[root@nginx test2]# mkdir -p /data/web/html/return
[root@nginx test2]# curl -I var.jieyu.org/return
HTTP/1.1 200 OK
Server: nginx/1.26.2
Date: Sun, 18 Aug 2024 03:56:26 GMT
Content-Type: text/html
Connection: keep-alive
Keep-Alive: timeout=60
Vary: Accept-Encoding

 rewrite  临时和永久

永久重定向301:域名永久型调整,即域名永远跳转至另外一个新的域名,之前的域名再也不使用,跳转记录可以缓存到客户端浏览器

永久重定向会缓存DNS解析记录, 浏览器中有 from disk cache 信息,即使nginx服务器无法访问,浏览器也会利用缓存进行重定向

location /rewrite {
        root /data/web/var;
        index index.html;
        rewrite / http://www.jieyu.com permanent;
    }

测试

临时重定向302:域名临时重定向,告诉浏览器域名不是固定重定向到当前目标域名,后期可能随时会更改,因此浏览器 不会缓存当前域名的解析记录,而浏览器会缓存永久重定向的DNS解析记录,这也是临时重定向与永久重定向最大的本质区别。

即当nginx服务器无法访问时,浏览器不能利用缓存,而导致重定向失败 

location /rewrite {
        root /data/web/var;
        index index.html;
        rewrite / http://www.jieyu.com redirect;
    }

 测试

rewrite 案例: break 与 last

创建html文件

[root@nginx ~]# mkdir /data/web/html/{test1,test2,break,last} -p
[root@nginx ~]# echo test1 > /data/web/html/test1/index.html
[root@nginx ~]# echo test2 > /data/web/html/test2/index.html
[root@nginx ~]# echo last > /data/web/html/last/index.html
[root@nginx ~]# echo break > /data/web/html/break/index.html
server {
    listen 80;
    server_name var.jieyu.org;
    root /data/web/html;
    index index.html;

    location /break {
        rewrite ^/break/(.*) /test1/$1;
        rewrite ^/test1/(.*) /test2/$1;
    }

    location /last {
        rewrite ^/last/(.*) /test1/$1;
        rewrite ^/test1/(.*) /test2/$1;
    }

    location /test1 {
        default_type test/html;
        echo "jieyu hahahahahha";
    }

    location /test2 {
        root /data/web/html;
    }
}

测试

 当加入break之后

当加入last之后

rewrite案例: 自动跳转 https

案例:基于通信安全考虑公司网站要求全站 https,因此要求将在不影响用户请求的情况下将http请求全 部自动跳转至 https,另外也可以实现部分 location 跳转

[root@nginx ~]# mkdir -p /usr/local/nginx/certs
[root@nginx ~]# openssl req -newkey rsa:2048 -nodes -sha256 -keyout /usr/local/nginx/certs/jieyu.org.key -x509 -days 365 -out /usr/local/nginx/certs/jieyu.org.crt
.+.....+....+.....+.+...+........+....+....................+.+.....+...+....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.....+.....+....+........+...+.+...+...............+...+...+..............+.+......+.........+............+..+.+......+.....+...+.........................................................+...+.+..+.......+...+.....+...+.+...+...+..+............+.+.........+........+...+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
...+........+.......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*..........+.....+...+.........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*....+.........+...+...+.+...+..........................+.......+..............+....+............+............+...........+.+........+.+...........+.+..+...+...+..........+..+.........+......+....+...+........+...+.+......+.....+....+...+......+...........+.+...+......+......+.....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:Jiangsu
Locality Name (eg, city) [Default City]:nanjing
Organization Name (eg, company) [Default Company Ltd]:jieyu
Organizational Unit Name (eg, section) []:webserver
Common Name (eg, your name or your server's hostname) []:www.jieyu.org
Email Address []:admin@jieyu.com

 编辑配置

vim /usr/local/nginx/conf.d/vhosts.conf
server {
    listen 80;
    listen 443 ssl;
    server_name www.jieyu.org;
    root /data/web/html;
    index index.html;
    ssl_certificate /usr/local/nginx/certs/jieyu.org.crt;
    ssl_certificate_key /usr/local/nginx/certs/jieyu.org.key;
    ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;

    location / {
        if ( $scheme = http ){
            rewrite / https://$host redirect;
        }
    }
}

 测试: 输入http://www.jieyu.org

案例:防盗链

放图片

[root@nginx html]# mkdir /data/web/html/images
[root@nginx images]# ls
123.jpg

将盗链图片放在/data/web/html下 

实现盗链

在一个web 站点盗链另一个站点的资源信息,比如:图片、视频等 

 假设有个192.168.136.128的web服务器偷图

[root@client ~]# cat /var/www/html/index.html
<html>

  <head>
    <meta http-equiv=Content-Type content="text/html;charset=utf-8">
    <title>盗链</title>
</head>

  <body>
    <img src="http://www.jieyu.org/images/nginx.jpg" >
    <h1 style="color:red">欢迎大家</h1>
    <p><a href=http://www.jieyu.org>狂点老鱼</a>出门见喜</p>
  </body>

</html>

 

location /images  {
        valid_referers none blocked server_names *.jieyu.org ~/.baidu/.;
        if ( $invalid_referer ){
                rewrite ^/   http://www.jieyu.org/daolian.png;
        }
    }

 如果从百度转过去  会有referer信息

验证两个域名的日志,是否会在被盗连的web站点的日志中出现以下盗链日志信息:

 实现防盗链

全站限制  

发现图片裂了,网址也访问不了

location /images  {
        valid_referers none blocked server_names *.jieyu.org ~/.baidu/.;
        if ( $invalid_referer ){
                rewrite ^/   http://www.jieyu.org/daolian.png;
        }
    }

再次访问

NGINX 反向代理

ngx_http_proxy_module: #将客户端的请求以http协议转发至指定服务器进行处理 ngx_http_upstream_module #用于定义为proxy_pass,fastcgi_pass,uwsgi_pass

                                              #等指令引用的后端服务器分组

ngx_stream_proxy_module: #将客户端的请求以tcp协议转发至指定服务器处理 ngx_http_fastcgi_module: #将客户端对php的请求以fastcgi协议转发至指定服务器助理 ngx_http_uwsgi_module: #将客户端对Python的请求以uwsgi协议转发至指定服务器处理

动静分离 

准备两台web服务器

 在nginx主机上测试访问两台web主机

 一台主机装php

[root@web1 ~]# yum install php -y

[root@web1 ~]# yum install httpd -y
[root@web1 ~]# cat /var/www/html/index.php
<?php
  phpinfo();
?>

一台配置一个html页面

[root@nginx images]# cat /usr/local/nginx/conf.d/vhosts.conf
server {
    listen 80;
    server_name www.jieyu.org;

    location ~ \.php$ {
        proxy_pass http://192.168.136.128:80;
    }
    location /static {
        proxy_pass http://192.168.136.129:90;
    }
}

测试:

反向代理示例: 缓存功能

cache is king 

压测

[root@nginx nginx]# ab -n1000 -c100 http://www.jieyu.org/static/index.html

每秒处理的请求量  

开始缓存配置 (缓存功能默认关闭状态,需要先动配置才能启用)

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

在http模块添加以下语句:

proxy_cache_path /usr/local/nginx/proxy_cache levels=1:2:2 keys_zone=proxycache:20m inactive=120s max_size=1g;

server {
    listen 80;
    server_name www.jieyu.org;

    location ~ \.php$ {
        proxy_pass http://192.168.136.128:80;
    }
    location /static {
        proxy_pass http://192.168.136.129:80;
        proxy_cache proxycache;
        proxy_cache_key $request_uri;
        proxy_cache_valid 200 302 301 10m;
        proxy_cache_valid any 1m;
    }
}

 再次压测

刚刚配置生成的文件

http 反向代理负载均衡 

需要有这些模块

upstream webcluster {
        server 192.168.136.128:80 fail_timeout=15s max_fails=3;
        server 192.168.136.129:80 fail_timeout=15s max_fails=3;
        server 192.168.136.100:80 backup;
}
server {
    listen 80;
    server_name www.jieyu.org;

    location / {
        proxy_pass http://webcluster;
    }
}

测试

ip_hash

源地址hash调度方法,基于的客户端的remote_addr(源地址IPv4的前24位或整个IPv6地址)做hash计 算,以实现会话保持

加入ip_hash后

 测试

hash $request_uri consistent; #基于用户请求的uri做hash

测试 

对cookie进行hash

基于cookie中的sessionid这个key进行hash调度,实现会话绑定测试down 标记为down状态,可以平滑下线后端服务

测试

实现 Nginx 四层负载均衡

域名解析负载均衡

两台主机安装bind服务,并编辑配置文件

[root@web1 ~]# vim /etc/named.rfc1912.zones
...
zone "jieyu.org" IN {
        type master;
        file "jieyu.org.zone";
        allow-update { none; };
};
...
[root@web1 named]# cat /var/named/jieyu.org.zone
$TTL 1D
@       IN SOA   ns.jieyu.org. root.jieyu.org. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      ns.jieyu.org.
ns      A       192.168.136.128
www     A       192.168.136.128

传给另一台服务器

[root@web1 named]# scp -p /etc/named.{conf,rfc1912.zones} root@192.168.136.129:/etc/
root@192.168.136.129's password:
named.conf                                                                           100% 1712     1.3MB/s   00:00
named.rfc1912.zones                                                                  100% 1115     2.0MB/s   00:00

[root@web1 named]# scp -p /var/named/jieyu.org.zone  root@192.168.136.129:/var/named/jieyu.org.zone

[root@web2 named]# chgrp named /var/named/jieyu.org.zone

实现 FastCGI

二进制下载nginx

[root@nginx nginx-1.24.0]# ./configure --prefix=/usr/local/nginx --add-module=/root/echo-nginx-module-0.63 --add-module=/root/memc-nginx-module-0.20 --add-module=/root/srcache-nginx-module-0.33 --user=nginx --group=nginx --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-stream --with-stream_ssl_module --with-stream_realip_module --with-pcre
[root@nginx nginx-1.24.0]# make && make install

二进制下载php 

利用yum解决php依赖

[root@Nginx ~]# yum install -y bzip2 systemd-devel libxml2-devel sqlite-devel
libpng-devel libcurl-devel oniguruma-devel

 oniguruma-devel 可能安装不了  去阿里下

[root@nginx php-8.3.9]# ./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-curl --with-iconv --with-mhash --with-zlib --with-openssl --enable-mysqlnd --with-mysqli --with-pdo-mysql --disable-debug --enable-sockets --enable-soap --enable-xml --enable-ftp --enable-gd --enable-exif --enable-mbstring --enable-bcmath --with-fpm-systemd
[root@nginx php-8.3.9]# make && make install

make && make install

php相关配置优化

[root@nginx php-8.3.9]# cd /usr/local/php/etc/
[root@nginx etc]# ls
php-fpm.conf.default  php-fpm.d
[root@nginx etc]# cp -p php-fpm.conf.default php-fpm.conf
去掉注释
[root@nginx etc]# vim php-fpm.conf
pid = run/php-fpm.pid   #指定pid文件存放位置

[root@nginx etc]# cd php-fpm.d/
[root@nginx php-fpm.d]# ls
www.conf.default
[root@nginx php-fpm.d]# cp www.conf.default www.conf -p
[root@nginx php-fpm.d]# vim www.conf

生成主配置文件 

[root@nginx php-8.3.9]# cp php.ini-production /usr/local/php/etc/php.ini
[root@nginx ~]# cd /usr/local/php/etc/
[root@nginx etc]# vim php.ini 

修改时区

生成启动文件

[root@nginx php-8.3.9]# cp sapi/fpm/php-fpm.service /lib/systemd/system

注释该内容

[root@nginx php-8.3.9]# systemctl daemon-reload 
[root@nginx php-8.3.9]# systemctl start php-fpm.service 
[root@nginx php-8.3.9]# netstat -launpt | grep php
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      147532/php-fpm: mas 

添加php环境变量

[root@nginx php-8.3.9]# vim ~/.bash_profile 

[root@nginx php-8.3.9]# source ~/.bash_profile 

 准备php测试页面

[root@nginx php-8.3.9]# mkdir /data/web/php -p
[root@nginx php-8.3.9]# cd /data/web/php
[root@nginx php]# vim index.php

<?php
    phpinfo();
?>

Nginx配置转发

Nginx安装完成之后默认生成了与fastcgi的相关配置文件,一般保存在nginx的安装路径的conf目录当 中,比如/apps/nginx/conf/fastcgi.conf、/apps/nginx/conf/fastcgi_params。

在主配置文件添加子配置文件

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

写nginx文件

[root@nginx ~]# mkdir /usr/local/nginx/conf.d
[root@nginx ~]# cd /usr/local/nginx/conf.d/
[root@nginx conf.d]# vim vhosts.conf

server {
        listen 80;
        server_name  www.jieyu.org;
        root /data/web/html;
        index index.html;

        location ~ \.php$ {
                root /data/web/php;
                fastcgi_pass 127.0.0.1:9000
                fastcgi_index index.php;
                include fastcgi.conf;
        }
}

测试访问 

php高速缓存  

php的动态扩展模块(php的缓存模块)

安装memcache模块

[root@Nginx ~]# tar zxf memcache-8.2.tgz
[root@Nginx ~]# cd memcache-8.2/
[root@Nginx memcache-8.2]# yum install autoconf
[root@Nginx memcache-8.2]# phpize
Configuring for:
PHP Api Version:         20200930
Zend Module Api No:      20200930
Zend Extension Api No:   420200930

[root@Nginx memcache-8.2]# ./configure && make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-nonzts-20230831/
[root@Nginx memcache-8.2]# ls /usr/local/php/lib/php/extensions/no-debug-non-zts20230831/
memcache.so opcache.so

复制测试文件到nginx发布目录中 

[root@Nginx ~]# cd memcache-8.2/
[root@Nginx memcache-8.2]# ls
autom4te.cache config.log configure.ac example.php Makefile.fragments
README
build config.m4 config.w32 include Makefile.objects runtests.php
config9.m4 config.nice CREDITS libtool memcache.la src
config.h config.status docker LICENSE memcache.php
tests
config.h.in configure Dockerfile Makefile modules
[root@Nginx memcache-8.2]# cp example.php memcache.php /data/web/php
[root@Nginx ~]# vim /data/php/memcache.php

 

配置php加载memcache模块 

[root@Nginx ~]# vim /usr/local/php/etc/php.ini

[root@Nginx ~]# systemctl reload php-fpm
[root@Nginx no-debug-non-zts-20230831]# php -m | grep mem
memcache

部署memcached 

[root@Nginx ~]# yum install memcached -y
[root@Nginx ~]# systemctl enable --now memcached.service
[root@Nginx ~]# netstat -antlupe | grep memcache
tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN
976 1037243 186762/memcached
[root@Nginx ~]# cat /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 127.0.0.1,::1"

测试:

输入用户和密码

访问 http://php.timinglee.org/memcache.php 查看命中效果 

性能对比 

[root@apache20 ~]# ab -n500 -c10 http://www.jieyu.org/index.php
@@@内容忽略@@@
Concurrency Level: 10
Time taken for tests: 0.514 seconds
Complete requests: 500
Failed requests: 44
(Connect: 0, Receive: 0, Length: 44, Exceptions: 0)
[root@apache20 ~]# ab -n500 -c10 http://www.jieyu.org/example.php
@@@内容忽略@@@
Concurrency Level: 10
Time taken for tests: 0.452 seconds
Complete requests: 500
Failed requests: 0


部署方法

在我们安装的nginx中默认不支持memc和srcache功能,需要借助第三方模块来让nginx支持此功能,所以nginx需要重新编译

[root@Nginx ~]# vim /usr/local/nginx/conf.d/vhosts.conf
upstream memcache {
  server 127.0.0.1:11211;
  keepalive 512;
}
server {
  listen 80;
  server_name www.jieyu.org;
  root /data/web/php;
  location /memc {
    internal;
    memc_connect_timeout 100ms;
    memc_send_timeout 100ms;
    memc_read_timeout 100ms;
    set $memc_key $query_string; #使用内置变量$query_string来作为key
    set $memc_exptime 300; #缓存失效时间300秒
    memc_pass memcache;
  }

  location ~ \.php$ {
    root /data/web/php;
    set $key $uri$args; #设定key的值
    srcache_fetch GET /memc $key; #检测mem中是否有要访问的php
    srcache_store PUT /memc $key; #缓存为加载的php数据
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi.conf;
  }
}
[root@nginx memcache-8.2]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

测压

[root@nginx ~ ]# ab -n500 -c10 http://www.jieyu.org/index.php

 

 

nginx 二次开发版本

openresty

 二进制安装

[root@nginx openresty]# ./configure --prefix=/usr/local/openresty --with-http_stub_status_module --with-http_gzip_static_module --with-http_sub_module --with-stream_ssl_module --with-stream_realip_module --with-pcre --with-stream --with-http_ssl_module \

# make && make install
[root@nginx bin]# vim ~/.bash_profile

[root@nginx bin]# source ~/.bash_profile
[root@nginx bin]# openresty
[root@nginx bin]# netstat -launpt | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      166940/nginx: maste

[root@nginx ~]# cd /usr/local/openresty/
[root@nginx openresty]# ls
bin  COPYRIGHT  luajit  lualib  nginx  pod  resty.index  site

 可以在里面进行开发

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2053942.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

来了...腾讯内推的软件测试面试PDF 文档(共107页)

不多说&#xff0c;直接上干货&#xff08;展示部分以腾讯面试纲要为例&#xff09;完整版文末领取 通过大数据总结发现&#xff0c;其实软件测试岗的面试都是差不多的。常问的有下面这几块知识点&#xff1a; 全网首发-涵盖16个技术栈 第一部分&#xff0c;测试理论&#x…

C++:平衡二叉搜索树之红黑树

一、红黑树的概念 红黑树&#xff0c; 和AVL都是二叉搜索树&#xff0c; 红黑树通过在每个节点上增加一个储存位表示节点的颜色&#xff0c; 可以是RED或者BLACK&#xff0c; 通过任何一条从根到叶子的路径上各个节点着色方式的限制&#xff0c;红黑树能够确保没有一条路径会比…

黑马头条vue2.0项目实战(九)——编辑用户资料

目录 1. 创建组件并配置路由 2. 页面布局 3. 展示用户信息 4. 修改昵称 5. 修改性别 6. 修改生日 7. 修改头像 7.1 图片上传预览 7.2 使用纯客户端的方式处理用户头像上传预览 7.3 头像裁切 7.4 纯客户端的图片裁切上传流程 7.5 Cropper.js 图片裁剪器的基本使用 …

盘点.软件测试工程师常见的面试题。面试官说我要定你了!

今天我们来聊聊软件测试工程师的面试题有哪些&#xff0c;2024年的8月份马上就过完了&#xff0c;金九银十就业季&#xff0c;跳槽季马上又要来了&#xff0c;毕竟在面试的战场上&#xff0c;知己知彼方能百战不殆。嗯嗯&#xff0c;不错说的真好&#xff01; 1、您所熟悉的测试…

24/8/15算法笔记 项目练习冰湖

import gym from matplotlib import pyplot as plt %matplotlib inline import os os.environ[SDL_VIDEODRIVER]dummy #设置环境变量 SDL_VIDEODRIVERdummy 是在使用基于 SDL (Simple DirectMedia Layer) 的应用程序时&#xff0c;告诉应用程序不使用任何视频驱动程序。这通常…

云计算实训29——mysql主从复制同步、mysql5.7版本安装配置、python操作mysql数据库、mycat读写分离实现

一、mysql主从复制及同步 1、mysql主从自动开机同步 2、配置mysql5.7版本 mysql-5.7.44-linux-glibc2.12-x86_64.tar 启动服务、登录 对数据库进行基本操作 3、使用python操纵mysql数据库 4、编辑python脚本自动化操纵mysql数据库 二、mycat读写分离实现 1.上传jdk和mycat安装…

【C语言】双链表

&#x1f984;个人主页:小米里的大麦-CSDN博客 &#x1f38f;所属专栏:C语言数据结构_小米里的大麦的博客-CSDN博客 &#x1f381;代码托管:黄灿灿/数据结构 (gitee.com) ⚙️操作环境:Visual Studio 2022 目录 一、什么是双链表&#xff1f; 二、双链表温习 1. 双链表的结构…

Windows 11 Build 27686 上手体验:2TB FAT32、更好的沙盒等功能

Windows 11 Build 27686 现已在 Insider Program 的 Canary 频道发布&#xff0c;其中包含一些有趣的内容。该版本确认了微软更改 FAT32 大小限制的计划&#xff0c;并将其大小限制从 32GB 提高到 2TB。与此同时&#xff0c;沙盒也得到了改进。让我们来详细了解一下此次更新。 …

Unity 麦扣 x 勇士传说 全解析 之 怪物基类(2)(附各模块知识的链接,零基础也包学会的牢弟)(案例难度:★★☆☆☆)

1.怪物的动画逻辑一览 2.怪物的受伤死亡逻辑一览 using System.Collections; using System.Collections.Generic; using System.Xml; using UnityEngine;public class Monster : MonoBehaviour {[Header("速度")]public float normalSpeed;public float chaseSpeed;…

Xinstall神器来袭:落地页与App无缝衔接,用户转化不再是难题

在移动互联网时代&#xff0c;App的推广与运营成为了各行各业的关键一环。然而&#xff0c;许多推广者在落地页跳转App这一环节上遇到了不小的挑战。用户点击落地页后&#xff0c;往往需要经过繁琐的步骤才能跳转到App&#xff0c;这不仅降低了用户体验&#xff0c;还严重影响了…

红明谷CTF 2022

MissingFile 前置知识 DPAPI&#xff1a; 全称&#xff1a;Data Protection Application Programming Interface DPAPI blob 一段密文&#xff0c;可以使用Master Key对其解密 Master Key 64字节&#xff0c;用于解密DPAPI blob&#xff0c;使用用户登录密码、SID和16字…

周易测算系统前景分析

周易测算系统作为一种结合传统文化与现代技术的服务平台。其市场前景分析如下&#xff1a; 市场需求增长&#xff1a;随着人们对传统文化的重视和对个性化服务的追求&#xff0c;周易测算系统市场需求正逐渐增长。特别是在互联网的背景下&#xff0c;周易预测服务与互联网的结…

java: 错误: 不支持发行版本

报这样的错误大概率是 idea 中的版本配置不统一导致的 通过确保四个位置的版本一致&#xff0c;解决版本不同的问题 第一个位置&#xff1a;Project ,确保 SDK 和 Project language level 的版本适配 第二个位置&#xff1a;Modules,确保需要运行的模块的 Language level 正确…

本地下载安装WampServer结合内网穿透配置公网地址远程访问详细教程

文章目录 前言1.WampServer下载安装2.WampServer启动3.安装cpolar内网穿透3.1 注册账号3.2 下载cpolar客户端3.3 登录cpolar web ui管理界面3.4 创建公网地址 4.固定公网地址访问 前言 Wamp 是一个 Windows系统下的 Apache PHP Mysql 集成安装环境&#xff0c;是一组常用来…

AI浪潮下的教育革新:把握机遇,拥抱变化!

在全球范围内&#xff0c;AI技术正以前所未有的速度改变着我们的生活和工作方式。据麦肯锡数据预测&#xff0c;到2045年左右&#xff0c;有50%的工作将被AI替代。与此同时&#xff0c;具有创造力、深度思考的高阶智力的人才&#xff0c;将享受到AIGC带来的效率优势&#xff0c…

Maven的依赖范围

依赖的jar包&#xff0c;默认情况下&#xff0c;可以在任何地方使用&#xff0c;可以通过scope来设置作用范围 作用范围&#xff1a; 主程序范围有效&#xff08;main文件夹范围内&#xff09;测试程序范围有效&#xff08;test文件夹范围内&#xff09;是否参与打包运行&…

HTML静态网页成品作业(HTML+CSS)——古诗词网设计制作(5个页面)

&#x1f389;不定期分享源码&#xff0c;关注不丢失哦 文章目录 一、作品介绍二、作品演示三、代码目录四、网站代码HTML部分代码CSS部分代码 五、源码获取 一、作品介绍 &#x1f3f7;️本套采用HTMLCSS&#xff0c;未使用Javacsript代码&#xff0c;共有5个页面。 &#x1…

产线一直在用的 RabbitMQ 搭建教程(含负载均衡配置,验证脚本,监控案例),偷偷抄出来的,建议收藏备用

本文介绍公司一直在用的 rabbitmq 集群安装部署过程&#xff0c;版本不算太新&#xff0c;但一直稳定运行&#xff0c;对其他版本安装也有一定的参考价值&#xff0c;建议收藏备用。 简介 官网&#xff1a;https://www.rabbitmq.com/ RabbitMQ 是一个开源的遵循 AMQP(Advance…

超详细的Vue新手向教程

一&#xff0c;前言 本篇文章的正文部分为渐近式介绍Vue基础中的OptionAPI和相关指令&#xff0c;在两大内容之外&#xff0c;本文结尾处会附上vue的特性。 ps:本文总字数过22000&#xff0c;足够详细&#xff0c;尽量新手向的同时也包含一些原理性知识&#xff0c;部分内容…

TILs 评分:TCGA 肿瘤浸润淋巴细胞病理切片深度学习评分!图片下载与可视化

生信碱移 病理切片的TILs评分 TCGA 数据库是最大的肿瘤组学公开数据库之一。尽管如此&#xff0c;更多的研究往往仅局限于关注 TCGA 中各类肿瘤样本的上游组学信息或基本病理特征&#xff0c;而忽略了对样本数字化 H&E 病理染色图像的进一步应用。 ▲ TCGA中肿瘤样本的病…