windows用bat脚本将nginx安装为服务

embedded/2024/9/22 14:36:35/

首先可以从百度网盘下载nginx文件包:
链接:https://pan.baidu.com/s/1XP1jXBfFLmyOeAi3cMkvOw?pwd=re0z 
提取码:re0z

安装脚本如下:

@echo off
chcp 65001

echo 参数设置
echo.
set cds=%~dp0
echo 当前目录:%cds%

echo ****************************************
echo.
echo 安装nginx,请不要关闭窗口
echo.
echo.
echo 请以管理员身份运行
echo.
echo ****************************************

echo 参数设置
echo.
set cdsf=%cds:\=/%
set sign=${base}
set nginxpath=%cdsf%nginx
echo nginx目录:%nginxpath%
set teamplatefile=%nginxpath%/conf/nginx.conf.template
echo 模版目录:%teamplatefile%
set configfile=%nginxpath%/conf/nginx.conf
set configfileremove=%cds%nginx\conf\nginx.conf
echo 模版目录:%configfile%
echo 模版删除目录:%configfileremove%
set servertemplatefile=%cds%nginx\nginx-service.xml.template
echo 服务模版目录:%servertemplatefile%
set serverfile=%cds%nginx\nginx-service.xml
echo 服务文件目录:%serverfile%

echo 删除旧配置文件
echo.
if exist %configfileremove% del %configfileremove%
if exist %serverfile% del %serverfile%

echo 生成配置文件
echo.
setlocal enabledelayedexpansion
for /f "tokens=*" %%i in (%teamplatefile%) do (
set s=%%i
set s=!s:%sign%=%cds%!
if not [!s!]==[] echo !s!>>%configfile%
)

for /f "tokens=*" %%j in (%servertemplatefile%) do (
set t=%%j
set t=!t:%sign%=%cds%!
if not [!t!]==[] echo !t!>>%serverfile%
)

echo 安装nginx服务
%cds%nginx\nginx-service.exe install
sc start hzsidp_nginx


exit


http://www.ppmy.cn/embedded/9872.html

相关文章

vulfocus靶场couchdb 权限绕过 (CVE-2017-12635)

Apache CouchDB是一个开源数据库,专注于易用性和成为"完全拥抱web的数据库"。它是一个使用JSON作为存储格式,JavaScript作为查询语言,MapReduce和HTTP作为API的NoSQL数据库。应用广泛,如BBC用在其动态内容展示平台&…

实验室三大常用仪器3---交流毫伏表的使用方法(笔记)

目录 函数信号发生器、示波器、交流毫伏表如何连接 交流毫伏表的使用方法 测量值的读数问题 实验室三大常用仪器1---示波器的基本使用方法(笔记)-CSDN博客 实验室三大常用仪器2---函数信号发生器的基本使用方法(笔记)-CSDN博客…

解析OceanBase v4.2函数索引进行查询优化

一、如何通过函数索引来进行查询优化 函数索引是一种优化查询的技术,其主要作用在于提升包含函数调用的查询语句的执行速度。当查询语句中包含函数调用时,数据库系统需要逐行执行函数计算,这无疑会增加查询的复杂性,导致查询速度…

力扣HOT100 - 25. K 个一组翻转链表

解题思路&#xff1a; class Solution {public ListNode reverseKGroup(ListNode head, int k) {ListNode dum new ListNode(0, head);ListNode pre dum;ListNode end dum;while (end.next ! null) {for (int i 0; i < k && end ! null; i) {end end.next;}if …

c++中一些常用库函数

1.最大公约数 需要包括头文件#include<algorithm>,直接写__gcd(a,b),就是求a与b的最大公约数。 #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<stack> #include<map>…

C语言案例——输出以下图案(两个对称的星型三角形)

目录 图片代码 图片 代码 #include<stdio.h> int main() {int i,j,k;//先输出上半部图案for(i0;i<3;i){for(j0;j<2-i;j)printf(" ");for(k0;k<2*i;k)printf("*");printf("\n");}//再输出下半部分图案for(i0;i<2;i){for(j0;j&…

springboot使用Mybatis中兼容多数据源的databaseId(databaseIdProvider)的简单使用方法

最近有兼容多数据库的需求&#xff0c;原有数据库使用的mysql&#xff0c;现在需要同时兼容mysql和pgsql&#xff0c;后期可能会兼容更多。 mysql和pgsql很多语法和函数不同&#xff0c;所以有些sql需要写两份&#xff0c;于是在全网搜索如何在mapper中sql不通用的情况下兼容多…

配置全局代理上网

#准备一台机器(160)&#xff0c;DNS注释掉 直接访问不行 curl https://www.baidu.com #代理访问OK curl -x 192.141.46.161:8888 https://www.baidu.com #CentOS设置全局代理 vi ~/.bashrc #加入以下内容 export http_proxyhttp://192.141.46.161:8888 export https_proxy…