Nginx Windows命令行全局操作

在windows中使用Nginx全局使用起来要敲击很长的命令。在CSDN的凡恩在文章的指导下解决了这个问题,在此记录下。

感谢!https://blog.csdn.net/zhuojiamin/article/details/81140096

创建一个 bat 文件(我的是 nginxd.bat),使用 bat 来运行 nginx 命令。创建了之后,就可以使用如下命令:

nginxd [-h,help] [-v,version] [start] [stop] [stop -a] [reload] [reopen] [find]

下面是bat文件的代码:

@echo off
if "%1"=="help" (goto help) else (if "%1"=="-h" goto help)
if "%1"=="version" (goto version) else (if "%1"=="-v" goto version)
if "%1"=="start" goto start
if "%1"=="stop" goto stop
if "%1"=="reload" goto reload
if "%1"=="reopen" goto reopen
if "%1"=="find" goto find
goto error

:help
nginx -v
echo Usage: nginxd [-h,help] [-v,version] [start] [stop] [stop -a] [reload] [reopen] [find]
echo=
echo Options:
echo help,-h : this help
echo version,-v : show current nginx version
echo start : start nginx master process
echo stop : stop the newest nginx master process
echo stop -a : stop all nginx master processes
echo reload : reload configuration
echo reopen : reopen nginx
echo find : show the nginx master process list
echo=
exit /B

:version
nginx -v
exit /B

:start
start nginx -p D:\Software\nginx
exit /B

:stop
if "%2"=="-a" (taskkill /F /IM nginx.exe) else (if "%2"=="" (nginx -s stop -p D:\Software\nginx) else goto error)
exit /B

:reload
nginx -s reload -p D:\Software\nginx
exit /B

:find
tasklist /fi "imagename eq nginx.exe"
exit /B

:error
echo nginxd: invalid option: "%1 %2"
echo=
exit /B

其实本质上解决这个问题是要学习重新编译Nginx源码改变nginx.conf、error.log的默认路径。也可以学习理解Nginx的模块安装。

至此下一篇研究下windows环境下编译Nginx

---------------------
作者:凡恩
来源:CSDN
原文:https://blog.csdn.net/zhuojiamin/article/details/81140096
版权声明:本文为博主原创文章,转载请附上博文链接! 

猜你喜欢

转载自www.cnblogs.com/q3619940/p/10672079.html