美文网首页
Nginx常用命令

Nginx常用命令

作者: kazeno | 来源:发表于2018-07-10 10:48 被阅读0次

1. 启动 Nginx

poechant@ubuntu:sudo./sbin/nginx

2. 停止 Nginx

poechant@ubuntu:sudo./sbin/nginx -s stoppoechant@ubuntu:sudo./sbin/nginx -s quit

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

3. Nginx 重载配置

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

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

poechant@ubuntu:servicenginx reload

4. 指定配置文件

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

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

5. 查看 Nginx 版本

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

poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -vnginx:nginxversion:nginx/1.0.0

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

poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -Vnginx:nginxversion:nginx/1.0.0nginx:built by gcc4.3.3(Ubuntu4.3.3-5ubuntu4)nginx:TLS SNI support enablednginx:configurearguments:--with-http_ssl_module --with-openssl=/home/luming/openssl-1.0.0d/

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

poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -tnginx:[alert] couldnotopen error logfile:open()"/usr/local/nginx/logs/error.log"failed (13: Permission denied)nginx:the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok2012/01/0916:45:09 [emerg]23898#0: open() "/usr/local/nginx/logs/nginx.pid" failed (13: Permission denied)nginx:configuration file /usr/local/nginx/conf/nginx.conf test failed

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

poerchant@ubuntu:/usr/local/nginx$ sudo ./sbin/nginx -tnginx:the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx:configuration file /usr/local/nginx/conf/nginx.conf test is successful

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

7. 显示帮助信息

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

或者:

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

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

作者:JokerW

链接:https://www.jianshu.com/p/630e2e1ca57f

來源:简书

简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

相关文章

网友评论

      本文标题:Nginx常用命令

      本文链接:https://www.haomeiwen.com/subject/stlfpftx.html