nginx1.12 tar包编译安装

nginx1.12 tar包编译安装

  • 安装依赖

    yum install -y gcc gcc-c++ pcre pcre-devel openssl openssl-devel zlib zlib-devel
    
  • 下载nginx源码包解压到当前目录

    tar zxvf  nginx-1.12.0.tar.gz
    
    [root@localhost ~]# cd nginx-1.12.0
    [root@localhost nginx-1.12.0]# ll
    total 700
    drwxr-xr-x 6 1001 1001    326 Nov 27 20:29 auto
    -rw-r--r-- 1 1001 1001 277049 Apr 12  2017 CHANGES
    -rw-r--r-- 1 1001 1001 421985 Apr 12  2017 CHANGES.ru
    drwxr-xr-x 2 1001 1001    168 Nov 27 20:29 conf
    -rwxr-xr-x 1 1001 1001   2481 Apr 12  2017 configure
    drwxr-xr-x 4 1001 1001     72 Nov 27 20:29 contrib
    drwxr-xr-x 2 1001 1001     40 Nov 27 20:29 html
    -rw-r--r-- 1 1001 1001   1397 Apr 12  2017 LICENSE
    drwxr-xr-x 2 1001 1001     21 Nov 27 20:29 man
    -rw-r--r-- 1 1001 1001     49 Apr 12  2017 README
    drwxr-xr-x 9 1001 1001     91 Nov 27 20:29 src
    
  • 查看nginx版本支持的编译模块

    [root@localhost nginx-1.12.0]# ./configure --help
    
      --help                             print this message
    
      --prefix=PATH                      set installation prefix
      --sbin-path=PATH                   set nginx binary pathname
      --modules-path=PATH                set modules path
      --conf-path=PATH                   set nginx.conf pathname
      --error-log-path=PATH              set error log pathname
      --pid-path=PATH                    set nginx.pid pathname
      --lock-path=PATH                   set nginx.lock pathname
    
      --user=USER                        set non-privileged user for
                                         worker processes
      --group=GROUP                      set non-privileged group for
                                         worker processes
    
      --build=NAME                       set build name
      --builddir=DIR                     set build directory
    
      --with-select_module               enable select module
      --without-select_module            disable select module
      --with-poll_module                 enable poll module
      --without-poll_module              disable poll module
    
    
  • 生成Makefile文件

     ./configure --with-http_v2_module --with-http_ssl_module --with-http_sub_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre
    
  • 编译源代码并安装

    make && make install
    
  • 创建nginx命令软链接到环境变量

    ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
    
  • 设置开机自启

    echo '/usr/local/nginx/sbin/nginx' >> /etc/rc.d/rc.local
    chmod +x /etc/rc.d/rc.local
    
  • 启动nginx

    nginx
    
  • 查看所有load的模块

    [root@localhost ~]#nginx -V
    nginx version: nginx/1.12.0
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) 
    built with OpenSSL 1.0.1e-fips 11 Feb 2013
    TLS SNI support enabled
    configure arguments: --with-http_v2_module --with-http_ssl_module --with-http_sub_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre
    
    
  • 在已安装nginx情况下安装nginx模块

./configure --prefix=/usr/local/nginx  --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --add-module=../ngx_pagespeed-master --add-module=/第三方模块目录
make //不要make install
nginx -s stop
cp objs/nginx /usr/local/nginx/sbin/nginx
nginx //启动nginx

猜你喜欢

转载自blog.csdn.net/sinat_39562444/article/details/84585581