window开机启动nginx服务器
要在 Windows 开机时启动 Nginx 服务器,可以按照以下步骤操作:
-
打开命令提示符窗口(按 Win+R,输入 cmd,按 Enter)。
-
进入到 Nginx 安装目录下的
conf文件夹,例如:
cd C:\nginx\conf
- 编辑
nginx.conf文件,添加以下内容:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
注意:上述内容只是一个简单的示例配置,具体的配置内容需要根据实际情况进行修改。
-
保存
nginx.conf文件,并退出编辑器。 -
打开服务管理器(按 Win+R,输入 services.msc,按 Enter)。
-
找到名为
nginx的服务,右键点击,选择属性。 -
在属性窗口中,将
启动类型设置为自动,点击应用,然后点击确定。 -
关闭所有窗口,重新启动计算机。
这样,在 Windows 开机时,Nginx 服务器就会自动启动,可以通过浏览器访问 http://localhost 来测试是否正常工作。
原文地址: https://www.cveoy.top/t/topic/Lub 著作权归作者所有。请勿转载和采集!