1、需要工具:

下载ngnix  网址:http://nginx.org/

下载:RunHiddenConsole

第二步 将下载文件解压后,将RunHiddenConsole拷贝到ngnix目录与php所在目录

修改conf目录下ngnix.conf,使其支持php

 site:

 server {
listen ; #端口
server_name example.org www.example.org; #域名
root e:/www; location / {
index index.html index.php;
} location ~* \.(gif|jpg|png)$ {
expires 30d; #缓存图片文件
}
#支持php
location ~ \.php$ {
fastcgi_pass 127.0.0.1:;
fastcgi_param SCRIPT_FILENAME
e:/www$fastcgi_script_name;
include fastcgi_params;
}
}

另外可以把虚拟主机单独出来

在ngnix.conf文件中加入如下代码

http{

#其它代码

include vhost/*.conf; #加载vhost目录下的虚拟主机配置文件 

}

可以在conf文件夹中新建一个vhost文件夹,在此目录下建立新文件自定义文件名,扩展名为conf即可,在文件中加入如下代码

 server {
listen 80;
server_name www.szs.com; #charset koi8-r; #access_log logs/host.access.log main; location / {
root E:/20nc;
index index.php index.html index.htm;
} #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:/wamp/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME E:/20nc$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(gif|jpg|png)$ {
expires 30d;
} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}

  

第三步:配置php.ini文件使其支持cgi

;cgi.force_redirect = 1,删除前面的分号:cgi.force_redirect = 1

;cgi.fix_pathinfo=1,删除前面的分号:cgi.fix_pathinfo=1

;cgi.rfc2616_headers = 0,删除前面的分号:cgi.rfc2616_headers = 1

第四步:制作启动和关闭ngnix文件

注意:路径请自行更改

start.bat

@echo off
echo start_nginx.bat
  echo Starting PHP FastCGI...
cd D:/bin/php/php5.5.12
d:
  RunHiddenConsole php-cgi.exe -b 127.0.0.1:9000 -c php.ini
  echo Starting nginx...
cd C:/nginx
c:
  RunHiddenConsole nginx.exe
  Exit exit.bat @echo off
  echo stop_nginx.bat
  echo Stopping nginx...
  taskkill /F /IM nginx.exe > nul
  echo Stopping PHP FastCGI...
  taskkill /F /IM php-cgi.exe > nul
  exit

 

windows下ngnix+php配置的更多相关文章

  1. Windows下python的配置

    Windows下python的配置 希望这是最后一次写关于python的配置博客了,已经被python的安装烦的不行了.一开始我希望安装python.手动配置pip并使用pip安装numpy,然而发现 ...

  2. Windows 下用 gogs 配置局域网 git server

    大道曙光 Windows 下用 gogs 配置局域网 git server 最近要用 C# 开发一个新的项目,所以需要在 Windows 局域网环境下构建一个 git server. 在 Window ...

  3. Windows 下如何安装配置Snort视频教程

    Windows 下如何安装配置Snort视频教程: 第一步: http://www.tudou.com/programs/view/UUbIQCng360/ 第二部: http://www.tudou ...

  4. PHP学习之-Mongodb在Windows下安装及配置

    Mongodb在Windows下安装及配置 1.下载 下载地址:http://www.mongodb.org/ 建议下载zip版本. 2.安装 下载windows版本安装就和普通的软件一样,直接下一步 ...

  5. Windows下caffe的配置和调用caffe库(一)

    一.Windows下caffe的配置: 1. 下载caffe官网提供的开发包,https://github.com/microsoft/caffe 2. 将caffe-master目录下的Window ...

  6. windows下安装和配置redis

    1.windows下安装和配置redis 1.1 下载: 官网(linux下载地址):https://redis.io/ Windows系统下载地址:https://github.com/MSOpen ...

  7. Windows下为 Eclipse 配置 C/C++ 编译环境(转)

    1.Eclipse及CDT的安装 CDT的全称是C/C++ DevelopmentTools,CDT使得Eclipse能够支持C/C++的开发.直接下载 eclipse CDT 集成版 下载地址:ht ...

  8. windows下安装和配置多个版本的JDK

    https://jingyan.baidu.com/article/47a29f2474ba55c015239957.html 如何在windows下安装和配置多个版本的jdk,本文将带你在windo ...

  9. 网络基础 Windows下安装和配置net-snmp 代理

    Windows 下安装和配置net-snmp 代理[摘录] by:授客 QQ:1033553122   A.   安装  1.   安装前准备 ActivePerl-5.10.0.1004-MSWin ...

随机推荐

  1. tensorflow中使用指定的GPU及GPU显存 CUDA_VISIBLE_DEVICES

    参考: https://blog.csdn.net/jyli2_11/article/details/73331126 https://blog.csdn.net/cfarmerreally/arti ...

  2. 官网下载旧版本jdk,老版本jdk,jdk1.7,jdk1.8

    1.进入中文oracle官网(不是国内官网下载速度超级慢): http://www.oracle.com/technetwork/cn/indexes/downloads/index.html 2.进 ...

  3. BizTalk Server 如何处理大消息

    什么是大消息? 遗憾的是,此问题的答案不而直接与特定的消息大小,绑定,取决于你的 Microsoft 的特定瓶颈 BizTalk Server 系统. 与大消息关联的问题可分为以下几类: 内存不足错误 ...

  4. Spring Boot自动配置与Spring 条件化配置

    SpringBoot自动配置 SpringBoot的自动配置是一个运行时(应用程序启动时)的过程,简化开发时间,无需浪费时间讨论具体的Spring配置,只需考虑如何利用SpringBoot的自动配置即 ...

  5. Codeforces Round #440 Div. 1

    A:显然应该尽量拆成4.如果是奇数,先拆一个9出来即可. #include<iostream> #include<cstdio> #include<cmath> # ...

  6. Minimum number of steps CodeForces - 805D(签到题)

    D. Minimum number of steps time limit per test 1 second memory limit per test 256 megabytes input st ...

  7. Django 调用报错 " ImportError: Couldn't import Django. "

    系统炸了导致不得已重装 安装 Django后 利用ORM 创建表的时候报错 Traceback (most recent call last): File "manage.py", ...

  8. 基于 __new__ 方法的单例模式

    单例模式定义 首次实例化创建实例化对象 之后的每次实例化都用最初的实例化对象 即单实例模式 __new__ 的原理 __new__ 方法可以在 __init__ 方法执行 这样可以在初始化之前进行一系 ...

  9. synchronized 关键字解析

    synchronized 关键字解析 同步锁依赖于对象,每个对象都有一个同步锁. 现有一成员变量 Test,当线程 A 调用 Test 的 synchronized 方法,线程 A 获得 Test 的 ...

  10. 【刷题】BZOJ 1413 [ZJOI2009]取石子游戏

    Description 在研究过Nim游戏及各种变种之后,Orez又发现了一种全新的取石子游戏,这个游戏是这样的: 有n堆石子,将这n堆石子摆成一排.游戏由两个人进行,两人轮流操作,每次操作者都可以从 ...