到今天为止,我只摸索到简单的配置
环境:windows2003
前提:nginx-0.8.33.zip,srvany-instsrv.rar
下面是配置好的文件:
nginx.conf
#user nobody;
#进程数
worker_processes 2;
#错误日志文件
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
#每个进程允许的并发数224
events {
worker_connections 224;
}
#http代理配置
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
#本机监听端口
listen 9999;
#DNS
resolver 202.112.14.161;
location / {
proxy_pass http://$http_host$request_uri/;
}
}
}
nginx.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NGINX\Parameters]
"Application"="D:\\nginx\\nginx.exe"
"AppParameters"=""
"AppDirectory"="D:\\nginx\\"
下面是网上提供的资料:
从wnmp发布以来,很多朋友就问Windows下如何将Nginx加入服务中,以便于服务器重启后自动运行,我在朋友的留言中回复了,可能不是很好找,便整理在此,便于需要的朋友查找。
假设nginx安装在c:\nginx\下:
1.下载微软服务注册工具srvany.exe, instsrv.exe,http://blog.licess.cn/uploads/200901/srvany-instsrv.rar, srvany-instsrv存放到c:\nginx\目录下
2.安装Nginx服务, 将命令行切换到c:\nginx\,执行下列命令
instsrv NGINX d:\nginx\srvany.exe
3.在c:\nginx\下,新建一个nginx.reg文件,输入一下内容:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NGINX\Parameters]
“Application”=”C:\\nginx\\nginx.exe”
“AppParameters”=”"
“AppDirectory”=”C:\\nginx\\”
5.让服务与程序关联起来, 命令行执行
regedit /s nginx.reg
6.编辑启动nginx脚本start-nginx.bat(关闭脚本不用变), 让程序以服务方式运行
@ECHO OFF
net stop nginx
net start nginx
EXIT
完成~