nginx原版本升级过程记录
1.先下载
	wget http://nginx.org/download/nginx-1.18.0.tar.gz
	
2.解压nginx并安装所需要的依赖的软件包
	tar -xf nginx-1.18.0.tar.gz -C /usr/local/src/
	
	安装软件包
	yum install pcre pcre-devel openssl-devel openssl gcc gcc-c++ make cmake -y
	
3.进入目录
	cd /usr/local/src/nginx
	
4.编译nginx加参数
	/configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module

5.预编译
	make
	
6.编译并安装nginx
	make install
	
7.添加环境变量
	 echo "export PATH=/usr/local/nginx/sbin:$PATH" > /etc/profile.d/nginx.sh
	
8.让环境变量生效
	source /etc/profile.d/nginx.sh
	
9.让nginx可以利用systemctl启动
	vim /lib/systemd/system/nginx.service
	写入以下内容

	    [Unit]
	Description=nginx service
	After=network.target 
	
	[Service] 
	Type=forking 
	ExecStart=/usr/local/nginx/sbin/nginx
	ExecReload=/usr/local/nginx/sbin/nginx -s reload
	ExecStop=/usr/local/nginx/sbin/nginx -s quit
	PrivateTmp=true 
	
	[Install] 
	WantedBy=multi-user.target
	
10.重新加载systemctl服务
		systemctl daemon-reload

11.启动nginx
		systemctl start nginx.service
		
12.开机自启动nginx
		systemctl enable nginx.service
		
13.查看nginx已经编译的参数信息
		/usr/local/nginx/sbin/nginx -V
		输入结果如下
		nginx version: nginx/1.18.0
		built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
		built with OpenSSL 1.0.2k-fips  26 Jan 2017
		TLS SNI support enabled
		configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module
		
14.生产中发现自己要用到模块现有的nginx的没有这些模块,可以二次编译更新nginx软件版本或者添加新的模块进去一定要
	升级nginx一定要添加上现有版本的参数,如果不添加就会报错
	
15.解压下载最新的nginx
	wget http://nginx.org/download/nginx-1.18.0.tar.gz
	
16.解压
	tar xf nginx-1.18.0.tar.gz
	
17.进入nginx目录
	cd nginx-1.18.0/
	
18.编译nginx加上现有的模块参数和要新增的模块参数
	现有的参数如下
	--prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module
	新增加的参数如下
	--with-http_mp4_module --with-stream
	
	编译新加的参数和老的参数
	./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-stream
	
19.预编译
	make 

20.查看make常用帮助参数
	[root@centos7 nginx-1.18.0]# cat Makefile 
	返回结果:
	default:	build
	
	clean:
		rm -rf Makefile objs
	
	build:
		$(MAKE) -f objs/Makefile
	
	install:
		$(MAKE) -f objs/Makefile install
	
	modules:
		$(MAKE) -f objs/Makefile modules
	
	upgrade: 													
		/usr/local/nginx/sbin/nginx -t
	
		kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
		sleep 1
		test -f /usr/local/nginx/logs/nginx.pid.oldbin
	
		kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin
	
		
	解释:
		clean:
			清楚编译的内容
			使用方法
				make clean
			
		build:
			这个和make build和make一样预编译
			使用方法,默认使用make即可
				make build
				make
		
		install:
			编译安装
			使用发放:
				make install
				
		upgrade:
			升级,但是不安装
			使用方法
			make upgrade
		
21.升级nginx,但是没有安装
	make upgrade
	
22.重新安装新编译的nginx,不会覆盖掉你先现有的配置文件,并不会影响现有的服务
	make install
	
23.查看新安装的nginx的参数
	/usr/local/nginx/sbin/nginx -V
	返回结果:
	nginx version: nginx/1.18.0
	built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
	built with OpenSSL 1.0.2k-fips  26 Jan 2017
	TLS SNI support enabled
	configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-streams
		
		
		
		
		
		
		
		
		
		


本文 暂无 评论

Top