yum -y  install nginx

# yum info nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyuncs.com
* epel: mirrors.aliyuncs.com
* extras: mirrors.aliyuncs.com
* updates: mirrors.aliyuncs.com
Installed Packages
Name : nginx
Arch : x86_64
Epoch :
Version : 1.10.
Release : .el7
Size : 1.4 M
Repo : installed
From repo : epel
Summary : A high performance web server and reverse proxy server
URL : http://nginx.org/
License : BSD
Description : 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

nginx启动、开机自启动、重启、关闭的更多相关文章

  1. nginx设置开机自启动

    每次启动nginx服务都需要到安装目录下的/sbin下面,感觉挺麻烦的. 下面介绍一下如何在Linux(CentOS)系统上,设置nginx开机自启动. 1 用脚本管理nginx服务 第一步:在/et ...

  2. nginx启动、停止重启

    启动 启动代码格式:nginx安装目录地址 -c nginx配置文件地址 例如: [root@LinuxServer sbin]# /usr/local/nginx/sbin/nginx -c /us ...

  3. NO19 优化Linux系统--重要开机自启动服务--关闭自启动项

    **如何优化Linux系统: 1   不用root,添加普通用户,通过sudo授权管理.2   更改默认的远程连接SSH服务端口及禁止root用户远程连接.3   定时自动更新服务器时间.4   配置 ...

  4. nginx加入开机自启动

    1.首先,在linux系统的/etc/init.d/目录下创建nginx文件,使用如下命令:(vim /etc/init.d/nginx) 2.在/etc/init.d/nginx中写入以下脚本代码 ...

  5. 配置nginx脚本开机自启动

    vi /etc/init.d/nginx 插入以下内容,修改红色字体自己安装路径 #!/bin/bash## chkconfig: - 85 15# description: Nginx is a W ...

  6. Windows下nginx设置开机自启动

    第一步:下载 WinSW https://github.com/winsw/winsw/releases/download/v2.10.3/WinSW.NET4.exe 64位系统 https://g ...

  7. Windows 安装nginx并开机启动

    Win安装nginx并 开机启动 下载nginx安装包 nginx-1.12.2.zip,解压到D盘. https://pan.baidu.com/s/1InQa527yq35Q68c73RBb-A# ...

  8. CentOS7.X中设置nginx和php-fpm的开机自启动

    一.设置nginx的开机自启动方法 1.在/etc/init.d/目录下创建nginx文件 vi /etc/init.d/nginx 编写内容如下: #!/bin/sh # # nginx - thi ...

  9. 虚拟机拷贝之后,发现系统内的开机自启动的nginx,不能自启动了

    因业务需要,同事以某个虚拟机为模板,复制出其他的CentOS虚拟机时,发现原系统内的开机自启动的nginx,不能再自启动了. 好吧,那就重新注册一下 nginx 的开机自启动: # 先删除原来的注册: ...

  10. 编写shell脚本让springboot项目在CentOS中开机自启动

    springboot项目部署在CentOS系统上时,如果遇到停电关机,公司的实施人员就得跑到甲方现场重新启动项目并测试,很是麻烦,这里探讨如何编写shell脚本控制springboot项目开机时自动启 ...

随机推荐

  1. SQL server 2008无法连接Local服务器的解决办法

    SQL的有些服务总是在关机的时候自动关闭,然后你可以打开 控制面板——管理工具——服务,然后找到SQL相关的服务,右键——属性,里面有设置,可以设成自动启动

  2. 论try/catch的重要性,我们经常遇到代码出现无法调试的错误,程序退出的时候崩溃。这跟我们代码日常保护的习惯息息相关。

    每当构造函数或析构函数中出现溢出,会导致调试非常困难,而使用try/catch来处理构造中的初始化就非常重要了. 如上图,在构造函数中,我们的很多初始化动作会放在这里,但是却忽视了,一旦初始化出错了, ...

  3. Ubuntu 14.04 上使用 Nginx 部署 Laravel

    本教程将会涉及以下工具: Ubuntu 14.04 LTS PHP 5.5 MySQL Laravel 5.0 Nginx 参考文章:Ubuntu 14.04 上使用 Nginx 部署 Laravel ...

  4. js静态属性和静态方法

    啥也不说了,直接上代码...(就是这么任性)     var Animal = function(){};     Animal.name = "dog";     var a = ...

  5. nginx filter

    server { listen 80; server_name g.zcdn.com; index index.html; location / { proxy_cache cache_go; pro ...

  6. xmu1214: 购物

    1214: 购物 Time Limit: 500 MS  Memory Limit: 64 MBSubmit: 10  Solved: 5[Submit][Status][Web Board] Des ...

  7. java课程设计(计算器)

    JAVA课程 设 计 报 告 1206401-18   瞿杰 一.设计时间 2013年6月 24日-----6月28日 二.设计地点 湖南城市学院实验楼计算机506机房 三.设计目的 1.巩固学习VB ...

  8. 三分钟教你学Git(十六) - 统计

    有时候想统计仓库的情况,比方代码量.贡献者之类的. 1 统计某人的commit数量 git log --author="$(git config --get user.name)" ...

  9. Oracle fga审计有这几个特性

    fga审计有这几个特性: 本文为原创文章,转载请注明出处: http://blog.csdn.net/msdnchina/article/details/38409057 1.select * fro ...

  10. div中央

    .histroyMsgSearch{ background:#Fff; text-align: center; }  CSS 怎样使DIV层水平居中 今天用CSS碰到个非常棘手的问题,DIV本身未定义 ...