nginx启动、开机自启动、重启、关闭

简介: yum -y  install nginx # yum info nginx Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.

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       : 1
Version     : 1.10.1
Release     : 1.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

 

相关文章
|
6月前
|
应用服务中间件 nginx 数据安全/隐私保护
百度搜索:蓝易云【Nginx启动,重启以及基本命令详解!】
请注意,上述命令可能需要在终端中以管理员权限(使用sudo)运行。根据你的系统配置和安装方式,可能会有所不同。确保使用适用于你的系统的正确命令。
118 3
|
应用服务中间件 网络安全 nginx
nginx启动成功,但外部不能访问的问题
nginx启动成功,但外部不能访问的问题
2868 0
nginx启动成功,但外部不能访问的问题
|
1月前
|
应用服务中间件 nginx Windows
windows下快速安装nginx 并配置开机自启动
windows下快速安装nginx 并配置开机自启动
windows下快速安装nginx 并配置开机自启动
|
4月前
|
Ubuntu 应用服务中间件 Linux
百度搜索:蓝易云【总结Nginx的安装、配置与设置开机自启?】
完成上述步骤后,Nginx将安装并配置好,并设置为开机自启。您可以根据需要修改Nginx的配置文件以适应特定的服务器需求,例如添加站点配置、SSL证书等。在修改配置文件后,记得重新加载Nginx以使更改生效。
34 1
|
7月前
|
应用服务中间件 Linux nginx
CentOS7创建nginx服务并配置开机自启
CentOS7创建nginx服务并配置开机自启
119 0
|
8月前
|
应用服务中间件 Linux Shell
设置Nginx开机自动启动(centos6.8上亲测可用)
设置Nginx开机自动启动(centos6.8上亲测可用)
|
9月前
|
应用服务中间件 Linux Shell
【Shell脚本】Linux安装Nginx以及开机自启
【Shell脚本】Linux安装Nginx以及开机自启
【Shell脚本】Linux安装Nginx以及开机自启
|
9月前
|
应用服务中间件 Linux nginx
Linux下Nginx编译安装后的开机自启动设置
Linux下Nginx编译安装后的开机自启动设置
387 0
|
9月前
|
安全 应用服务中间件 Linux
Linux系统设置服务自启,实操nginx开机自启
Linux系统设置服务自启,实操nginx开机自启
|
10月前
|
应用服务中间件 nginx
window重启Nginx的BAT脚本
window重启Nginx的BAT脚本
189 0