第三, 启动nginx 服务器,再启动php 的FasCGI sever 。关于php FastCGI server 可以使用以下命令:
php-cgi.exe -b 127.0.0.1:9000 -q
这样做,缺陷是命令行窗口一直打开,若关闭那FastCGI server 也关闭啦。到网上下载RunHiddenConsole.exe 可以使命令行窗口隐藏啦。(RunHiddenConsole.exe下载页面 )
RunHiddenConsole.exe php-cgi.exe -b 127.0.0.1:9000 -q
你也可以写一个批处理来做这件事:
@echo off
start /min RunHiddenConsole.exe php-cgi.exe -b 127.0.0.1:9000 -q
Web 2009-10-29 17:09:39 阅读43 评论0 字号:大中小
PHP的 FastCGI服务批处理脚本,用它可以增强了phpcgi的健壮!phpcgi进程无故崩溃后可以重建进程!
下载地址:
ftp://ftp.wlmp-project.net/pub/WLMP-Project/Other/PHP-FastCGI/
Package name: FastCGI Server Script for PHP
Version:
1.0 RC1
Release date: 2008-12-16 / 02:51:20
Language: English
Platform:
Windows 2000 / XP / 2003
License: GNU General Public License,
Version 2
Comments: PHP-FastCGI Batch Script 1.0 (Release Candidate
1)
This file is part of WLMP ToolKit
Version 1.1.24 (2008/12/16).
(Compatible with WLMP-1.2.x API.)
顺便贴一下脚本的内容,文件名“PHPFCGI.CMD”,使用时需要修改的有2个地方,
PHP
目录及PHP-CGI.exe文件名。
@ECHO OFF
REM
/***#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#***\
REM \ W |
WLMP PROJECT TOOLKIT - PHPFCGI.CMD | W /
REM / L | - - - - - - - -
- - - - - - - - - - - - - | L \
REM \ M | Copyright (C)
2006-2008. | M /
REM / P | WLMP Project TEAM / D-Club
Soft. | P \
REM
\***#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#***/
REM ToolKit Version: 1.1.24 (2008/12/16)
REM This file is a part of WLMP Webserver Package.
REM
Compatible with WLMP-1.2.x API.
REM License: GNU/General Public
License 2.0
:HEAD
ECHO
=================================================
ECHO PHP-FastCGI
Server for Windows, Version 1.0 ^(RC1^)
ECHO
=================================================
ECHO.
ECHO
Copyright (C) 2006-2008 WLMP Project TEAM.
REM
=====================
REM SET EXECUTABLE VALUES
REM
=====================
SET
ROOT=C:\PHP5
SET EXEC=php-cgi.exe
IF
NOT EXIST "%ROOT%\%EXEC%" (
ECHO.
ECHO Fatal Error:
ECHO
------------
ECHO '%ROOT%\%EXEC%' not found.
GOTO QUIT
)
REM =============
REM SET FUNCTIONS
REM
=============
IF "%1"=="" GOTO HELP
IF
"%1"=="-h" GOTO HELP
IF "%1"=="-b" (
GOTO
CHKBIND
) ELSE (
ECHO.
ECHO Fatal Error:
ECHO ------------
ECHO
Invalid parameter.
GOTO HELP
)
:CHKBIND
REM
===================
REM CHECK ADDRESS VALUE
REM
===================
IF "%2"=="" (
ECHO.
ECHO
Fatal Error:
ECHO ------------
ECHO Server address isn't defined.
GOTO
HELP
) ELSE (
SET BIND=%2
)
IF "%3"=="" GOTO SETDEFS
IF "%3"=="-p" (
GOTO
CHKPORT
) ELSE (
ECHO.
ECHO Fatal Error:
ECHO ------------
ECHO
Invalid parameter.
GOTO HELP
)
:CHKPORT
REM
================
REM CHECK PORT VALUE
REM ================
IF "%4"=="" (
ECHO.
ECHO Fatal Error:
ECHO
------------
ECHO Server port isn't defined.
GOTO HELP
) ELSE (
SET
PORT=%4
)
IF "%5"=="" GOTO SETDEFS
IF "%5"=="-c" (
GOTO CHKCHLD
) ELSE (
ECHO.
ECHO
Fatal Error:
ECHO ------------
ECHO Invalid parameter.
GOTO
HELP
)
:CHKCHLD
REM
=================
REM CHECK CHILD VALUE
REM =================
IF "%6"=="" (
ECHO.
ECHO Fatal Error:
ECHO
------------
ECHO Child processes aren't defined.
GOTO HELP
)
ELSE (
SET CHLD=%6
GOTO CHKRCVE
)
:CHKRCVE
REM
=====================
REM CHECK RECURSIVE VALUE
REM
=====================
IF "%7"=="-r" (
SET
RCVE=Y
GOTO SETENV
)
IF "%7"=="-s" (
SET
RCVE=N
GOTO SETENV
)
IF "%7"=="" (
GOTO
SETDEFS
) ELSE (
ECHO.
ECHO Fatal Error:
ECHO ------------
ECHO
Invalid parameter.
GOTO HELP
)
:HELP
REM ====
REM HELP
REM ====
ECHO.
ECHO Command-line usage:
ECHO -------------------
ECHO
%0 -b ^<address^> -p ^<port^> -c ^<number of childs^>
[-r^|-s]
IF "%1"=="-h" GOTO QUIT
IF
"%1"=="-?" GOTO QUIT
IF "%1"=="" (
GOTO
SETDEFS
) ELSE (
GOTO QUIT
)
:SETDEFS
REM =================
REM SET SERVER VALUES
REM
=================
ECHO.
ECHO Set
server values
ECHO -----------------
IF
NOT DEFINED BIND (
SET BIND=127.0.0.1
) ELSE (
GOTO SELPORT
)
:SETBIND
SET /P BIND="Server address [%BIND%]: "
:SELPORT
IF NOT DEFINED PORT (
SET PORT=1879
)
ELSE (
GOTO SELCHLD
)
:SETPORT
SET
/P PORT="Server port [%PORT%]: "
:SELCHLD
IF
NOT DEFINED CHLD (
SET CHLD=5
) ELSE (
GOTO SELRCVE
)
:SETCHLD
SET /P CHLD="Child processes [%CHLD%]: "
:SELRCVE
IF NOT DEFINED RCVE (
SET RCVE=Y
)
ELSE (
GOTO SETENV
)
ECHO.
:SETRCVE
SET /P RCVE="Do you want to run server
as recursive mode [Y/n]: "
:SETENV
IF
%CHLD% GEQ 10 (
SET PHP_FCGI_CHILDREN=10
) ELSE (
SET
PHP_FCGI_CHILDREN=%CHLD%
)
SET PHP_FCGI_MAX_REQUESTS=1000
IF "%RCVE%"=="y" SET RECURSE=ENA
IF "%RCVE%"=="Y"
SET RECURSE=ENA
IF "%RCVE%"=="n" SET RECURSE=DIS
IF "%RCVE%"=="N"
SET RECURSE=DIS
ECHO.
ECHO PHP Version
Information
ECHO -----------------------
SET CDIR=%CD%
CD /D "%ROOT%"
%EXEC% -v
ECHO.
ECHO FastCGI Server Options
ECHO
----------------------
ECHO Host: %BIND%
ECHO Port: %PORT%
ECHO
Child processes: %PHP_FCGI_CHILDREN% ^(Max requests:
%PHP_FCGI_MAX_REQUESTS%^)
IF
"%RECURSE%"=="ENA" (
ECHO Crash detection: RECURSIVE ^(protected
mode^)
) ELSE (
ECHO Crash detection: STANDALONE ^(non-protected
mode^)
)
ECHO.
ECHO Event log
ECHO
---------
GOTO EXECRUN
:GENMSG
REM ===============
REM
SET DATE FORMAT
REM ===============
SET FDATE=%DATE:~0,4%/%DATE:~5,2%/%DATE:~8,2%
IF
"%TIME:~0,1%"==" " (
SET FTIME=0%time:~1,1%:%time:~3,2%:%time:~6,2%
)
ELSE (
SET FTIME=%time:~0,2%:%time:~3,2%:%time:~6,2%
)
ECHO [%FDATE% %FTIME%] - %CMESSAGE%
IF NOT DEFINED ITEM (
GOTO EXECRUN
) ELSE (
GOTO
%ITEM%
)
:EXECRUN
IF NOT DEFINED ITEM (
SET CMESSAGE=PHP-FastCGI Server is
started.
) ELSE (
SET CMESSAGE=PHP-FastCGI Server is
^(re^)started.
)
SET ITEM=SPAWNPHP
GOTO GENMSG
:SPAWNPHP
%EXEC% -b %HOST%:%PORT%
IF "%RECURSE%"=="ENA" (
SET CMESSAGE=Server is crashed,
restarting...
SET ITEM=EXECRUN
) ELSE (
SET CMESSAGE=Server is
crashed, aborting...
SET ITEM=CRASH
)
GOTO GENMSG
:CRASH
ECHO.
ECHO
Press any key to exit...
PAUSE >NUL