本文共 1997 字,大约阅读时间需要 6 分钟。
yum -y install nginx
# yum info nginxLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.aliyuncs.com * epel: mirrors.aliyuncs.com * extras: mirrors.aliyuncs.com * updates: mirrors.aliyuncs.comInstalled PackagesName : nginxArch : x86_64Epoch : 1Version : 1.10.1Release : 1.el7Size : 1.4 MRepo : installedFrom repo : epelSummary : A high performance web server and reverse proxy serverURL : http://nginx.org/License : BSDDescription : Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and : IMAP protocols, with a strong focus on high concurrency, performance and low : memory usage.
yum -y uninstall nginx
一、启动
cd /usr/local/nginx/sbin./nginx
开机自启动:
cat /etc/rc.d/rc.local#!/bin/bash# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES## It is highly advisable to create own systemd services or udev rules# to run scripts during boot instead of using this file.## In contrast to previous versions due to parallel execution during boot# this script will NOT be run after all other services.## Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure# that this script will be executed during boot.touch /var/lock/subsys/local/usr/local/nginx/sbin/nginx
直接把启动应用程序的命令放在这个文件中就可以了
二、重启
更改配置重启nginx
kill -HUP 主进程号或进程号文件路径或者使用cd /usr/local/nginx/sbin./nginx -s reload
判断配置文件是否正确
nginx -t -c /usr/local/nginx/conf/nginx.conf或者cd /usr/local/nginx/sbin./nginx -t
三、关闭
查询nginx主进程号
ps -ef | grep nginx
从容停止 kill -QUIT 主进程号
快速停止 kill -TERM 主进程号
强制停止 kill -9 nginx
若nginx.conf配置了pid文件路径,如果没有,则在logs目录下
kill -信号类型 '/usr/local/nginx/logs/nginx.pid'
四、升级
1、先用新程序替换旧程序文件
2、kill -USR2 旧版程序的主进程号或者进程文件名
此时旧的nginx主进程会把自己的进程文件改名为.oldbin,然后执行新版nginx,此时新旧版本同时运行
3、kill -WINCH 旧版本主进程号
4、不重载配置启动新/旧工作进程
kill -HUP 旧/新版本主进程号
从容关闭旧/新进程
kill -QUIT 旧/新进程号
快速关闭旧/新进程
kill -TERM 旧/新进程号
http://www.cnblogs.com/jianxie/p/3990377.html