荷塘月色__shanlxj的BLOG

  • 首页
  • 关于
  • 留言
  1. 首页
  2. 电子电脑
  3. 正文

WNMP nginx+php5+mysql测试环境安装(Windows7)

2010年5月29日 2点热度 0人点赞 0条评论

(更新中.. 软件安装在D:webserver下,网站根目录D:webroots)

1. 安装php

下载:http://windows.php.net/download/

这里下载PHP 5.2 (5.2.13)版本的VC6 x86 Non Thread Safe (2010-Feb-24 15:38:53) ZIP [9.95MB]

(最新的版本5.3.2一些软件不支持,比如下面的Zend Optimizer)

Notes:php版本选择

a.VC6版本是使用Visual Studio 6编译器编译的,如果你的php是用Apache来架设,就选择vc6版本;VC9版本是使用Visual Studio 2008编译器编译的,如果你的php使用IIS来架设的,就选择vc9版本

b.PHP的两种执行方式:ISAPI和FastCGI。ISAPI执行方式是以DLL动态库的形式使用,可以在被用户请求后执行,在处理完一个用户请求后不会马上消失,所以需要进行线程安全检查,这样来提高程序的执行效率,所以如果是以ISAPI来执行PHP,建议选择Thread Safe版本;而FastCGI执行方式是以单一线程来执行操作,所以不需要进行线程的安全检查,除去线程安全检查的防护反而可以提高执行效率,所以,如果是以FastCGI来执行PHP,建议选择Non Thread Safe版本。

解压缩至D:webserverphp-5.2.13

复制一份php.ini-recommended,更名为php.ini。查找下面几项,更改php.ini配置:其中extension_dir指定扩展位置;

error_reporting = E_ALL display_errors = On extension_dir = "D:webserverphp-5.2.13ext" doc_root = cgi.fix_pathinfo = 1

 

doc_root默认为空,不要指定,否则提示"No input file specified"

最后一句解除注释,允许修正地址,nginx将php请求交与Fast CGI Server处理

 (尚未开启mysql和pdo)

2. 安装nginx

下载:http://nginx.org/en/download.html

这里也下载了最新的nginx/Windows-0.8.36

解压缩至D:webservernginx-0.8.36

将confnginx.conf配置如下:

#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 64; } 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 80; server_name localhost; charset utf-8; #access_log logs/host.access.log main; location / { root D:webroot; index index.html index.php; autoindex on; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ .php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ .php$ { # root D:/webroot; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME D:/webroot$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443; # server_name localhost; # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_timeout 5m; # ssl_protocols SSLv2 SSLv3 TLSv1; # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} }

 其中

worker_processes 1;只默认开启一个进程

work_connections 64;测试服务器的话,一个进程允许64个最大连接数就可以了

server中listen 80;常与IIS冲突,在logserror.log中会看到如下提示:

2010/05/03 23:22:02 [emerg] 3492#5004: bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)

解决办法最好关闭IIS或更改掉IIS开启的端口

location / 指定网站根目录

添加autoindex on;允许目录结构查看

在location ~ .php$中修改nginx,将php请求转发给PHP FastCGI Server.

这里SCRIPT_FILENAME路径最好使用/,防止用被解析为特殊字符,如t是制表符

3. 开启关闭nginx

开启:

在php-5.3.2目录下新建bat如下,开始php-cgi,开启后任务管理器能看到php-cgi.exe

php-cgi -b 127.0.0.1:9000

php-cig这个dos窗口需要长开着,如果需要隐藏可以去这里下载一个小软件

http://blogbuildingu.com/files/RunHiddenConsole.zip

然后双击nginx.exe,任务管理器能看到nginx.exe

在D:webroot目录下新建index.php

<?php phpinfo(); ?>

访问http://localhost/就可以正常使用了

关闭:

新建bat如下

taskkill /F /IM nginx.exe > nul taskkill /F /IM php-cgi.exe > nul
标签: nginx php
最后更新:2010年5月29日

shan yan

现奇妙的爱情| 从握手的 | 瞬间开始 | it`s my fault | 不懂你的心 | 使这段爱 | 化成泪 | 流出手心 | 对不起!| 我爱你!!! 在某个黄昏,当那曾经让你心动的乐声不经意地滑入耳膜,伤感无奈,哀婉凄美,在你的心底,是否也会泛起点点滴滴的往事?那些你想忘记的,不想忘记的,或是原以为早已忘记的…… “我从不知道爱你会有那么的难  也许你早已经离开了我的身旁 我不要和别人一样 我会把眼泪往心里藏  相信你知道我的情感 这一生我永远不能忘

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复
最新 热点 随机
最新 热点 随机
晚饭一个改变,血糖、血压、脂肪肝都会变好 个人总结的存酒买酒经验 辽宁省管干部任前公示(2026年第5号) 辽宁省管干部任前公示(2026年第4号) ‌2024年度白酒十大百亿级单品排名! 申公豹20条经典语录,治愈了30年职场的我
辽宁省管干部任前公示(2026年第5号)个人总结的存酒买酒经验晚饭一个改变,血糖、血压、脂肪肝都会变好
各种茶叶的功效,千万不要喝错,精心搜集的,都顶一下啊。 忙?撒? 重庆女护士深陷“艳照门” 高校十大牛X搞笑个性签名,你敢晒晒自己的签名么? 娱乐圈急需结束单身的12位黄金剩女 拌小白菜
分类
  • 个人日记
  • 医疗健康
  • 开心一笑
  • 情感驿站
  • 感悟人生
  • 汽车天地
  • 生活美食
  • 电子电脑
  • 电视电影
  • 美女照片
标签聚合
爱情 经典 男人 美女 女人 女孩 女生 故事

COPYRIGHT © 2026 荷塘月色__shanlxj的BLOG. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

辽ICP备09024489号-1