永发信息网

关于如何升级nginx 到新最新版本1.7.9

答案:1  悬赏:20  手机版
解决时间 2021-12-04 02:07
关于如何升级nginx 到新最新版本1.7.9
最佳答案
如何升级Nginx到最新稳定版
我的环境:
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_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

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_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

在执行configure时得到几个错误:
a.配置 --with-http_xslt_module 时提示 the HTTP XSLT module requires the libxml2/libxslt libraries
sudo apt-get install libxml2 libxml2-dev libxslt-dev

b.配置 --with-http_image_filter_module 时提示 the HTTP image filter module requires the GD library.
sudo apt-get install libgd2-xpm libgd2-xpm-dev

c.配置 --with-http_geoip_module 时提示 the GeoIP module requires the GeoIP library.
sudo apt-get install geoip-database libgeoip-dev

d.rewrite需要pcre支持, 错误提示:./configure: error: the HTTP rewrite module 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,升级完毕.
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
ULN2803芯片的工作原理及功能
陕西同志聊天室网站 怎么上不了 是什么原因
2018年刚刚实行的基层副高和省里的副高待遇有
印度属于什么半球东西半球中
买车位和租车位哪个更划算?有些车库不能买!
梦见瓜腾上结了一个瓜是什么意思?
和绅当年贪了那么多的钱,还是当年国库里多少
北京伯爵售后在哪?手表不动了怎么办?
翛字怎么读?什么意思?
奔驰威挺空调虑在哪
作文:(60+10=70分)痕迹 约翰●罗斯金 
有一首数星星改编粤语版是谁唱的?
宋词词谱中的“豆”是什么意思?
求声优这种h音音频云盘
沙县小吃卤鸭腿怎么做???
推荐资讯
普公英可以直接泡开水喝吗
描写灯节的诗句
判断题植物体的六大器官是:根、茎、叶、花、
25610算24,每个数只能用一次
智联招聘的个人简历里的“专业技能”一项是什
12平米的小客厅和6.5平米的小房间,应该装什
上年工资10万今年工资12万今年比上年增幅多少
爱圆绿色干洗店地址在哪,我要去那里办事,
合阳县第三初级中学怎么样?
无锡火车站有到三国城公交吗
非洲以脖子长为美的国家
电脑插上税盘然后在哪里打开?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?