Nginx安装并启用gzip模块

  • 环境介绍
    Nginx安装并启用gzip模块_第1张图片

  • 安装依赖

yum -y install make cmake gcc gcc-c++ pcre pcre-devel zlib zlib-devel  autoconf libtool glibc-devel  openssl openssl-devel unzip vim
  • 解压并安装
tar -zxf nginx-1.18.0.tar.gz
cd nginx-1.18.0/
./configure --with-http_gzip_static_module
make && make install
  • /usr/local/nginx/conf/nginx.conf内增加配置
http {
    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 32k;
    gzip_http_version 1.1;
    gzip_comp_level 5;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
    gzip_vary on;
    gzip_proxied any;
    gzip_disable "MSIE [1-6]\.";
    }
  • 检查配置并启动
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -V
/usr/local/nginx/sbin/nginx

Nginx安装并启用gzip模块_第2张图片

你可能感兴趣的:(Nginx相关类记录随笔,nginx,linux,centos,运维)