windows 配置nginx php resin

1。保持php-cgi.exe 在windows下 php-cgi处理了一定的请求之后会关闭,因此需要保持他持续运行,使用了http://xiaoxia.org/2011/02/01/xxfpm-wrote-a-fastcgi-process-manager/ 作者写得一个小程序xxfpm

Usage: xxfpm path [-n number] [-i ip] [-p port]
Manage FastCGI processes.

-n, --number number of processes to keep
-i, --ip ip address to bind
-p, --port port to bind, default is 8000
-u, --user start processes using specified linux user
-g, --group start processes using specified linux group
-r, --root change root direcotry for the processes
-h, --help output usage information and exit
-v, --version output version information and exit

使用例子:
xxfpm z:/php5/php-cgi.exe -n 5 -p 8080

有人问,如何给程序加入参数?这个不难,使用双引号即可,路径要用"/"而不用"\"。例如要指定php.ini的路径,可以用下面例子:
xxfpm "z:/php5/php-cgi.exe -c z:/php5/php.ini" -n 5 -i 127.0.0.1 -p 8080

启动脚本

RunHiddenConsole.exe D:\app\nginx-1.2.3\xxfpm.exe "D:\app\php\php-cgi.exe -c D:\app\php\php.ini" -i 127.0.0.1 -p 9000 -n 5

2.resin加入到windows的服务

httpd.exe -install即可 

httpd.exe -remove即可删除

3.nginx加入到windows服务

下载微软的2个工具: rktools.exe

将rktools安装目录下(一般在C:\Program Files\Windows Resource Kits\Tools目录)的srvany.exe拷贝到nginx目录下然后执行

instsrv.exe Nginx D:\nginx\srvany.exe

然后填入注册表项

方法一

Windows Registry Editor Version 5.00  

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NGINX\Parameters]

 "Application"="D:\\nginx\\nginx.exe"

"AppParameters"="参数"

"AppDirectory"="D:\\nginx\\"

方法二

打开注册表确认填写的信息,如果参数没有 则添加一个字符串项即可

    一般情况下该服务名下没有Parameters项目,需要手动建立:对服务名称项目右击新建项,名称为        

    Parameters,然后定位到Parameters项,新建以下几个字符串值。
    名称 Application 值为你要作为服务运行的程序地址。
    名称 AppDirectory 值为你要作为服务运行的程序所在文件夹路径。
    名称 AppParameters 值为你要作为服务运行的程序启动所需要的参数。 

添加注册表项

这样就可以将nginx加入到windows的服务,php-cgi.exe 加入服务的方法类似。

但是,当停止Nginix服务后,访问浏览器仍然能看到网站。查看进程,你会发现,Nginx启动了两个nginx进程(根据nginx.conf的配置worker_processes  1;),Fork出来的进程显然没有被停止,结果就是nginx永远关不掉。因此需要另外写个程序关闭nginx

 

posted @ 2013-10-24 20:39  血色舞  阅读(702)  评论(0编辑  收藏  举报