开发者社区> 问答> 正文

centos 6.5 系统下的 nginx 1.4.4怎样升级?

1.4.4 提示有漏洞

展开
收起
秋日的私语 2015-12-16 12:05:56 9430 0
2 条回答
写回答
取消 提交回答
  • 回 1楼(买醉) 的帖子
    非常感谢大师的回答。那其它几个软件 在哪下载 呢?我按http://undefinedblog.com/seamlessly-upgrade-nginx-on-centos/这个教程升级,却出错:
    cd /alidata/server/

    tar -zcvf nginx.tar.gz /alidata/server/nginx-1.4.4/*

    wget http://nginx.org/download/nginx-1.8.0.tar.gz

    tar -zxvf nginx-1.8.0.tar.gz

    yum install gcc openssl-devel pcre-devel zlib-devel

    如果你不清楚编译时的选项,可以参考现有 nginx 的编译选项,查看方法
    /alidata/server/nginx-1.4.4/sbin/nginx -V

    得到结果如下
    nginx version: nginx/1.4.4
    built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
    TLS SNI support enabled
    configure arguments: --user=www --group=www --prefix=/alidata/server/nginx --with-http_stub_status_module --without-http-cache --with-http_ssl_module --with-http_gzip_static_module

    其中 configure arguments 就是当前运行的 nginx 编译时的命令,找到这些命令后我们开始编译新的 nginx
    ./configure arguments: --user=www --group=www --prefix=/alidata/server/nginx --with-http_stub_status_module --without-http-cache --with-http_ssl_module --with-http_gzip_static_module

    这一步编译出错了:
    ./configure arguments: --user=www --group=www --prefix=/alidata/server/nginx --with-http_stub_status_module --without-http-cache --with-http_ssl_module --with-http_gzip_static_module
    ./configure: error: invalid option "arguments:"



    大师的升级步骤解读,不知是不是这样呢?
    cd /tmp/nginxup    \\进入原nginx目录
    tar xvf openssl-x.x.x.tar.gz   \\解包
    tar xvf pcre-x.x.x.tar.gz   \\解包
    tar zxvf zlib-x.x.x.tar.gz   \\解包
    tar xvf nginx-.x.x.x.tar.gz   \\解包
    cd nginx-x.x.x   \\进入新nginx目录
    ./configure --user=运行账号 --group=运行账号 --prefix=/nginx的安装路径/nginx --with-pcre=/tmp/nginxup/pcre-x.x.x --with-zlib=/tmp/nginxup/zlib-x.x.x --with-openssl=/tmp/nginxup/openssl-x.x.x --with-http_stub_status_module --with-http_ssl_module --with-rtsig_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_random_index_module --with-http_stub_status_module --without-http_upstream_ip_hash_module --with-mail --with-mail_ssl_module --with-cpu-opt=opteron   \\编译nginx
    make  \\安装
    rm -rf /nginx的安装路径/nginx/sbin/nginx.bak   \\删除原nginx目录?
    mv /nginx的安装路径/nginx/sbin/nginx /nginx的安装路径/nginx/sbin/nginx.bak  将原nginx目录重命名为nginx.bak?
    cp objs/nginx /nginx的安装路径/nginx/sbin/    复制编译好的objs/nginx到原目录
    /nginx的安装路径/nginx/sbin/nginx -s reload  平滑重启nginx




    -------------------------

    用rpm -qa|grep 查询,这几个软件包都安装过了:
    rpm -qa|grep openssl

    openssl-1.0.1e-30.el6.11.i686
    openssl-devel-1.0.1e-30.el6.11.i686

    rpm -qa|grep pcre
    pcre-7.8-6.el6.i686


    rpm -qa|grep zlib
    zlib-1.2.3-29.el6.i686
    zlib-devel-1.2.3-29.el6.i686


    当初安装nginx1.4.4时的脚本是:
    #!/bin/bash
    rm -rf nginx-1.4.4
    if [ ! -f nginx-1.4.4.tar.gz ];then
      wget http://oss.aliyuncs.com/aliyunecs/onekey/nginx/nginx-1.4.4.tar.gz
    fi
    tar zxvf nginx-1.4.4.tar.gz
    cd nginx-1.4.4
    ./configure --user=www \
    --group=www \
    --prefix=/alidata/server/nginx \
    --with-http_stub_status_module \
    --without-http-cache \
    --with-http_ssl_module \
    --with-http_gzip_static_module
    CPU_NUM=$(cat /proc/cpuinfo | grep processor | wc -l)
    if [ $CPU_NUM -gt 1 ];then
        make -j$CPU_NUM
    else
        make
    fi
    make install
    chmod 775 /alidata/server/nginx/logs
    chown -R www:www /alidata/server/nginx/logs
    chmod -R 775 /alidata/www
    chown -R www:www /alidata/www
    cd ..
    cp -fR ./nginx/config-nginx/* /alidata/server/nginx/conf/
    sed -i 's/worker_processes  2/worker_processes  '"$CPU_NUM"'/' /alidata/server/nginx/conf/nginx.conf
    chmod 755 /alidata/server/nginx/sbin/nginx
    #/alidata/server/nginx/sbin/nginx
    mv /alidata/server/nginx/conf/nginx /etc/init.d/
    chmod +x /etc/init.d/nginx
    /etc/init.d/nginx start







    -------------------------

    我按以下命令操作,没有报错,不过目录里没有编译好的文件 ,启动不了nginx:
    cd /alidata/server/
    tar -zcvf nginx1.4.4bak.tar.gz /alidata/server/nginx-1.4.4/*
    wget http://nginx.org/download/nginx-1.8.0.tar.gz
    tar -zxvf nginx-1.8.0.tar.gz
    cd nginx-1.8.0
    ./configure --user=www \
    --group=www \
    --prefix=/alidata/server/nginx \
    --with-http_stub_status_module \
    --without-http-cache \
    --with-http_ssl_module \
    --with-http_gzip_static_module
    /alidata/server/nginx-1.4.4/sbin/nginx -s stop
    mv /alidata/server/nginx-1.4.4/sbin/nginx /alidata/server/nginx-1.4.4/sbin/nginx.old
    cp objs/nginx /alidata/server/nginx-1.4.4/sbin/nginx
    /alidata/server/nginx-1.4.4/sbin/nginx -s start









    -------------------------

    回 5楼(买醉) 的帖子
    感谢提醒,确实是少了make,还有启动命令是./nginx,成功升级到1.8.0了。
    2015-12-17 19:22:31
    赞同 展开评论 打赏
  • 纯手工升级


    首先找到老版本的nginx安装路径和运行账号

    1.准备软件
    openssl-x.x.x.tar.gz
    pcre-.x.x.x.tar.gz
    zlib-x.x.x.tar.gz
    nginx-x.x.x.tar.gz
    (x.x.x为版本号)

    2.把这4个软件放在/tmp/nginxup目录下(当然你也可以放在其他目录下)

    3.开始升级:

    cd /tmp/nginxup
    tar xvf openssl-x.x.x.tar.gz
    tar xvf pcre-x.x.x.tar.gz
    tar zxvf zlib-x.x.x.tar.gz

    tar xvf nginx-.x.x.x.tar.gz
    cd nginx-x.x.x
    ./configure --user=运行账号 --group=运行账号 --prefix=/nginx的安装路径/nginx --with-pcre=/tmp/nginxup/pcre-x.x.x --with-zlib=/tmp/nginxup/zlib-x.x.x --with-openssl=/tmp/nginxup/openssl-x.x.x --with-http_stub_status_module --with-http_ssl_module --with-rtsig_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_random_index_module --with-http_stub_status_module --without-http_upstream_ip_hash_module --with-mail --with-mail_ssl_module --with-cpu-opt=opteron
    make
    rm -rf /nginx的安装路径/nginx/sbin/nginx.bak
    mv /nginx的安装路径/nginx/sbin/nginx /nginx的安装路径/nginx/sbin/nginx.bak
    cp objs/nginx /nginx的安装路径/nginx/sbin/
    /nginx的安装路径/nginx/sbin/nginx -s reload




    同样适合tengine升级,只要把

    tar xvf nginx-.x.x.x.tar.gz
    cd nginx-x.x.x


    换成

    tar xvf tengine-.x.x.x.tar.gz
    cd tengine-x.x.x



    -------------------------

    看了你的命令,你没有make 怎么可能编译成功

    -------------------------

    回 6楼(秋日的私语) 的帖子
    ./nginx -s reload 命令是刷新命令,升级nginx的时候不需先关闭或者重启的,所以刷新下就行了
    2015-12-16 22:30:27
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《Nginx 代理系统常用手册》 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载