您的位置:首页 > 运维架构 > Nginx

阿里云服务器升级nginx 到最新稳定版

2017-01-05 23:01 387 查看
阿里云市场有一个2元钱的服务器安装包,一次购买无限次使用,可以一键安装mysql、nginx、php环境。其中nginx是1.4.4版的,而现在最新稳定版是1.10.2,因为某些原因,必须升级到更高版本。从网上查了一下,可以在原程序包的基础上做到无缝隙升级而不用apt-get重装,关键是这个安装包里,用apt-get无法升级。以下是升级步骤:

1.到nginx官网下载资源包到home文件夹:nginx-1.10.2.tar.gz

2.解压,并进入nginx-1.10.2文件夹,如要提示有权限问题,请升级这个文件夹的权限。

3. 执行下面的命令【各种目录,要和老版一一对应,这很重要!】:

./configure --user=www --group=www --prefix=/alidata/server/nginx-1.4.4 --conf-path=/alidata/server/nginx-1.4.4/conf/nginx.conf --error-log-path=/alidata/log/nginx/error.log --http-client-body-temp-path=/alidata/server/nginx-1.4.4/client_body_temp --http-fastcgi-temp-path=/alidata/server/nginx-1.4.4/fastcgi_temp --http-log-path=/alidata/log/nginx/access/access.log --http-proxy-temp-path=/alidata/server/nginx-1.4.4/proxy_temp --http-scgi-temp-path=/alidata/server/nginx-1.4.4/scgi_temp --http-uwsgi-temp-path=/alidata/server/nginx-1.4.4/uwsgi_temp --lock-path=/var/lock/nginx.lock --pid-path=/alidata/server/nginx/logs/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module


4.补充几个依赖包【这一步应在第3步之前执行】

apt-get install libxml2 libxml2-dev libxslt-dev
apt-get install libgd2-xpm libgd2-xpm-dev
apt-get install geoip-database libgeoip-dev
apt-get install libpcre3 libpcre3-dev
apt-get install libcurl4-openssl-dev


5.执行make

6.执行老版本备份:

mv /alidata/server/nginx-1.4.4/sbin/nginx /alidata/server/nginx-1.4.4/sbin/nginx20170105


7.把make 到新文件复制到相关文件夹:

cp objs/nginx /alidata/server/nginx-1.4.4/sbin/nginx


8.执行以下命令:

/alidata/server/nginx-1.4.4/sbin/nginx -t


得到:

nginx: the configuration file /alidata/server/nginx-1.4.4/conf/nginx.conf syntax is ok
nginx: configuration file /alidata/server/nginx-1.4.4/conf/nginx.conf test is successful


9.在nginx1.10.2文件夹执行:

make upgrade


10.执行nginx -v查看版本,已经是新版本了,重启nginx!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx ubuntu linux 阿里云