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

nginx windows下安装成功

[复制链接]
跳转到指定楼层
1#
发表于 2012-6-27 09:52:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
台州网址导航
第一步 下载nginx ,windows版本,解压保存在C:/nginx下( 用的1.0.3版)

   第二步 下载 php fast-cgi版本(我用的是 VC9 x86 Non Thread Safe),解压到C:/php下

   第三步 把C:/php/php.ini-development重命名成C:/php/php.ini,找到#cgi.fix_pathinfo=1,把#号去掉

  第四步  修改C:/nginx/conf/nginx.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  1024;
}


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 koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #root   html;           //此处为默认路径
            root   D:/public_html;   //此处为我修改,要运行PHP程序的路径
            index  index.php index.html index.htm;  //增加了 index.php
        }

        #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$ {
         #   root         php;
            #index        index.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:/public_html;        //运行的PHP程序路径
            fastcgi_pass   127.0.0.1:9000;  
            fastcgi_index  index.php;          //默认首页程序
            fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;  //$document_root 指的是上面的 D:/public_html
            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;
    #    }
    #}

}

   第五步 ,PHP以fast-cgi形式运行

在CMD下运行下面(路径可能有些不同)

C:\php>php-cgi.exe -b 127.0.0.1:9000 -c C:/php/php.ini

第六步  点击运行 nginx.exe  ,运行nginx

第七步  浏览器中输入 localhost/index.php,就运行D:/public_html/index.php这个程序了

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

本版积分规则

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

Hi,扫描关注我

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

Powered by 站长论坛 with TZWEB Update Techonolgy Support

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