windows nginx开机自启
时间: 2023-08-08 12:11:42 浏览: 140
要在Windows上实现Nginx开机自启动,可以按照以下步骤进行操作:
1. 首先,在Nginx安装目录下创建一个名为nginx-service.xml的文件,并将以下配置信息写入该文件中:\[1\]
```
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<logpath>D:\sofware\nginx\nginx-1.22.0\nginx-1.22.0\server-logs\</logpath>
<logmode>roll</logmode>
<depend></depend>
<executable>D:\sofware\nginx\nginx-1.22.0\nginx-1.22.0\nginx.exe</executable>
<stopexecutable>D:\sofware\nginx\nginx-1.22.0\nginx-1.22.0\nginx.exe -s stop</stopexecutable>
</service>
```
2. 然后,在start-nginx.xml文件中添加以下代码:\[2\]
```
<service>
<id>start-nginx</id>
<name>start-nginx</name>
<description>nginx self starting</description>
<logpath>D:\nginx-1.14.2\</logpath>
<logmode>roll</logmode>
<depend></depend>
<executable>D:\nginx-1.14.2\nginx.exe</executable>
<stopexecutable>D:\nginx-1.14.2\nginx.exe -s stop</stopexecutable>
</service>
```
3. 配置完成后,以管理员身份运行命令提示符,并切换到Nginx安装目录下,执行以下命令来将Nginx注册为Windows服务:\[3\]
```
.\nginx-service.exe install
```
4. 注册成功后,可以在Windows任务管理器的服务中查看到nginx服务。接下来,可以将该服务的启动方式设置为自动,以实现开机自启动。
请注意,以上步骤中的路径和文件名可能需要根据你的实际情况进行相应修改。
#### 引用[.reference_title]
- *1* *3* [Widows安装Nginx并设置开机自启](https://blog.csdn.net/qq_35112567/article/details/127392544)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [nginx 设置开机自启动](https://blog.csdn.net/gulang00/article/details/125721382)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文