重启centOS丢失nginx.pid致使没法启动nginx的解决方法

[TOC]nginx

找到nginx

首先,若是你忘记了你的nginx的安装目录,不妨使用如下命令,找到你的nginx:shell

find / -name nginx

这个时候,不出意外的话,你的界面将会出现一堆nginx路径,可是通常可执行的文件是在/sbin/或者/bin/目录下。固然,若是你的shell工具支持关键字高亮的话,一眼就能区分该是目录仍是可执行文件了,如下是目录示例:工具

/run/nginx
/usr/lib64/nginx
/usr/sbin/nginx
/usr/share/nginx
/usr/libexec/initscripts/legacy-actions/nginx
/etc/logrotate.d/nginx
/etc/sysconfig/nginx
/etc/nginx
/var/lib/yum/repos/x86_64/7/nginx
/var/cache/nginx
/var/cache/yum/x86_64/7/nginx
/var/log/nginx

上述列表中,带有/sbin/或者/bin/的目录仅有一个,那就是:测试

/usr/sbin/nginx

找到nginx的配置文件

也就是找到nginx.conf文件,一样是使用查找命令:ui

find / -name nginx.conf

这个时候通常只会出现一个配置文件路径,以下:this

/etc/nginx/nginx.conf

拼接命令,启动nginx

将目录/usr/sbin/nginx加上参数 -c,再加上配置文件目录:/etc/nginx/nginx.confspa

最终变成了:code

/usr/sbin/nginx -c /etc/nginx/nginx.conf

此时按下Enter执行,屏幕将会没有其余的提示,意味着nginx程序启动成功。进程

nginx -c 它是设置配置文件。其实nginx -c 它还有一个默认的配置文件路径。它默认的路径:/etc/nginx/nginx.conf,因此上述命令修正后是:ip

/usr/sbin/nginx -c

怎么知道nginx还有其余的命令呢?

你只须要输入如下命令便可:

/usr/sbin/nginx -?

Nginx指令拓展知识(中英对照):

-?,-h 			: this help (这个帮助)
-v 				: show version and exit (显示版本并退出)
-V 				: show version and configure options then exit (显示版本和选项,而后退出)
-t 				: test configuration and exit (测试配置和退出)
-T 				: test configuration, dump it and exit (测试配置,转储并退出)
-q 				: suppress non-error messages during configurationtesting (在配置非错误期间,禁止显示非错误消息)
-s signal 		: send signa1 to a master process: stop, quit, reopen, reload  (向主进程发送信息:中止;退出;从新打开;从新加载)
-p prefix 		: set prefix path (default: /etc/nginx/)  (设置前缀路径,默认:/etc/nginx/)
-c filename 	: set configuration file (default: /etc/nginx/nginx. conf)  (设置配置文件,默认为:/etc/nginx/nginx. conf )

-g directives 	: set global directives out of configuration file (将配置文件设置为全局指令)
相关文章
相关标签/搜索