欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

nginx环境搭建(windows)

程序员文章站 2024-02-14 21:41:40
...
安装nginx

下载nginx(官网)
本次下载的是:nginx/Windows-1.10.1(Mainline version)
然后将zip包解压,放到指定目录。
cmd查看nginx -h 命令

D:\nginx-1.11.1>nginx.exe -h
nginx version: nginx/1.11.1
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version andexit
  -V            : show version and configure options thenexit
  -t            : test configurationandexit
  -T            : test configuration, dump it andexit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signalto a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: NONE)
  -c filename   : set configurationfile (default: conf/nginx.conf)
  -g directives : set global directives outofconfigurationfile

官网文档命令说明(链接):

nginx/Windows runs asa standard console application (nota service), andit can be managed usingthe following commands:

nginx -s stop   fast shutdown
nginx -s quit   graceful shutdown
nginx -s reload changing configuration, starting new worker processes withanew configuration, graceful shutdown of old worker processes
nginx -s reopen re-opening logfiles

启动nginx:D:\nginx-1.11.1>start nginx.exe
然后打开浏览器输入localhost,可以看到如下:
nginx环境搭建(windows)
至此,nginx在windows上面就安装完毕了。

配置PHP的fast-cgi

官方教程(链接)
下载RunHiddenConsole,并放置在指定目录,例如c:\bin。
建立bat文件:start-php-fcgi.bat。文件内容如下(php-cgi.exe目录需配置):
@ECHO OFF
ECHO Starting PHP FastCGI...
set PATH=C:\PHP;%PATH%
c:\bin\RunHiddenConsole.exe C:\PHP\php-cgi.exe -b 127.0.0.1:9123

启动start-php-fcgi.bat文件。
配置nginx文件:nginx.conf。
修改server配置:

server {
        listen       80;
        server_name  localhost;
        root e:;

        #charset koi8-r;#access_log  logs/host.access.log  main;        location / {
            #root   E:;indexindex.html index.htm index.php;
        }

        #error_page  404              /404.html;# redirect server error pages to the static page /50x.html#
        error_page   500502503504  /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          E:;
            fastcgi_pass   127.0.0.1:9123;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;#/scripts$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;#}
    }

在root目录建立index.php

echo"it works";

然后cmd重启nginx。
浏览器里面打开localhost,看到:
nginx环境搭建(windows)

至此nginx+php配置完毕。

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了 nginx环境搭建(windows),包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。