effective life plus

Binzy's blog

nginx + Zend Framework @ Windows

| Filed under Programming

If you feel pretty boring with Apache, just like me, so having a try of nginx might be good idea. Although at most of my time, I’m using Windows, fortunately, nginx has native Windows build. So my steps might be helpful to you to try nginx on Windows, especially Windows 7.

1. Download nginx and php and install

2. Configure nginx and php

  • PHP, no specific configuration, just do what you like to php.ini.
  • Nginx
    Fast-CGI of php
    You can find sample from wiki.nginx.org, http://wiki.nginx.org/PHPFastCGIOnWindows, below works for me.
    location ~ \.php$ {
                fastcgi_pass   127.0.0.1:9999;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  D:/www/public/$fastcgi_script_name;
                include        fastcgi_params;
            }

    Configure for Zend Framework
    -f and !-f are used for checking whether file exists.
            error_page 404 /index.php;
    
            if (!-f $request_filename) {
                rewrite ^.*$ /index.php last;
                break;
            }

3. batch script to start and stop nginx + php-cgi

I’m using RunHiddenConsole to hide the prompt window and actually you also can use vbs to run nginx.

start-nginx.bat

@ECHO OFF
ECHO Starting PHP FastCGI...
C:\nginx\RunHiddenConsole.exe C:\PHP5\php-cgi.exe -b 127.0.0.1:9999
ECHO Starting nginx...
C:\nginx\RunHiddenConsole.exe c:\nginx\nginx.exe

stop-nginx.bat
@ECHO OFF
ECHO Stopping nginx...
taskkill /F /IM nginx.exe
ECHO Stopping php-cgi...
taskkill /F /IM php-cgi.exe

but php-pfm doesn’t work on Windows unless you are using cygwin.

nginx_zend

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>