首页 > 系统相关 >安装nginx-http-concat和nginx平滑升級

安装nginx-http-concat和nginx平滑升級

时间:2023-04-20 11:39:12浏览次数:31  
标签:http -- 升級 module nginx usr local


评:
Nginx_concat_module 是淘宝开发的基于Nginx减少HTTP请求数量的扩展模块,主要是用于合并减少前端用户Request的HTTP请求的数量


下载后把它放在/usr/local/src/文件夹中,到时候nginx需要指定该目录


这个需要重新编译nginx,所以顺便把nginx升级了下。


下载最新版本




Linux代码 收藏代码

wget http://nginx.org/download/nginx-1.0.15.tar.gz



查看之前安装时怎么配置的,copy下红色代码,这里是下面要用到的


Linux代码 收藏代码

/usr/local/nginx/sbin/nginx -V

TLS SNI support disabled
configure arguments: <strong>--</strong>
prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --http-proxy-temp-path=/var/nginx/proxy --http-fastcgi-temp-path=/var/nginx/fastcgi --http-client-body-temp-path=/var/nginx/client



开始安装,在上面的配置中添加 --add-module=/usr/local/src/nginx-http-concat 这段


Linux代码 收藏代码

tar zxvf nginx-1.0.15.tar.gz
cd nginx-1.0.15.tar.gz

./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --http-proxy-temp-path=/var/nginx/proxy --http-fastcgi-temp-path=/var/nginx/fastcgi --http-client-body-temp-path=/var/nginx/client --add-module=/usr/local/src/nginx-http-concat




Linux代码 收藏代码

make



执行到这里就好了,千万不要 make install


为了防止意外发生啊,先备份先老版本


Linux代码 收藏代码

mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old



把刚刚编译过的文件copy过去


Linux代码 收藏代码

cp -a nginx /usr/local/nginx/sbin/



检测一下 NGINX 是否正常。


Linux代码 收藏代码

/usr/local/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



到这里升级nginx就可以了,如果要使用http-concat的话还需要修改nginx.conf文件,在里面添加下面代码




Linux代码 收藏代码

location /js/ {
# 打开concat 功能
# 默认关闭
concat on;
# 允许concat最大的文件数(http://m114.org/test/??1.css,2.css,3.css...10.css) 默认最大设置十个文件。
# (默认: 10)
# concat_max_files 10;
# 只允许相同类型的文件(例:http://m114.org/test/??m114.css,m23.js 默认情况下是不允许的)
# 默认是开启的
# concat_unique on;
# 允许内容的类型
# (default: application/x-javascript, text/css)
# concat_types text/html;
}



安装好了如何使用呢?


http://localhost/js/??a.js,b.js

两个问号(??),需要合并的文件(a.js,b.js)

标签:http,--,升級,module,nginx,usr,local
From: https://blog.51cto.com/u_16080829/6209259

相关文章

  • nginx 安装
    评:nginx可以使用各平台的默认包来安装,本文是介绍使用源码编译安装,包括具体的编译参数信息。正式开始前,编译环境gccg++开发库之类的需要提前装好,这里默认你已经装好。ububtu平台编译环境可以使用以下指令apt-getinstallbuild-essentialapt-getinstalllibtoolcento......
  • nginx location规则以及优先级详解
    nginx配置文件里往往有多个location来区分不同的路径来执行不同的配置 在nginx配置文件中,location主要有这几种形式:1、~#使用波浪符“~”区分大小写正则匹配,如location~/abc{}2、~*#不区分大小写的正则匹配,如location~*/abc{}3、^~#匹配路径的前缀,如......
  • Nacos笔记(五):Nacos集群整合Nginx
    前言Nginx搭建,参考:Linux安装Nginx。1、Nginx配置添加nacos集群,调整端口与服务名,并设置代理,详情如下:   配置详情如下http{includemime.types;default_typeapplication/octet-stream;sendfileon;keepalive_timeout......
  • http 前端5种请求优化方法
    1、减少请求数量:可以通过将多个资源(例如JavaScript、CSS、图像等)合并为单个文件,从而减少HTTP请求的数量。另外,使用CDN(内容分发网络)也可以减少跨地                域的请求延迟。2、缓存请求结果:对于一些不会频繁更新的资源,可以将它......
  • 【Nginx】Nginx介绍及配置详解
    Nginx是什么Nginx("enginex")是一个高性能的HTTP和反向代理服务器,特点是占有内存少,并发能力强。Nginx官网:http://nginx.org/Nginx安装Nginx官网下载地址:http://nginx.org/en/download.html其中nginx-1.23.4这一列是Linux版本。Windows安装解压Nginx压缩包后,目录如下:启动n......
  • Ingress nginx配置同一个域名不同的path访问不同的service
    配置同一个域名,不同的path,访问不同的service  #重写URL  #当您访问http://<ingress_ip>/foo/bar时,nginxingresscontroller将把请求路由到foo-service的80端口,并将原始请求的路径/foo/bar重写为/bar。    #nginx.ingress.kubernetes.io/rewrite-ta......
  • fix Linux apt-get install package HTTPS error All In One
    fixLinuxapt-getinstallpackageHTTPSerrorAllInOneerrorsE:Themethoddriver/usr/libapt/methods/httpscouldnotbefound.N:Isthepackageapt-transport-httpsinstalled?solutionssymbollinksoftlink/软链接$cd/usr/lib/apt/methods#symbo......
  • chatgpt--http
    Java可以通过很多方式来实现http请求,其中比较常用的有以下几种方式:1.HttpURLConnection:Java提供的标准库中的一个类,可以轻松处理http请求和响应,支持GET、POST、PUT、DELETE等请求方式。以下是一个使用HttpURLConnection发送GET请求的示例代码:```javaURLurl=......
  • vue项目部署后 nginx配置重定向 大文件报错问题
      删除Nginx缓存文件试试?#rm-rf/usr/local/nginx/proxy_temp  注意proxy_busy_buffers_size是proxy_buffers的两倍,proxy_temp_file_write_size也要比proxy_buffers大。  ......
  • uhttp luci simple-app
    uhttplucisimple-appseehttps://forum.openwrt.org/t/rest-api-supported-in-openwrt/17210/6 YouprobablydowantLuci,oratleasttotakealookathowLucidoesit.POSTdataisinthebodyoftherequest.Lucicreatesa ltn12compatiblesourcetorea......