Installing nginx + php in Windows

I recently found a light-weight web server called nginx and want to give it a try. Installing nginx in Windows 7 was simple, just put the content of the zip into a directory and run the nginx.exe file.  My main purpose of installing the server is try to test out some PHP programs, and installing php was a bit more complicated.  Luckily, I found a web page talking exactly what I was looking for.

The following is my procedure:

I installed nginx in c:\WinApps\nginx and php in c:\WinApps\php

Go to  c:\WinApps\nginx\conf and uncomment or modify the following lines in nginx.conf.

 location ~ .php$ {
  root html;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME  c:/WinApps/nginx/html/$fastcgi_script_name;
  include fastcgi_params;

Then, create a batch file start-nginx.bat as follows:

start /b c:\WinApps\nginx\nginx.exe
start /b c:\WinApps\php\php-cgi.exe -b -c c:\WinApps\php\php.ini
ping -n 1>NUL
echo Starting nginx
echo .
echo .
echo .
ping >NUL

and stop-nginx.bat as follows:

taskkill /f /IM nginx.exe
taskkill /f /IM php-cgi.exe



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s