windows下nginx+php安装配置

zh375288 9年前

来自: http://my.oschina.net/tongjh/blog/614802


一、下载nginx http://nginx.org/en/download.html 解压后进入目录双击nginx.exe就启动服务了

二、下载php http://php.net/downloads.php 解压后进入目录找到php.ini 配置一下

;extension=php_gd2.dll,删除前面的分号:extension=php_gd2.dll  ;extension=php_mbstring.dll,删除前面的分号:extension=php_mbstring.dll  ;extension=php_mysql.dll,删除前面的分号:extension=php_mysql.dll  ;extension=php_mysqli.dll,删除前面的分号:extension=php_mysqli.dll  ;extension=php_pdo_mysql.dll,删除前面的分号:extension=php_pdo_mysql.dll  ;cgi.force_redirect = 1,删除前面的分号:cgi.force_redirect = 1  ;cgi.fix_pathinfo=1,删除前面的分号:cgi.fix_pathinfo=1  ;cgi.rfc2616_headers = 0,删除前面的分号:cgi.rfc2616_headers = 1



三、进入nginx目录创建start_nginx.bat文件(启动nginx服务与php-cgi)
@echo off  echo start_nginx.bat  echo Starting PHP FastCGI...    cd G:/php5618 & runhiddenconsole php-cgi.exe -b 127.0.0.1:9000 -c php.ini    echo starting nginx...    cd G:/nginx181 & start nginx.exe    exit



再创建stop_nginx.bat(关闭nginx服务与php-cgi) 

@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

双击 stop_nginx.bat关闭,双击start_nginx.bat启动


四、打开nginx/conf/nginx.conf文件,配置一个服务

worker_processes  1;    events {      worker_connections  1024;  }    http {      include       mime.types;      default_type  application/octet-stream;      sendfile        on;      keepalive_timeout  65;      server{     listen  8888;    server_name localhost;    location  / {     root G:/www;     index index.html index.htm index.php;     autoindex on;    }      location ~ \.php$ {              fastcgi_pass   127.0.0.1:9000;              fastcgi_index  index.php;              fastcgi_param  SCRIPT_FILENAME  G:/www$fastcgi_script_name;              include        fastcgi_params;          }     }  }



双击 start_nginx.bat启动服务,ok 正常