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 :)
- Install cygwin
- path=c:\cygwin
- packages
- devel (make,autoconf,etc)
- nano (an editor…)
- 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
- 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
- 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" ' '"$gzip_ratio"'; 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 { listen 127.0.0.1:80; 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_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME c:/cygwin/home/norr/www/html$fastcgi_script_name; include /etc/nginx/fastcgi_params; } } }
- nano /etc/nginx/nginx.conf
- Start nginx in the cygwin window
- nginx
- You should be able to go to http://localhost/ now
- 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)
- 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”
- Create a shortcut to php-cgi
- open the shortcut properties
- add “-b 127.0.0.1:9000 -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 127.0.0.1
- 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 :)