Nginx是通過(guò)apt-get的方式安裝的,所以我的路徑與下載代碼再編譯、安裝的有些不一樣,我的升級(jí)過(guò)程如下
1.進(jìn)入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.進(jìn)入ngixn-1.2.5文件夾中
cd nginx-1.2.5
5.查看nginx原來(lái)的配置
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.執(zhí)行configure命令,后面跟上原來(lái)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
在執(zhí)行configure時(shí)得到幾個(gè)錯(cuò)誤:
a.配置 --with-http_xslt_module 時(shí)提示 the HTTP XSLT module requires the libxml2/libxslt libraries
sudo apt-get install libxml2 libxml2-dev libxslt-dev
b.配置 --with-http_image_filter_module 時(shí)提示 the HTTP image filter module requires the GD library.
sudo apt-get install libgd2-xpm libgd2-xpm-dev
c.配置 --with-http_geoip_module 時(shí)提示 the GeoIP module requires the GeoIP library.
sudo apt-get install geoip-database libgeoip-dev
d.rewrite需要pcre支持, 錯(cuò)誤提示:./configure: error: the HTTP rewrite module requires the PCRE library.
apt-get install libpcre3 libpcre3-dev
7.再執(zhí)行第6步的configure命令
8.這次沒(méi)有提示缺少library, 執(zhí)行make令命編譯nginx, 編譯好以后objs目錄下多出一個(gè)nginx文件,這個(gè)就是已編輯好的nginx程序
make
9.更改舊的nginx程序的名子,并復(fù)制新的程序過(guò)去,我的舊nginx程序放在/usr/sbin/目錄中
mv /usr/sbin/nginx /usr/sbin/nginx-20121122
cp objs/nginx /usr/sbin/nginx
/usr/sbin/nginx -t
執(zhí)行/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目錄下執(zhí)行下面的命令來(lái)升級(jí)nginx
make upgrade
11.執(zhí)行make upgrade得到一個(gè)錯(cuò)誤:
make: /etc/nginx/sbin/nginx: Command not found
make: *** [upgrade] Error 127
12.用文本編輯器打開(kāi)修改nginx-1.2.5目錄下名為Makefile的文件,將upgrade節(jié)點(diǎn)中的/etc/nginx/sbin/nginx改為/usr/sbin/nginx -t,保存后關(guān)閉并重新執(zhí)行make upgrade命令
13.執(zhí)行nginx -v命令,程序的版本號(hào)已經(jīng)是1.2.5,升級(jí)完畢.