查看: 9192|回复: 0
打印 上一主题 下一主题

windows下nginx+php配置

[复制链接]
跳转到指定楼层
1#
发表于 2012-6-27 09:46:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
台州网址导航
版本 nginx0.8.20    php5.2.10

解压nginx到C:/web/nginx-0.8.20
解压php 到C:/web/php
//--------------------------------------------------------------------------------------
修改配置nginx.conf

gzip  on;

    server {
        listen       80;
        server_name  localhost;

        charset utf-8;

        #access_log  logs/host.access.log  main;

        location / {
            #root   html;        
            #index  index.html index.htm;
        root    D:/var/www;
        index   index.html index.htm 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           html;
        root       D:/var/www; #PHP文件目录
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name; #PHP文件
            include        fastcgi_params;
        #fastcgi_intercept_errors on;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

//-------------------------------------------------------------------
修改配置php.ini

enable_dl = On
cgi.force_redirect = 0
cgi.fix_pathinfo=1
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1

这几项和nginx相关,其它和mysql等相关的配置略

//--------------------------------------------------------------------

下载RunHiddenConsole

把"  @echo off
echo Starting PHP FastCGI...
RunHiddenConsole.exe c:\web\php\php-cgi.exe -b 127.0.0.1:9000 -c c:\web\php\php.ini   "引号中间部分用记事本保存并重命名为bat文件  和上面下载的文件放同一目录下,用于启动php-cgi

nginx启动直接双击nginx.exe


把"  @echo off
echo Stopping nginx...
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
exit " 引号中间部分用记事本保存,并重命名为bat文件,用于关闭php和nginx

//-------------------------------------------------------------------------
测试时浏览器中出现no input file specified错误时,注掉php.ini中的doc_root,解决

//-------------------------------------------------------------------------
nginx.conf添加两个虚拟机  bug和db

server {
        server_name  bug;
        location / {
            root   D:/var/www/bug/;
            index  index.html index.htm index.php;
        autoindex on;
        }
    location ~ \.php$ {
        root       D:/var/www/bug/;
            fastcgi_pass   127.0.0.1:9000;           
            include        fastcgi_params;      
        }
    }
    server {
        server_name  db;
        location / {
            root   D:/var/www/db/;
            index  index.html index.htm index.php;
        autoindex on;
        }
    location ~ \.php$ {
        root       D:/var/www/db/;
            fastcgi_pass   127.0.0.1:9000;           
            include        fastcgi_params;      
        }
    }



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

网站推广
关于我们
  • 台州朗动科技(Tzweb.com)拥有多年开发网站平台系统门户手机客户端等业务的成功经验。主要从事:政企网站,系统平台,微信公众号,各类小程序,手机APP客户端,浙里办微应用,浙政钉微应用、主机域名、虚拟空间、后期维护等服务,满足不同企业公司的需求,是台州地区领先的网络技术服务商!

Hi,扫描关注我

Copyright © 2005-2025 站长论坛 All rights reserved

Powered by 站长论坛 with TZWEB Update Techonolgy Support

快速回复 返回顶部 返回列表