Nginx安装并启用gzip模块

  • 环境介绍
    在这里插入图片描述

  • 安装依赖

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

在这里插入图片描述

posted @ 2021-06-10 16:25  小来丝  阅读(978)  评论(0编辑  收藏  举报