车皮 发表于 2018-11-11 09:21:57

nginx编译安装和未编译模块的添加

  安装nginx
  Yum 安装
  参考http://nginx.org/en/linux_packages.html
  编译安装nginx
  系统首先要安装gcc* 包以及一些依赖包
  # wget http://nginx.org/download/nginx-1.8.0.tar.gz
  # tar xf nginx-1.8.0.tar.gz -C /usr/local/src/
  # cd /usr/local/src/nginx-1.8.0/
  #
  备注: 每个版本不一样,默认安装的模块可能有所不同
  详细可参考官网:
  http://nginx.org/en/docs/configure.html
  或者
  # ./configure –help 根据需求选择需要的模块
  # yum install gcc*   pcre pcre-devel openssl openssl-devel zlibzlib-devel –y
  # useradd nginx -s /sbin/nologin –M
  # ./configure --prefix=/usr/local/webserver/nginx--with-http_ssl_module   --with-http_flv_module   --with-http_gunzip_module   --with-http_stub_status_module
  # make && make install
  make: Leaving directory `/usr/local/src/nginx-1.8.0'
  查看nginx安装的模块
  #/usr/local/webserver/nginx/sbin/nginx -V
  nginx version: nginx/1.8.0
  built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
  built with OpenSSL 1.0.1e-fips 11 Feb 2013
  TLS SNI support enabled
  configure arguments: --prefix=/usr/local/webserver/nginx--with-http_ssl_module --with-http_flv_module --with-http_gunzip_module--with-http_stub_status_module
  nginx 编译根据业务需要需要开启的模块
  --with-http_ssl_module             enable ngx_http_ssl_module
  --with-http_spdy_module         enable ngx_http_spdy_module
  --with-http_realip_module         enable ngx_http_realip_module
  --with-http_addition_module       enable ngx_http_addition_module
  --with-http_xslt_module         enable ngx_http_xslt_module
  --with-http_image_filter_module   enable ngx_http_image_filter_module
  --with-http_geoip_module          enable ngx_http_geoip_module
  --with-http_sub_module            enable ngx_http_sub_module
  --with-http_dav_module            enable ngx_http_dav_module
  --with-http_flv_module             enable ngx_http_flv_module
  --with-http_mp4_module             enable ngx_http_mp4_module
  --with-http_gunzip_module          enable ngx_http_gunzip_module
  --with-http_gzip_static_module   enable ngx_http_gzip_static_module
  --with-http_auth_request_module   enable ngx_http_auth_request_module
  --with-http_random_index_module   enable ngx_http_random_index_module
  --with-http_secure_link_module    enable ngx_http_secure_link_module
  --with-http_degradation_module    enable ngx_http_degradation_module
  --with-http_stub_status_module   enable ngx_http_stub_status_module
  Nginx如何添加未编译的模块
  重新编译
  # ./configure--prefix=/usr/local/webserver/nginx--with-http_ssl_module --with-http_flv_module --with-http_gunzip_module--with-http_stub_status_module   --with-http_realip_module--with-http_flv_module   &&make
  # ls
  autoCHANGESCHANGES.ru confconfigurecontrib htmlLICENSEMakefile manobjsREADME src
  #make 完成之后会生成一个objs目录会多出一个nginx,他就是新编译成的nginx程序,只需要将objs/nginx 拷贝到/usr/local/webserver/nginx/sbin/覆盖原有的nginx程序即可
  如果此时nginx在运行的将nginx关闭,然后备份原有的nginx程序
  # cp/usr/local/webserver/nginx/sbin/nginx   /usr/local/webserver/nginx/sbin/nginx.bak
  拷贝新的nginx程序覆盖原有的nginx
  # cp objs/nginx/usr/local/webserver/nginx/sbin/nginx
  cp: overwrite `/usr/local/webserver/nginx/sbin/nginx'? y
  查看编译模块
  #/usr/local/webserver/nginx/sbin/nginx -V
  nginx version: nginx/1.8.0
  built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
  built with OpenSSL 1.0.1e-fips 11 Feb 2013
  TLS SNI support enabled
  configure arguments: --prefix=/usr/local/webserver/nginx--with-http_ssl_module --with-http_flv_module --with-http_gunzip_module--with-http_stub_status_module --with-http_realip_module --with-http_flv_module
  第三方模块的安装
  https://www.nginx.com/resources/wiki/modules/index.html

页: [1]
查看完整版本: nginx编译安装和未编译模块的添加