前言:看到一篇关于HTTP2的文章,说性能是http1.1的几倍 于是就有了部首的冲动,但是nginx 开启http2 需要1.9x以上 我现在是1.6.3 所以就有了这篇文章(当你看到这篇文章的时候已经是http2协议了)
我的环境:
- Raspberrypi
- Nginx 1.6.3
Nginx是通过apt-get的方式安装的,所以我的路径与下载代码再编译、安装的有些不一样,我的升级过程如下
1.进入tmp文件夹
cd /tmp
2.下载nginx-1.10.2.tar.gz文件到tmp文件夹中
wget http://nginx.org/download/nginx-1.10.2.tar.gz
3.解压nginx-1.10.2.tar.gz文件
tar zxvf nginx-1.10.2.tar.gz
4.进入ngixn-1.10.2文件夹中
cd nginx-1.10.2
5.查看nginx原来的配置
nginx -V
上面的命令将输出:
--prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --with-http_v2_module
6.执行configure命令,后面跟上原来nginx的配置
./configure --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --with-http_v2_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 我安装失败 一直提示错误 我就把配置中--with-http_image_filter_module 删除了
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-bak
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.10.2目录下执行下面的命令来升级nginx
make upgrade
11.执行make upgrade得到一个错误:
make: /etc/nginx/sbin/nginx: Command not found make: *** [upgrade] Error 127
12.用文本编辑器打开修改nginx-1.10.2目录下名为Makefile的文件,将upgrade节点中的/etc/nginx/sbin/nginx改为/usr/sbin/nginx -t,保存后关闭并重新执行make upgrade命令
13.执行nginx -v命令,程序的版本号已经是1.10.2,升级完毕.