1下载

http://nginx.org/en/download.html

选择稳定版下载。

2 解压后 直接双击nginx.exe

双击后一个黑色的弹窗一闪而过

3 修改配置文件nginx.conf

3.1 修改你的站点名称 我这边还是localhost

3.2

   location / {
#root html;
root E:/ts.p2ps.cn;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$query_string; if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
} }

3.3

location ~ \.php$ {
root E:/ts.p2ps.cn;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

4 启动nginx

在cmd窗口下切换目录 输入命令:  nginx.exe

5 修改php.ini配置

修改E:\PHP\php5.5\php5.5.12\ext下的php.ini-development文件,将文件名修改为php.ini,打开php配置文件php.ini:

搜索“extension_dir”,找到: ;extension_dir = “ext” 先去前面的分号再改为 extension_dir = “E:\PHP\php5.5\php5.5.12\ext”

搜索“date.timezone”,找到:;date.timezone = 先去前面的分号再改为 date.timezone = Asia/Shanghai

搜索“enable_dl”,找到:enable_dl = Off 改为 enable_dl = On

搜索“cgi.force_redirect” ;cgi.force_redirect = 1 先去前面的分号再改为 cgi.force_redirect = 0

搜索“fastcgi.impersonate”,找到: ;fastcgi.impersonate = 1 去掉前面的分号

搜索“cgi.rfc2616_headers”,找到:;cgi.rfc2616_headers = 0 先去前面的分号再改为 cgi.rfc2616_headers = 1

搜索“php_mysql”,找到:”extension=php_mysql.dll和extension=php_mysqli.dll 去掉前面的“;”extension=php_mysql.dll和extension=php_mysqli.dll (支持MYSQL数据库)

6  运行php

F:\xmapp\php>php-cgi.exe -b 127.0.0.1:9000 -c php.ini

7  打开浏览器 输入localhost 运行成功

8 停止nginx服务器

nginx -s stop

如果使用cmd命令窗口启动nginx,关闭cmd窗口是不能结束nginx进程的,可使用两种方法关闭nginx

(1)输入nginx命令  nginx -s stop(快速停止nginx)  或  nginx -s quit(完整有序的停止nginx)

(2)使用taskkill   taskkill /f /t /im nginx.exe

10 制作批处理命令快速启动与关闭

下载软件RunHiddenConsole.exe:

http://redmine.lighttpd.net/attachments/660/RunHiddenConsole.zip

start_nginx.bat

@echo off

REM set PHP_FCGI_CHILDREN=5
set PHP_FCGI_MAX_REQUESTS=1000 echo Starting PHP FastCGI...
F:\nginx-1.14.2\RunHiddenConsole "F:\xmapp\php\php-cgi.exe" -b 127.0.0.1:9000 -c "F:\xmapp\php\php.ini"
echo Starting nginx...
F:\nginx-1.14.2\RunHiddenConsole "F:/nginx-1.14.2/nginx.exe" -p "F:/nginx-1.14.2/"

stop_nginx.bat

@echo off
echo Stopping nginx...
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
exit

就可以双击运行控制启动与停止了。

11 参考资料

https://blog.csdn.net/weixin_41782253/article/details/82706617

12 直接用phpstudy

#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;
root E:/ts.p2ps.cn; #access_log /tmp/testing.p2ps.cn.log;
#error_log /tmp/testing.p2ps.cn.log; #"upstream sent too big header" issue
#nginx 错误
# FirePHP 等造成头部过大的错误
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k; # 设置expires和max-age的时间
location ~* "^.+\.(jpe?g|gif|css|png|js|ico|pdf|zip|tar|t?gz|mp3|wav|swf)$" {
expires 30d;
log_not_found off;
} #location / {
# try_files $uri $uri/ /index.php?$args;
#} #将request指向index.php
location / {
index index.php index.html index.htm;
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
rewrite ^(.+)$ /index.php last;
} #主程序目录不能被访问
#location /www/{
# deny all;
#}
location /src/ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root/src/index.php;
include fastcgi_params;
#client_max_body_size 50m;
} #引用PHP CGI
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 600;
include fastcgi_params;
}
} # 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 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }

