Smoothly and seamlessly upgrade Nginx to the latest version under CentOS

Source: Internet
Author: User
1. check the installed nginx version and the compiled parameter [root @ localhost ~], just like installing a third-party nginx module. #/Usr/local/nginx/sbin/nginx-Vnginxversion: nginx/1.7.8builtbygcc4.8.220140120 (RedHat4.8.2-16) (GCC) TLSSNI

1. just like installing a third-party module of nginx, you need to check the installed nginx version and the compiled parameters.

[root@localhost ~]# /usr/local/nginx/sbin/nginx -Vnginx version: nginx/1.7.8built by gcc 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) TLS SNI support enabledconfigure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --add-module=/root/ngx_cache_purge-2.2

2. download the nginx version you want to upgrade

wget -c http://nginx.org/download/nginx-1.7.9.tar.gz

3. decompress the package to the directory and start running the compilation parameters found above.

tar zxvf nginx-1.7.9.tar.gzcd /root/nginx-1.7.9./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --add-module=/root/ngx_cache_purge-2.2

4. then make, but do notMake install, remember!

There may be an error message:

Ca-: all warnings being treated as errors
Make [1]: *** [objs/addon/ngx_cache_purge-2.2/ngx_cache_purge_module.o] Error 1
Make [1]: Leave the directory "/root/nginx-1.7.9"
Make: *** [build] error 2

The reason for this error message is that my nginx is the latest and the ngx_cache_purge module version is old. We recommend that you use the latest version. If no third-party module is available, an error message is not reported when you upgrade nginx directly.

After downloading and unzipping, modify the:-add-module =/root/ngx_cache_purge-2.3 in the compilation parameters

wget -c http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gztar zxvf ngx_cache_purge-2.3.tar.gz

Make

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --add-module=/root/ngx_cache_purge-2.3

5. make is compiled. there is an nginx execution file under the objs directory.

6. back up the old nginx file

mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old

7. nginx cp under the new objs to sbin

Cp objs/nginx/usr/local/nginx/sbin/nginx

8. run the/usr/local/nginx/sbin/nginx-t test to check whether there is any problem.

9. use make upgrade to replace the old nginx process

10. execute again:/usr/local/nginx/sbin/nginx -VThe new nginx version and compiled parameters are displayed.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.