Nginx的安装参考这里:Nginx windows安装_aganliang的博客-CSDN博客
基本思路是把Nginx注册为windows的服务。
1.下载winsw /kohsuke/winsw/releases
比如:4.exe sample-minimal.xml
2.配置
把上面两个文件修改名字为:nginxservice.exe nginxservice.xml
nginxservice.xml的配置修改为:
<configuration> <!-- ID of the service. It should be unique across the Windows system--><id>nginx</id><!-- Display name of the service --><name>nginx</name><!-- Service description --><description>This service is a service created from a minimal configuration</description> <logpath>E:\mysever\nginx-1.14.2</logpath><logmode>roll</logmode> <depend></depend> <!-- Path to the executable, which should be started --><executable>E:\mysever\nginx-1.14.2\nginx.exe</executable><stopexecutable>E:\mysever\nginx-1.14.2\nginx.exe -s stop</stopexecutable></configuration>
3.安装
cdE:\mysever\nginx-1.14.2\nginxservice.exe install如果之前安装过nginx服务,需要删除nginx这个id,才能重新安装:sc delete nginx
4.可以在services.msc中看到服务,重启即可自动运行Nginx。
如果觉得《Nginx设置windows开机自动启动》对你有帮助,请点赞、收藏,并留下你的观点哦!