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. ABP 番外篇-容器

    一. @using YD.CloudTimetable.Web.Areas.AppAreaName.Startup @{ ViewBag.CurrentPageName = AppAreaNamePa ...

  2. Sql server 系统表

    sql server系统表详细说明 SQL Server 用户库中系统表说明 名称 说明 备注 syscolumns 每个表和视图中的每列在表中占一行,存储过程中的每个参数在表中也占一行.   sys ...

  3. 第213天:12个HTML和CSS必须知道的重点难点问题

    12个HTML和CSS必须知道的重点难点问题 这12个问题,基本上就是HTML和CSS基础中的重点个难点了,也是必须要弄清楚的基本问题,其中定位的绝对定位和相对定位到底相对什么定位?这个还是容易被忽视 ...

  4. CentOS7 搭建影梭服务器

    安装Python包管理工具 yum install python-setuptools && easy_install pip 安装Shadowsocks pip install sh ...

  5. 2018-南京网络赛icpc-L题(分层最短路)

    题意:给你n个点,m条边的有向带权图,然后你每次可以选<=k条边的边权变成0,问你1到n的最短路: 解题思路:这道题基本上就是原题了呀,bzoj2763(无向图),解法就是拆点跑分层的最短路,比 ...

  6. 微服务配合docker使用

    1.docker 安装 rabbitmq 启动脚本: docker run -d --name rabbitmq --publish : \ --publish : --publish : --pub ...

  7. E - Just a Hook HDU - 1698 线段树区间修改区间和模版题

    题意  给出一段初始化全为1的区间  后面可以一段一段更改成 1 或 2 或3 问最后整段区间的和是多少 思路:标准线段树区间和模版题 #include<cstdio> #include& ...

  8. 洛谷P1501 Tree II

    LCT 还是LCT的板子,下放标记和那道线段树2一样,先放乘..之前用char忘记getchar,调了好久... 注意开long long!! #include <bits/stdc++.h&g ...

  9. 如何判断是否为同一个App,Ionic3如何修改包名

    如何判断是否同一个App 使用Ionic3创建了两个项目demo1.demo2,然后使用同一个JDK,生成了两个不同的keystore证书. 结果在手机端安装的时候,先安装demo1,没有任何替换的提 ...

  10. MobaXterm之取消自动关闭连接 Network error :Connection timed out

    连一会就出现连接重来的问题 配置如下.