联系电话:0411-66373325
联系地址:大连市沙河口区富民广场
公司邮箱:2058793689@qq.com
备案信息:Copyright © 2016-2025,www.my249.com,All rights reserved
|
249建站之家:日积月累|nginx日常维护常用命令一、简明nginx常用命令 启动 Nginx poechant@ubuntu:sudo ./sbin/nginx 停止 Nginx poechant@ubuntu:sudo ./sbin/nginx -s stop poechant@ubuntu:sudo ./sbin/nginx -s quit -s都是采用向 Nginx 发送信号的方式。 Nginx 重载配置 poechant@ubuntu:sudo ./sbin/nginx -s reload 上述是采用向 Nginx 发送信号的方式,或者使用: poechant@ubuntu:service nginx reload 指定配置文件 poechant@ubuntu:sudo ./sbin/nginx -c /usr/local/nginx/conf/nginx.conf -c表示configuration,指定配置文件。 查看 Nginx 版本 有两种可以查看 Nginx 的版本信息的参数。第一种如下: poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -v nginx: nginx version: nginx/1.0.0 另一种显示的是详细的版本信息: poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -V nginx: nginx version: nginx/1.0.0 nginx: built by gcc 4.3.3 (Ubuntu 4.3.3-5ubuntu4) nginx: TLS SNI support enabled nginx: configure arguments: --with-http_ssl_module --with-openssl=/home/luming/openssl-1.0.0d/ 检查配置文件是否正确 poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -t nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied) nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok 2012/01/09 16: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 -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful 如果显示如上,则表示配置文件正确。否则,会有相关提示。 显示帮助信息 poechant@ubuntu:/user/local/nginx$ ./sbin/nginx -h 或者: poechant@ubuntu:/user/local/nginx$ ./sbin/nginx -? 以上这些涵盖了 Nginx 日常维护的所有基本操作,另外还有向 master 进程发送信号的相关命令,我们会在下面看到。 二、在Linux下通过master发送信号的相关命令 停止操作 停止操作是通过向nginx进程发送信号(什么是信号请参阅linux文 章)来进行的 步骤1:查询nginx主进程号 ps -ef | grep nginx 在进程列表里 面找master进程,它的编号就是主进程号了。 步骤2:发送信号 从容(平滑)停止Nginx: kill -QUIT 主进程号 快速停止Nginx: kill -TERM 主进程号 强制停止Nginx: pkill -9 nginx |