查看nginx進程html
說明:nginx的進程由主進程和工做進程組成。nginx
# ps -ef | grep nginx
root 85276 1 0 10:49 ? 00:00:00 nginx: master process ./nginx
nginx 85277 85276 0 10:49 ? 00:00:00 nginx: worker process
root 85483 68068 1 11:07 pts/0 00:00:00 grep --color=auto nginxdocker
檢查配置文件是否正確安全
[root@docker ~]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/nginx.conf test is successful網站
查看工做目錄,配置文件等信息ui
# /usr/local/nginx/sbin/nginx -Vspa
默認訪問目錄htm
# vi /usr/local/nginx/html/index.html進程
不中止服務,從新載入配置文件ssl
# /usr/local/nginx/sbin/nginx -s reload
安全的中止
# /usr/local/nginx/sbin/nginx -s stop
強制中止
# pkill -9 nginx
升級和降級方法同樣
檢查現有nginx版本及配置
# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.13.6
# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.13.6
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
built with OpenSSL 1.1.0g 2 Nov 2017
TLS SNI support enabled
configure arguments: --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_ssl_module --with-openssl=/root/openssl-1.1.0g --with-pcre=/root/pcre-8.41 --with-zlib=/root/zlib-1.2.11 --with-http_stub_status_module --conf-path=/usr/local/nginx/nginx.conf
解壓升級/降級的包
# tar -xvf nginx-1.12.2.tar.gz
進入解壓出來的目錄
[root@docker ~]# cd nginx-1.12.2/
配置:在配置過程當中。必需要把以前配置的參數都加入進
# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_ssl_module --with-openssl=/root/openssl-1.1.0g --with-pcre=/root/pcre-8.41 --with-zlib=/root/zlib-1.2.11 --with-http_stub_status_module --conf-path=/usr/local/nginx/nginx.conf
編譯:千萬不要執行make install
# make
重命名啓動文件
# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
備份舊的執行文件
(重命名以後網站還能夠訪問)
複製行的配置文件
# cp nginx-1.12.2/objs/nginx /usr/local/nginx/sbin/
將要升級或者降級的解壓包裏面的配置文件複製過去
平滑升級/降級nginx
# kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
查看nginx進程
# ps -ef | grep nginx
決定是否升級到新版本的nginx
# kill -WINCH `cat /usr/local/nginx/logs/nginx.pid.oldbin `
Nginx在不重載配置文件啓動工做進程
# kill -HUP `cat /usr/local/nginx/logs/nginx.pid.oldbin `
關閉舊版本nginx
# kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
查看是否關閉了就的nginx進程
# ps -ef | grep nginx
檢查升級以後的版本
# /usr/local/nginx/sbin/nginx -vnginx version: nginx/1.12.2