博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
windows下ngnix+php配置
阅读量:7203 次
发布时间:2019-06-29

本文共 2590 字,大约阅读时间需要 8 分钟。

hot3.png

1、需要工具:

    下载ngnix  网址:

    下载:

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

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

server {    listen      80;  #端口    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:9000;        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;        }    }

3、配置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

4、制作启动和关闭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

 

转载于:https://my.oschina.net/u/209161/blog/1613784

你可能感兴趣的文章
AutoCompleteTextView
查看>>
SecureCRT生成序列
查看>>
Android 应用程序主框架搭建
查看>>
2012腾讯春季实习生面试经历(二)
查看>>
用Bootstrap框架弹出iframe页面 在弹出的模态框中载人iframe页面,bootstrapiframe
查看>>
2012腾讯暑期实习面经(技术类web前端)
查看>>
第3种方法获取redis cluster主从关系
查看>>
注册表管理(本地、远程)
查看>>
《Linux内核设计与实现》第四周读书笔记——第五章
查看>>
关于COM组件log的位置
查看>>
C++操作符重载
查看>>
postgresql 时间戳格式为5分钟、15分钟
查看>>
linq中如何在join中指定多个条件
查看>>
交换排序
查看>>
【转】链表归并排序插入排序
查看>>
EL表达式和JSTL的使用
查看>>
递归:python 实现2分查找
查看>>
Centos6.5 安装 RabbitMQ3.6.1
查看>>
如何设置eclipse自动提示功能
查看>>
mosfet详解
查看>>