Windows 配置nginx服务器 运行php项目的更多相关文章

  1. windows配置nginx实现负载均衡集群

    windows配置nginx实现负载均衡集群2014-08-20 09:44:40   来源:www.abcde.cn   评论:0 点击:617 网上大部分关于nginx负载均衡集群的教程都是lin ...

  2. windows配置nginx实现负载均衡集群 -请求分流

    windows配置nginx实现负载均衡集群 一.windows上安装nginx 1.下载nginx的windows版本http://nginx.org/en/download.html 2.把压缩文 ...

  3. Windows Server - SVN 服务器搭建与项目配置、客户端安装与配置

    本教程以Windows Server 2012 R12 为例搭建SVN服务器,安装部署完成后,客户端可通过SVN客户端访问SVN服务器上的项目,也可以访问网上其他SVN服务器上的项目. 一.首先准备三 ...

  4. mac 安装nginx,并配置nginx的运行环境

    1. 安装nginx // 查询有没有nginx brew search nginx //开始安装nignx brew install nginx 2. 检查nignx是否安装成功 nginx -V ...

  5. Linux服务器安装配置Nginx服务器

      Nginx("engine x")是一款是由俄罗斯的程序设计师Igor Sysoev所开发高性能的 Web和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务 ...

  6. 基于Windows 配置 nginx 集群 & 反向代理

    1.下载 nginx 下载页面 : http://nginx.org/en/download.html 具体文件: http://nginx.org/download/nginx-1.7.0.zip ...

  7. Linux安装配置Nginx服务器

    如有需要可以加我Q群[308742428]大家一起讨论技术,有偿服务. 后面会不定时为大家更新文章,敬请期待. 喜欢的朋友可以关注下. 前言 今天搭建nginx服务器,来访问静态资源文件. Nginx ...

  8. ubuntu14.04安装与配置nginx服务器

    去年曾经配置过nginx服务器,可惜的是,几个月前因故障磁盘被格式化.今天又要用到nginx服务,所以从新配置了一番,但这次就不是那么顺利了.在此,愿与大家分享一下经验.只是简单的局域网应用,并未复杂 ...

  9. eclipse中配置Tomcat服务器以及新建项目

    eclipse配置Tomcat服务器 http://jingyan.baidu.com/article/ca2d939dd90183eb6d31ce79.html eclipse中配置Tomcat服务 ...

随机推荐

  1. IC卡冷复位时序

    冷复位(cold reset):当提供给IC卡的电源电压和其他信号从静止状态中复苏且收到复位信号后,IC卡产生的复位. 在触点激活后,终端将发出一个冷复位信号,并从IC卡获得一个复位应答信号,过程如下 ...

  2. Python全栈之路----函数----匿名函数

    用lambda声明匿名函数,对lambda定义名字,才能被调用.下面的calc和func功能一致. def calc(x,y): return x*y func = lambda x,y: x*y # ...

  3. MyCat配置详解

    MyCAT 配置解析 server.xml Mycat的配置文件,设置账号.参数等schema.xml Mycat对应的物理数据库和数据库表的配置rule.xml Mycat分片(分库分表)规则 一 ...

  4. ios-上传图片到后台

    做第一个项目时,有个版块的个人信息的编辑涉及到头像修改,老大说项目里有通用的代码,让我自己去找.总算找到,搞了许久才弄好,看来理解能力还需要提高啊!! #pragma mark- 修改头像上传后保存 ...

  5. Android studio 启动模拟器出现 VT-x is disabled in BIOS 以及 /dev/kvm is not found

    Android studio 启动模拟器出现 VT-x is disabled in BIOS 以及 /dev/kvm is not found 网上大部分文章都是说在bios开启vt-x支持等.这里 ...

  6. OpenResty 最佳实践 lua与nginx的结合 --引用自https://moonbingbing.gitbooks.io/openresty-best-practices/content/

    系统的说明了lua在nginx上的开发 请大家到源址查看 OpenResty最佳实践

  7. 【rocketMQ】之centos6.9安装RocketMQ4.2

    基于最新的RocketMQ4.2版本,搭建2Master模式. 硬件环境:centos6.9_x64(两台虚拟机) IP1:192.168.150.128 IP2:192.168.150.129 1. ...

  8. solr6.4.1搜索引擎(5)使用zookeeper3.4.9分布式集群

    本文讲的是如何使用zookeeper将solr分布式部署,也可以理解为tomcat分布式部署. 为什么要使用zookeeper,请参考文章<Solr的SolrCloud与Master-slave ...

  9. 数据库SQL语言学习----左外连接,右外连接,外连接,自然连接的形象对比

    现在有两张表,一张Student 另一张Score   1.查询每个学生及其选修课程的情况: 自然连接,Sno在Cscore中找不到就不显示,Cno在Cscore中找不到也不显示 SELECT Stu ...

  10. 安装ORACLE高可用RAC集群11g执行root脚本的输出信息

    安装ORACLE高可用RAC集群11g执行root脚本的输出信息 作者:Eric 微信:loveoracle11g [root@node1 ~]# /u01/app/oraInventory/orai ...