当前位置 主页 > 服务器问题 > nginx问题汇总 >

    Nginx服务器如何安装?

    栏目:nginx问题汇总 时间:2019-07-09 10:42

      我们编译安装nginx来定制自己的模块,机器CentOS 6.2 x86_64。首先安装缺少的依赖包:1# yum -y install gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre pcre-devel
      这些软件包如果yum上没有的话可以下载源码来编译安装,只是要注意编译时默认安装的目录,确保下面在安装nginx时能够找到这些动态库文件(ldconfig)。
      从 http://nginx.org/en/download.html 下载稳定版nginx-1.6.3.tar.gz到/usr/local/src下解压。
      为了后续准备我们另外下载2个插件模块:nginx_upstream_check_module-0.3.0.tar.gz —— 检查后端服务器的状态,nginx-goodies-nginx-sticky-module-ng-bd312d586752.tar.gz(建议在/usr/local/src下解压后将目录重命名为nginx-sticky-module-ng-1.2.5) —— 后端做负载均衡解决session sticky问题(与upstream_check模块结合使用需要另外打补丁,请参考nginx负载均衡配置实战)。
      请注意插件与nginx的版本兼容问题,一般插件越新越好,nginx不用追新,稳定第一。nginx-1.4.7,nginx-sticky-module-1.1,nginx_upstream_check_module-0.2.0,这个搭配也没问题。sticky-1.1与nginx-1.6版本由于更新没跟上编译出错。(可以直接使用Tengine,默认就包括了这些模块)
      [root@cachets nginx-1.6.3]# pwd
      /usr/local/src/nginx-1.6.3
      [root@cachets nginx-1.6.3]# ./configure --prefix=/usr/local/nginx-1.6 --with-pcre \
      > --with-http_stub_status_module --with-http_ssl_module \
      > --with-http_gzip_static_module --with-http_realip_module \
      > --add-module=../nginx_upstream_check_module-0.3.0
      [root@cachets nginx-1.6.3]# make && make install