Windows PowerShell 中启动 Nginx 报错解决方案

368 阅读1分钟

首先看一下报错提示:

 我这里由于配置了多个 nginx.conf 配置文件,默认情况下,直接双击nginx.exe 即可运行,默认加载的是 conf\nginx.conf 配置文件。

那么有多个配置文件时,我们启动就需要指定加载配置文件了。

start nginx -c ./conf/nginx-2.conf
  • start 是启动命令
  • nginx 就是nginx.exe 服务
  • -c 表示指定配置路径参数
  • -c 后面的内容 ./conf/nginx-2.conf 表示你要加载的 nginx 配置文件

具体报错信息:
InvalidOperation: (:) [Start-Process],InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

PowerShell 在不使用绝对路径时会出现问题,所以这里我用绝对路径即可启动成功。

start E:\nginx-1.10.2\nginx.exe -c E:\nginx-1.10.2\conf\nginx-2.conf