前言
 最近需要部署一个前端项目,用到了nginx。正常情况是:需要使用时nginx服务时,进入到nginx.exe所在目录,然后执行:start nginx.exe,但是线上环境这样搞的话还是不太科学。由于好奇心(懒),想一个nginx服务自动启动。参考了下windows自带的sc命令,发现如果不按照一定的规则编写程序是不能用的,永远都是1053错误。然后切换第二条路:用以前搞过的instsrv和srvany。直接开干。
nginx服务bat脚本
 @echo off
 echo nginx services install start
set curPath=%~dp0
 set commonHC=%~dp0common\hc.exe
 set instsrv=%~dp0common\instsrv.exe
 set srvany=%~dp0common\srvany.exe
 set NGINX_SERVICE_NAME=LMS_NGINX_SERVER
 set nginxPath=%curPath%nginx\nginx.exe
 set regPath=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\%NGINX_SERVICE_NAME%\Parameters\
@REM echo %instsrv% %srvany% %commonHC%
%instsrv% %NGINX_SERVICE_NAME% %srvany%
reg add %regPath% /v AppDirectory /t REG_SZ /d %curPath%nginx /f
 reg add %regPath% /v Application /t REG_SZ /d "%nginxPath%" /f 
 reg add %regPath% /v AppParameters /t REG_SZ /f
net start %NGINX_SERVICE_NAME%
echo nginx services install end
 @REM pause
  
其中服务相关的代码是。先将srvany 注册成服务,然后添加注册表。
%instsrv% %NGINX_SERVICE_NAME% %srvany%
reg add %regPath% /v AppDirectory /t REG_SZ /d %curPath%nginx /f
 reg add %regPath% /v Application /t REG_SZ /d "%nginxPath%" /f 
 reg add %regPath% /v AppParameters /t REG_SZ /f
实现效果

 nginx已经启动了

windows制作nginx服务-小何博客前言最近需要部署一个前端项目,用到了nginx。正常情况是:需要使用时nginx服务时,进入到nginx.exe所在目录,然后执行:start nginx.exe,但是线上环境这样搞的话还是不太科学。由于好奇心(懒),想一个nginx服… https://ligo100.cn/houduanjishu/qita/604.html
https://ligo100.cn/houduanjishu/qita/604.html










![命令执行 [BUUCTF 2018]Online Tool1](https://img-blog.csdnimg.cn/direct/c1207e1e50704e06b908bc1cd3c7badd.png)
![[pluginviteimport-analysis] vite 提示jsx语法报错](https://img-blog.csdnimg.cn/img_convert/4568dc90e485318e926bad3bf2e72ad1.png)







