【Nginx】Linux常用命令------启动、停止、重启

启动

启动代码格式:nginx安装目录地址 -c nginx配置文件地址

例如:

[root@LinuxServer sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

停止

nginx的停止有三种方式:

从容停止

1、查看进程号

[root@LinuxServer ~]# ps -ef|grep nginx

2、杀死进程

[root@LinuxServer ~]# kill -QUIT 2072

快速停止

1、查看进程号

[root@LinuxServer ~]# ps -ef|grep nginx

2、杀死进程

扫描二维码关注公众号,回复: 17148775 查看本文章

[root@LinuxServer ~]# kill -TERM 2132
或 [root@LinuxServer ~]# kill -INT 2132

强制停止

[root@LinuxServer ~]# pkill -9 nginx

重启

1、验证nginx配置文件是否正确
方法一:进入nginx安装目录sbin下,输入命令./nginx -t
看到如下显示nginx.conf syntax is ok

nginx.conf test is successful

说明配置文件正确!

方法二:在启动命令-c前加-t

2、重启Nginx服务
方法一:进入nginx可执行目录sbin下,输入命令./nginx -s reload 即可

方法二:查找当前nginx进程号,然后输入命令:kill -HUP 进程号 实现重启nginx服务

————————————————

pgrep /pkill

EXAMPLES
Example 1: Find the process ID of the named daemon:

$ pgrep -u root named

Example 2: Make syslog reread its configuration file:

$ pkill -HUP syslogd

Example 3: Give detailed information on all xterm processes:

$ ps -fp $(pgrep -d, -x xterm)

Example 4: Make all netscape processes run nicer:

$ renice +4 $(pgrep netscape)

验证配置是否正确: nginx -t

查看Nginx的版本号:nginx -V

启动Nginx:start nginx

快速停止或关闭Nginx:nginx -s stop

正常停止或关闭Nginx:nginx -s quit

配置文件修改重装载命令:nginx -s reload

1、错误情况:

nginx: [error] CreateFile() “E:\nginx\nginx-1.9.3/logs/nginx.pid” failed

nginx: [error] Open() “E:\nginx\nginx-1.9.3/logs/nginx.pid” failed

使用命令创建/logs/nginx.pid文件: nginx -c conf/nginx.conf

相关文档说明:

http://www.cnblogs.com/wangkongming/p/4004416.html

http://www.cnblogs.com/xiaogangqq123/archive/2011/03/02/1969006.html

2、配置多个80端口 server:

相关文档说明:

http://os.51cto.com/art/201404/437182.htm

3、不同端口为本地nginx服务器配置多个站点:

相关文档说明:

http://blog.csdn.net/yongzhang52545/article/details/51282914

http://www.2cto.com/os/201411/355976.html

猜你喜欢

转载自blog.csdn.net/qq_43842093/article/details/134916057