windows11 安装nginx 教程(并开机自启动)

windows11 安装nginx 教程(并开机自启动)

1、官网下载安装

官网地址:http://nginx.org/en/download.html
在这里插入图片描述

2. 找个文件位置解压压缩包

在这里插入图片描述

3 启动NGINX

在这里插入图片描述

4 相关命令

查詢端口被占用的进程
netstat -ano | findstr "80"

1、查看nginx的版本号
nginx -v

2、启动nginx
start nginx  或者运行 nginx.exe

3、快速停止或关闭Nginx
nginx -s stop

4、正常停止或关闭nginx
nginx -s quit

5、配置文件修改后重加载命令:
nginx -s reload

6、查看nginx进程
tasklist /fi "imagename eq nginx.exe"

7、查看所有nginx进程
tasklist /fi "imagename eq nginx.exe"

8、彻底停止nginx服务
taskkill /f /t /im nginx.ex

标题5、将Nginx注册成服务,设置Nginx开机自动启动

1、下载小工具
下载地址:https://github.com/winsw/winsw/releases
在这里插入图片描述

在这里插入图片描述

2、注册服务
下载后将该工具放入Nginx的安装目录下,并且将其重命名为 nginx-service.exe ;

在这里插入图片描述
在该目录下新建 nginx-service.xml 文件,写入配置信息,配置好了之后就可以通过这个将Nginx注册为Windows服务了。

<!-- nginx-service.xml -->
<service>
    <id>nginx</id>
    <name>nginx</name>
    <description>nginx</description>
	<env name="HOME" value="%BASE%"/>
	    <logpath>%BASE%\server-logs</logpath>
    <log mode="roll-by-size-time">
      <sizeThreshold>10240</sizeThreshold>
      <pattern>yyyyMMdd</pattern>
      <autoRollAtTime>00:00:00</autoRollAtTime>
      <zipOlderThanNumDays>5</zipOlderThanNumDays>
      <zipDateFormat>yyyyMMdd</zipDateFormat>
    </log>
    <executable>%BASE%\nginx.exe</executable>
    <stopexecutable>‪%BASE%\nginx.exe -s stop</stopexecutable>
</service>

在nginx安装目录下以管理员运行命令:.\nginx-service.exe install 完成注册
在这里插入图片描述

启动对应的服务 nginx-service.exe start ,完成开机自启
在这里插入图片描述
可以查看服务
在这里插入图片描述
相关命令

注册系统服务命令
nginx-service.exe install

删除已注册的系统服务命令
nginx-service.exe uninstall

停止对应的系统服务命令
nginx-service.exe stop

启动对应的系统服务命令
nginx-service.exe start

参考文章
https://www.jianshu.com/p/a62bab2bd672
https://blog.csdn.net/m0_74173363/article/details/140775949
https://blog.csdn.net/weixin_46560589/article/details/125661743

在 macOS 上安装 nginx 的第三方模块可以使用 Homebrew 包管理器来简化过程。以下是安装第三方模块的步骤: 1. 首先,确保您已经安装了 Homebrew。如果您还没有安装,可以在终端中运行以下命令来安装 Homebrew: ``` /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` 2. 安装 nginx。在终端中运行以下命令来使用 Homebrew 安装 nginx: ``` brew install nginx ``` 3. 找到您想要安装的第三方 nginx 模块。您可以通过在搜索引擎上搜索或访问模块的官方网站来找到合适的模块。 4. 下载解压第三方模块的源代码。将源代码解压到一个您可以方便访问的位置。 5. 进入解压后的模块源代码目录,使用 `./configure` 命令配置编译选项。在这个命令中,您可以通过添加 `--add-dynamic-module=/path/to/module` 来指定要安装的模块。例如: ``` ./configure --add-dynamic-module=/path/to/module ``` 请将 `/path/to/module` 替换为您要安装的模块的实际路径。 6. 完成配置后,运行 `make` 命令编译 nginx。 7. 编译完成后,在终端中运行以下命令将编译好的模块复制到 nginx 的模块目录: ``` cp objs/*.so /usr/local/Cellar/nginx/{version}/libexec/modules/ ``` 请将 `{version}` 替换为您当前安装nginx 版本号。 8. 在终端中运行以下命令启动 nginx: ``` brew services start nginx ``` 现在,您已经成功安装了第三方模块,且可以在 nginx 的配置文件中启用和配置它们。 请注意,安装第三方模块可能需要一些编译工具和依赖项。如果出现任何错误或依赖项缺失,您可能需要安装相应的工具和库。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值