win下nginx+php

来源:互联网 发布:淘宝买车可靠吗 编辑:程序博客网 时间:2024/06/04 17:51

1、分别下载nginx和php的安装包(两个都是解压即可用)
2、配置php
将php.ini-development文件复制并重命名为php.ini,并用Notepad++(没有安装此软件的话就使用记事本)打开php.ini:

查找并定位到行 修改为 ; extension_dir = “ext” extension_dir = “ext的绝对路径” ;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_mbstring.dll extension=php_mbstring.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

3、配置Nginx
Nginx的配置文件是在安装目录的conf文件夹下的nginx.conf,并用Notepad++(没有安装此软件的话就使用记事本)打开它:

找到

     location / {           root   html;           index  index.html index.htm;       }

改为

   location / {           root   html;           index  index.html index.htm index.php;       }

找到

   #location ~ \.php$ {       #    root           html;       #    fastcgi_pass   127.0.0.1:9000;       #    fastcgi_index  index.php;       #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;       #    include        fastcgi_params;       #}

改为

  location ~ \.php$ {           root           html;           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和php-cgi的bat批处理快速启动方法

start_nginx_php.bat

@echo offset php_home=D:/WNMP/php(php的解压路径)set nginx_home=D:/WNMP/nginx(nginx解压路劲)REM Windows 下无效REM set PHP_FCGI_CHILDREN=5REM 每个进程处理的最大请求数,或设置为 Windows 环境变量set PHP_FCGI_MAX_REQUESTS=1000echo Starting PHP FastCGI...RunHiddenConsole %php_home%/php-cgi.exe -b 127.0.0.1:9000 -c %php_home%/php.iniecho Starting nginx...RunHiddenConsole %nginx_home%/nginx.exe -p %nginx_home%

stop_nginx_php.bat

@echo offecho Stopping nginx...  taskkill /F /IM nginx.exe > nulecho Stopping PHP FastCGI...taskkill /F /IM php-cgi.exe > nulexit

http://www.wanghailin.cn/nginx-phpcgi-batfaststart/
http://www.tuicool.com/articles/YBJ3Yn

0 0
原创粉丝点击