[SOLVED] nginx + php (fastcgi) + win32 = “No input file specified”

You’ve probably found this post while searching for nginx and php (fastcgi with php-cgi) for windows. I ran into the “No input file specified.” problem and finally figured it out. The key is we are running on windows and not unix/linux. Windows paths are not /home/user/dir they are c:\cygwin\home\user\dir.

Keep reading for a complete How To nginx + php-cgi on windows :)

  1. Install cygwin
    • path=c:\cygwin
    • packages
      • devel (make,autoconf,etc)
      • nano (an editor…)
  2. Download nginx source
    • I used – nginx-0.7.22
    • start cygwin shell
    • cd (make sure in home dir)
    • wget http://sysoev.ru/nginx/nginx-0.7.22.tar.gz
    • tar -zxf nginx-0.7.22.tar.gz
  3. Compile nginx
    • cd nginx-0.7.22
    • ./configure –conf-path=/etc/nginx/nginx.conf –sbin-path=/bin/ –pid-path=/var/run/nginx.pid
      (there are other options, these just put things where I’m used to them being – gentoo)
    • make
    • make install
  4. Configure nginx
    • nano /etc/nginx/nginx.conf
      worker_processes 1;
      error_log /home/znd-norr/www/log/error_log info;
      events {
        worker_connections  64;
      http {
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
        log_format main
          '$remote_addr - $remote_user [$time_local] '
                '"$request" $status $bytes_sent '
          '"$http_referer" "$http_user_agent" '
        client_header_timeout 10m;
        client_body_timeout   10m;
        send_timeout          10m;
        connection_pool_size          256;
        client_header_buffer_size     1k;
        large_client_header_buffers   4 2k;
        request_pool_size             4k;
        gzip off;
        output_buffers  1 32k;
        postpone_output  1460;
        sendfile  on;
        tcp_nopush  on;
        tcp_nodelay  on;
        keepalive_timeout  75 20;
        ignore_invalid_headers  on;
        index index.php index.html;
        server {
          server_name  localhost;
          access_log /home/norr/www/log/localhost.access_log main;
          error_log   /home/norr/www/log/localhost.error_log info;
          root /home/norr/www/html;
          client_max_body_size 4m;
          location ~ \.php$ {
            fastcgi_param  SCRIPT_FILENAME  c:/cygwin/home/norr/www/html$fastcgi_script_name;
            include        /etc/nginx/fastcgi_params;
  5. Start nginx in the cygwin window
    • nginx
    • You should be able to go to http://localhost/ now
  6. Create a test php file
    • echo “<?php phpinfo() ?>” > /home/norr/www/html/info.php
    • now goto http://localhost/info.php – should get bad gateway (we haven’t setup php yet)
  7. Install PHP
    • I used – PHP 5.2.6 installer http://www.php.net/downloads.php
    • installed to “G:\Programs\PHP” – no spaces in path seems to be a good idea with things
    • selected the mysql extenseion
    • configured as “other cgi server”
  8. Create a shortcut to php-cgi
    • open the shortcut properties
    • add “-b -c php.ini” to the target – this will use the php.ini file in G:\Programs\php.ini
    • make sure the start in is set to “G:\Programs\PHP” (directory you installed to)
    • click the shortcut php-cgi should start and be listening on post 9000 on ip
  9. Refresh browser as http://localhost/info.php should load

I’ve done the above from memory so there might be some errors – leave a comment and I’ll amend :)

  • http://www.kehalim.com/ Kehalim

    Great post, though with the time that passed you can skip cygwin and compilation in favor of a windows binary (see http://wiki.nginx.org/NginxInstall).

  • balinder

    Has anyone been able to get windows binary of ngnix working in a production environment?

  • http://www.facebook.com/weijing.lin Weijing Lin

    you don't need install cygwin. No input file specified issue could be solved by edit php.ini file