1、查看原来安装的nginx的版本以及编译的参数
2、下载想要升级nginx的版本
3、解压进入目录开始运行上面所查询到的编译参数
4、然后make,但不要make install,切记! make 时可能会遇到各种 error ,要一一解决
Nginx安装以及可能出现错误
--在配置信息./configure --prefix=/usr/local/nginx 的时,出现错误:
/configure: error: the HTTP rewrite module requires the PCRE library.
解决方法:安装pcre
yum -y install pcre pcre-devel
-y 是跳过所有需要手动确认的环节
--缺少ssl错误,错误信息如下:
./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解决方法:安装openssl
yum -y install openssl openssl-devel
--缺少编译器,错误信息如下:
./configure: error: C compiler cc is not found
解决方法:安装gcc-c++
yum -y install gcc-c++ autoconf automake
--autoconf是自动配置,automake是自动编译
缺少zlib包,错误信息如下:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using –without-http_gzip_module
option, or install the zlib library into the system, or build the zlib
library
statically from the source with nginx by using –with-zlib=<path> option.
解决方法:安装zlib
yum install -y zlib-devel
--确实libxml2,错误信息如下:
./configure: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.
解决方法:
yum -y install libxml2 libxml2-dev
yum -y install libxslt-devel
--http_image_filter_module是nginx提供的集成图片处理模块,需要gd-devel的支持,错误信息如下:
./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.
解决方法:
yum -y install gd-devel
--缺少ExtUtils,错误信息如下:
./configure: error: perl module ExtUtils::Embed is required
解决方法:
yum -y install perl-devel perl-ExtUtils-Embed
--缺少GeoIP,错误信息如下:
./configure: error: the GeoIP module requires the GeoIP library.
You can either do not enable the module or install the library.
解决方法:
yum -y install GeoIP GeoIP-devel GeoIP-data
++修改完各种error后,测试一下 nginx 的配置文件:
nginx -t
显示以下信息为正确
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
5、make 编译完,在objs目录下有一个nginx执行文件
在当前解压的新版本文件夹中的objs 下会有 nginx
6、备份下原来老的nginx文件
8、执行 /usr/local/nginx/sbin/nginx -t 测试下,显示没有问题,可以执行第9步。
10、再次执行 nginx -V 将会显示新的nginx的版本及编译的参数。
启动
确保系统的 80 端口没被其他程序占用,运行nginx 命令来启动 Nginx,
netstat -ano|grep 80
or
netstat -lntup | grep 80
killall nginx
如果查不到结果后执行,有结果则忽略此步骤(ubuntu下必须用sudo启动,不然只能在前台运行)
sudo /usr/local/nginx/nginx
打开浏览器访问此机器的 IP,如果浏览器出现 Welcome to nginx! 则表示 Nginx 已经安装并运行成功。
-----------------------------------------------------------------------
简单说来就是看版本、记下里面的配置、下载、解压、./configure、然后make、备份、把objs上的nginx拷到现在的nginx目录下,执行升级。如果升级的时候失败出现上面那样的错误,可以试下make install。总之呢,最重要的就是做好备份
nginx -V
显示
configure arguments:
后面的参数,进行 copy
2、下载想要升级nginx的版本
wget -c http://nginx.org/download/nginx-1.9.1.tar.gz
3、解压进入目录开始运行上面所查询到的编译参数
tar zxvf nginx-1.9.1.tar.gz
cd /root/nginx-1.9.1
把上面的参数拷贝
./configure
后面
4、然后make,但不要make install,切记! make 时可能会遇到各种 error ,要一一解决
Nginx安装以及可能出现错误
--在配置信息./configure --prefix=/usr/local/nginx 的时,出现错误:
/configure: error: the HTTP rewrite module requires the PCRE library.
解决方法:安装pcre
yum -y install pcre pcre-devel
-y 是跳过所有需要手动确认的环节
--缺少ssl错误,错误信息如下:
./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解决方法:安装openssl
yum -y install openssl openssl-devel
--缺少编译器,错误信息如下:
./configure: error: C compiler cc is not found
解决方法:安装gcc-c++
yum -y install gcc-c++ autoconf automake
--autoconf是自动配置,automake是自动编译
缺少zlib包,错误信息如下:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using –without-http_gzip_module
option, or install the zlib library into the system, or build the zlib
library
statically from the source with nginx by using –with-zlib=<path> option.
解决方法:安装zlib
yum install -y zlib-devel
--确实libxml2,错误信息如下:
./configure: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.
解决方法:
yum -y install libxml2 libxml2-dev
yum -y install libxslt-devel
--http_image_filter_module是nginx提供的集成图片处理模块,需要gd-devel的支持,错误信息如下:
./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.
解决方法:
yum -y install gd-devel
--缺少ExtUtils,错误信息如下:
./configure: error: perl module ExtUtils::Embed is required
解决方法:
yum -y install perl-devel perl-ExtUtils-Embed
--缺少GeoIP,错误信息如下:
./configure: error: the GeoIP module requires the GeoIP library.
You can either do not enable the module or install the library.
解决方法:
yum -y install GeoIP GeoIP-devel GeoIP-data
++修改完各种error后,测试一下 nginx 的配置文件:
nginx -t
显示以下信息为正确
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
5、make 编译完,在objs目录下有一个nginx执行文件
在当前解压的新版本文件夹中的objs 下会有 nginx
6、备份下原来老的nginx文件
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.1.6.3
7、在把新objs下的nginx cp到sbin下
cp objs/nginx /usr/local/nginx/sbin/nginx
8、执行 /usr/local/nginx/sbin/nginx -t 测试下,显示没有问题,可以执行第9步。
如果出现以下错误,可修改错误提示中的 conf 文件,修改后若还是不通过
nginx: [alert] version 1.4.0 of nginx.pm is required, but 1.2.0 was found
nginx: configuration file /usr/local/webserv/nginx/conf/nginx.conf test failed
9、使用 make upgrade 替换老的nginx进程
无法upgrade 的话
用 make install 刚才不是说不能make install么,刚才有备份不是,可以还原回去,但要我还原回旧版?很难。看了下以前的安装过程,make install 应该不会有什么问题,于是直接make install。记住,把原来的配置文件什么的拷下来备份下。
10、再次执行 nginx -V 将会显示新的nginx的版本及编译的参数。
启动
确保系统的 80 端口没被其他程序占用,运行nginx 命令来启动 Nginx,
netstat -ano|grep 80
or
netstat -lntup | grep 80
killall nginx
如果查不到结果后执行,有结果则忽略此步骤(ubuntu下必须用sudo启动,不然只能在前台运行)
sudo /usr/local/nginx/nginx
打开浏览器访问此机器的 IP,如果浏览器出现 Welcome to nginx! 则表示 Nginx 已经安装并运行成功。
-----------------------------------------------------------------------
简单说来就是看版本、记下里面的配置、下载、解压、./configure、然后make、备份、把objs上的nginx拷到现在的nginx目录下,执行升级。如果升级的时候失败出现上面那样的错误,可以试下make install。总之呢,最重要的就是做好备份