Nginx教程

nginx升级或是添加nginx功能

本文主要是介绍nginx升级或是添加nginx功能,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

在新机器上编译安装nginx

检查是否安装nginx

[root@xiaohanhan ~]# rpm -qa |grep nginx
nginx-filesystem-1.20.1-9.el7.noarch
nginx-1.20.1-9.el7.x86_64

卸载nginx

[root@xiaohanhan ~]# rpm -e `rpm -qa |grep nginx`

检查是否卸载成功

[root@xiaohanhan ~]# rpm -qa |grep nginx

下载最新nginx(nginx官网右键复制链接,再用wget命令下载)

[root@xiaohanhan ~]# wget -P /server/tools http://nginx.org/download/nginx-1.20.2.tar.gz

进入下载目录,解压,进入解压成功的nginx目录

[root@xiaohanhan ~]# cd /server/tools/
[root@xiaohanhan /server/tools]# ls
nginx-1.20.2.tar.gz
[root@xiaohanhan /server/tools]# tar xf nginx-1.20.2.tar.gz 
[root@xiaohanhan /server/tools]# ls
nginx-1.20.2  nginx-1.20.2.tar.gz
[root@xiaohanhan /server/tools]# cd nginx-1.20.2

对nginx软件进行配置 ,加入想要功能(我这里将所有都打开,安装路径什么的都是默认)这步骤会报错缺依赖包,把报错复制到百度,查一下就知道安装什么

[root@xiaohanhan /server/tools/nginx-1.20.2]# ./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-compat --with-debug --with-file-aio --with-google_perftools_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'

看到这个结尾说明成功了,或者看有没有Makefile这个文件

checking for Google perftools ... found
creating objs/Makefile

Configuration summary
  + using threads
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library

  nginx path prefix: "/usr/share/nginx"
  nginx binary file: "/usr/sbin/nginx"
  nginx modules path: "/usr/lib64/nginx/modules"
  nginx configuration prefix: "/etc/nginx"
  nginx configuration file: "/etc/nginx/nginx.conf"
  nginx pid file: "/run/nginx.pid"
  nginx error log file: "/var/log/nginx/error.log"
  nginx http access log file: "/var/log/nginx/access.log"
  nginx http client request body temporary files: "/var/lib/nginx/tmp/client_body"
  nginx http proxy temporary files: "/var/lib/nginx/tmp/proxy"
  nginx http fastcgi temporary files: "/var/lib/nginx/tmp/fastcgi"
  nginx http uwsgi temporary files: "/var/lib/nginx/tmp/uwsgi"
  nginx http scgi temporary files: "/var/lib/nginx/tmp/scgi"

 

 编译make

[root@xiaohanhan /server/tools/nginx-1.20.2]# make

 

旧nginx机器上备份原nginx命令

[root@lb01 /etc/nginx]# which nginx
/usr/sbin/nginx
[root@lb01 /etc/nginx]# mv /usr/sbin/nginx /usr/sbin/nginx_bak

将新nginx系统上的/server/tools/nginx-1.20.2/objs/nginx目录复制到旧nginx系统的/usr/sbin/

[root@xiaohanhan /server/tools/nginx-1.20.2]# scp objs/nginx 10.0.0.5:/usr/sbin
[root@lb01 /etc/nginx]# ll /usr/sbin/nginx
-rwxr-xr-x 1 root root 9793048 Nov 28 15:21 /usr/sbin/nginx
[root@lb01 /etc/nginx]# nginx -V
nginx version: nginx/1.20.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-compat --with-debug --with-file-aio --with-google_perftools_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'

 重启nginx,完成

[root@lb01 /etc/nginx]# systemctl stop nginx
[root@lb01 /etc/nginx]# systemctl start nginx

 

这篇关于nginx升级或是添加nginx功能的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!