Nginx 使用在windows下的配置备忘录
分类: bordfServer | 标签: | 日期:2009-06-30
nginx [engine x] 是由 Igor Sysoev开发的一个HTTP 服务器和mail 代理服务器软件
Nginx 因其稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。Nginx 超越Apache的高性能和稳定性,使得国内使用 Nginx 作为 Web 服务器的网站也越来越多,其中有新浪、网易、腾讯等门户网站,六间房、酷6等视频分享网站,Discuz!、水木社区等知名论坛,豆瓣、YUPOO等新兴 Web 2.0网站。
所以我也打算给我手上的服务器们都换上这个。首先解决使用fastcgi的办法去完成php。
下载后直接运行 nginx.exe 就可以开启nginx机制,提供web服务了
需要注意的是要在服务中加上他的 自动启动~
sc create nginx binpath= “C:\nginx\nginx.exe” start= auto displayname= “bordfServer_nginx”
sc description nginx “nginx提供bordfServer中的web服务,bordf制作 欢迎访问www.bordf.com.cn”
加服务不好用的 就这样干:
—————————————–
假设nginx安装在c:\nginx\下:
1.下载微软服务注册工具srvany.exe, instsrv.exe, srvany-instsrv存放到c:\nginx\目录下
2.安装Nginx服务, 将命令行切换到c:\nginx\,执行下列命令
instsrv NGINX c:\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
—————————————-
然后修改nginx配置!加载php fastcgi
我使用的 是php-5.2.10-Win32
修改php.ini-dist 为php.ini 打开去掉某些常用的DLL的注释
extension=php_mcrypt.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_gd2.dll
extension_dir = ” 注意实际路径PHP\ext\”
然后 修改nginx的 nginx.conf
gzip on;
location / {
root php; 网站路径
index index.php index.html index.htm; 默认页
}
error_page 404 /404.html; 404错误页
——————————————–
location ~ \.php$ {
# root php; 网站路径
fastcgi_pass 127.0.0.1:9000; 监听9000端口。fastcgi的运行端口
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME 网站路径$fastcgi_script_name;
include fastcgi_params;
}
然后就可以使用了~
php-cgi.exe -b 127.0.0.1:9000 -q 开启php监听
taskkill /f /im nginx.exe 终止 nginx进程
同时启动nginx和fastcgi的批处理
@echo off
REM “正在启动Nginx 服务器……..”
start nginx
REM “开始启动PHP FastCGI………”
start php-cgi.exe -b 127.0.0.1:9000
直接杀死进程的:
@echo off
taskkill /f /im nginx.exe
taskkill /f /im php-cgi.exe
注意联合使用phpmyadmin的时候要查看这里:
include 里的config.default.php
$cfg['Servers'][$i]['controluser'] = ‘root’;
$cfg['Servers'][$i]['controlpass'] = ”;
因为我的mysql 超级管理用户root密码为0,还要记得看
$cfg['Servers'][$i]['AllowNoPasswordRoot'] = false; 一共要改成true!
要不就phpmyadmin访问被拒绝了~
其实人家是为了数据库的安全着想~
你的root密码为空,以当前的安全级别不允许登录 。应该这样提示下的!
现在nginx可以用了 php fastcgi 也可以用了~ mysql也可以了 。剩下的 就是
进行 bordfServer的组装了 设置 服务了!
bordfServer 组件包初步制作完成了,大小在13M左右,还可以接受 呵呵~
包含:nginx-0.8.4 、php-5.2.10-Win32 、mysql-noinstall-5.0.22-win32 与phpMyAdmin-3.1.2 当然我还写上了discuz的 rewrite 规则!
