Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

用 cmd 管理 Nginx

Mashiro edited this page Sep 13, 2019 · 2 revisions

当可视化工具及调试脚本都无法使用的时候可以在 cmd 中直接用命令行管理 Nginx,当然,如果你是一个 geek,或许会更喜欢这种方式。

第一步:启动 cmd 并切换到 Nginx 目录

在 Windows 文件管理器中打开包含 nginx.exe 的目录,在上方的地址栏中输入 cmd,回车: image

会弹出这个窗口,这就是 cmd 啦: image

PS. 如果是大佬可能会更喜欢用 PowerShell

第二步:管理 Nginx(启动、检测、关闭)

启动

当你直接双击 nginx.exe 的时候会有一个窗口一弹而过,其实这时 Nginx 已经启动了,你可以在任务管理器看到 Nginx 进程。

这里教你在 cmd 里启动 Nginx——在上面的窗口中输入:

start nginx

没有报错的话就是启动了。

检测 Nginx 状态

如果想确认 Nginx 是否正常启动,可以输入下面两行命令中的任意一行:

nginx -s reload
nginx -s reopen

如果 Nginx 正在运行,则不会看到任何报错;如果 Nginx 没有在运行,会看到如下报错:

nginx: [error] CreateFile() "C:\PATH\TO\Pixiv-Nginx/logs/nginx.pid" failed (2: The system cannot find the file specified)

这时你需要先启动 Nginx,或者检查 Nginx 配置是否有误:

nginx -t

关闭 Nginx

很简单,运行下面命令即可:

nginx -s stop

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /