问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

如何升级nginx到最新稳定版

发布网友 发布时间:2022-04-22 10:10

我来回答

1个回答

热心网友 时间:2023-05-21 09:54

我的环境:

Ubuntu 12.04 LTS
Nginx 1.1.9
Nginx是通过apt-get的方式安装的,所以我的路径与下载代码再编译、安装的有些不一样,我的升级过程如下

1.进入Downloads文件夹

cd /Downloads
2.下载nginx-1.2.5.tar.gz文件到Downloads文件夹中

wget http://nginx.org/download/nginx-1.2.5.tar.gz
3.解压nginx-1.2.5.tar.gz文件

tar zxvf nginx-1.2.5.tar.gz
4.进入ngixn-1.2.5文件夹中

cd nginx-1.2.5
5.查看nginx原来的配置

nginx -V
上面的命令将输出:

复制代码
--prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_mole --with-http_dav_mole --with-http_geoip_mole --with-http_gzip_static_mole --with-http_image_filter_mole --with-http_realip_mole --with-http_stub_status_mole --with-http_ssl_mole --with-http_sub_mole --with-http_xslt_mole --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_mole
复制代码
6.执行configure命令,后面跟上原来nginx的配置

复制代码
./configure --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_mole --with-http_dav_mole --with-http_geoip_mole --with-http_gzip_static_mole --with-http_image_filter_mole --with-http_realip_mole --with-http_stub_status_mole --with-http_ssl_mole --with-http_sub_mole --with-http_xslt_mole --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_mole
复制代码
在执行configure时得到几个错误:

a.配置 --with-http_xslt_mole 时提示 the HTTP XSLT mole requires the libxml2/libxslt libraries

sudo apt-get install libxml2 libxml2-dev libxslt-dev
b.配置 --with-http_image_filter_mole 时提示 the HTTP image filter mole requires the GD library.

sudo apt-get install libgd2-xpm libgd2-xpm-dev
c.配置 --with-http_geoip_mole 时提示 the GeoIP mole requires the GeoIP library.

sudo apt-get install geoip-database libgeoip-dev
d.rewrite需要pcre支持, 错误提示:./configure: error: the HTTP rewrite mole requires the PCRE library.

apt-get install libpcre3 libpcre3-dev

7.再执行第6步的configure命令

8.这次没有提示缺少library, 执行make令命编译nginx, 编译好以后objs目录下多出一个nginx文件,这个就是已编辑好的nginx程序

make
9.更改旧的nginx程序的名子,并复制新的程序过去,我的旧nginx程序放在/usr/sbin/目录中

mv /usr/sbin/nginx /usr/sbin/nginx-20121122
cp objs/nginx /usr/sbin/nginx
/usr/sbin/nginx -t
执行/usr/sbin/nginx -t 命令检查配置文件并将返回下面的信息:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
10.在nginx-1.2.5目录下执行下面的命令来升级nginx

make upgrade
11.执行make upgrade得到一个错误:

make: /etc/nginx/sbin/nginx: Command not found
make: *** [upgrade] Error 127
12.用文本编辑器打开修改nginx-1.2.5目录下名为Makefile的文件,将upgrade节点中的/etc/nginx/sbin/nginx改为/usr/sbin/nginx -t,保存后关闭并重新执行make upgrade命令

13.执行nginx -v命令,程序的版本号已经是1.2.5,升级完毕.
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
这是什么钞票。 请问这是哪个国家的钞票?价值多少人民币?谢谢 快易典学生平板电脑屏幕碎了怎么办,我在书店买的,可以拿到书店修吗... 沧州龟头周围有一圈小肉粒是什么? 快易典学生电脑的屏幕摔坏了,触屏触不了,可以修吗?如果修的话要多少... 西班牙冷汤和哪些菜品搭配更好喝? 西班牙番茄冷汤提示 我想请问你在秦汉胡同学学古筝...一共需要多少钱啊,包括买古筝的钱 word2010如何查看和编辑文档? 胸罩带子老掉,罩杯边有空 爱的教育 读后感急急急急急急 nginx 判断其他url是否能访问 爱的教育读后感600字,最好原创 爱的教育读后感500字。 你好,我的作文 爱的教育读后感94左右 如何用DNS+GeoIP+Nginx+Varnish做世界级的CDN 爱的教育读后感及自我评价 yum 安装的nginx 怎么编译 geoip 《爱的教育》士兵主要内容和精彩句段? geoip 在nginx 上怎么用 爱的教育读后感263个字。 娱乐男明星人气排行榜投票需要费用吗?需要买票? 爱的教育 读后感 800字左右 写猫飞檐走壁的作文 急求一篇《爱的教育》读后感 娱乐圈女明星人气排行榜投票杨颖第几 小猫的说明文 求《爱的教育》之《少年鼓手》读后感。 小猫的生活习性和外貌特点 爱的教育中士兵这篇故事弗兰帝有讥笑跛脚的士兵吗 nginx 过滤非法请求 有access日志吗 如何设置根据不同的IP地址所在地域访问不同的服务? <<爱的教育>> nginx 开启 uptream 需要补丁吗 爱的教育读书笔记业日始 有用过goaccess的吗,我安装后运行出错 如何将一个对象数组娴NSUserDefault 与 swift 香水哪个品牌最好 大智慧中如何察看布林线 如何在大智慧切换布林线和普通K线图? 如何在大智慧软件中看到“布林线”? 怎样在大智慧查布林线 大智慧如何设布林线 股市软件大智慧里的K线图变成了BOLL线,怎样还原到之前的均线图。 大智慧布林线图怎样相互切换。 怎么用大智慧里布林线选股 大智慧我看了布林线但怎么返回去呢? 大智慧股票软件中的布林线怎样还原成K线? 哪位高手指点下大智慧软件中如何查看布林线?