高性能Web服务器Nginx的配置与部署研究(4)Nginx常用命令

释放双眼,带上耳机,听听看~!

高性能Web服务器Nginx的配置与部署研究(4)Nginx常用命令

  • Author: Poechant
  • Blog: blog.CSDN.net/Poechant
  • Email: zhongchao.ustc#gmail.com (#->@)
  • Date: December 30

th, 2011

  • Update: February 36

th, 2012

  • Column: 《Nginx 高性能Web服务器》

1. 启动 Nginx


1
2
1poechant@ubuntu:sudo ./sbin/nginx
2

2. 停止 Nginx


1
2
3
1poechant@ubuntu:sudo ./sbin/nginx -s stop
2poechant@ubuntu:sudo ./sbin/nginx -s quit
3

-s都是采用向 Nginx 发送信号的方式。

3. Nginx 重载配置


1
2
1poechant@ubuntu:sudo ./sbin/nginx -s reload
2

上述是采用向 Nginx 发送信号的方式,或者使用:


1
2
1poechant@ubuntu:service nginx reload
2

4. 指定配置文件


1
2
1poechant@ubuntu:sudo ./sbin/nginx -c /usr/local/nginx/conf/nginx.conf
2

-c表示configuration,指定配置文件。

5. 查看 Nginx 版本

有两种可以查看 Nginx 的版本信息的参数。第一种如下:


1
2
3
1poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -v
2nginx: nginx version: nginx/1.0.0
3

另一种显示的是详细的版本信息:


1
2
3
4
5
6
1poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -V
2nginx: nginx version: nginx/1.0.0
3nginx: built by gcc 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
4nginx: TLS SNI support enabled
5nginx: configure arguments: --with-http_ssl_module --with-openssl=/home/luming/openssl-1.0.0d/
6

6. 检查配置文件是否正确


1
2
3
4
5
6
1poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -t
2nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)
3nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
42012/01/09 16:45:09 [emerg] 23898#0: open() "/usr/local/nginx/logs/nginx.pid" failed (13: Permission denied)
5nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
6

如果出现如上的提示信息,表示没有访问错误日志文件和进程,可以sudo(super user do)一下:


1
2
3
4
1poerchant@ubuntu:/usr/local/nginx$ sudo ./sbin/nginx -t
2nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
3nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
4

如果显示如上,则表示配置文件正确。否则,会有相关提示。

7. 显示帮助信息


1
2
1poechant@ubuntu:/user/local/nginx$ ./sbin/nginx -h
2

或者:


1
2
1poechant@ubuntu:/user/local/nginx$ ./sbin/nginx -?
2

以上这些涵盖了 Nginx 日常维护的所有基本操作,另外还有向 master 进程发送信号的相关命令,我们会在后续看到。

转载请注明来自“柳大的CSDN博客”: blog.CSDN.net/Poechant

给TA打赏
共{{data.count}}人
人已打赏
安全运维

WordPress网站专用docker容器环境带Waf

2020-7-18 20:04:44

安全运维

运维安全-Gitlab管理员权限安全思考

2021-9-19 9:16:14

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索