nginx 1.0

Since I started working on Pyro’s server backend for its social games, I have grown to love the nginx web server. Compact, efficient and fully featured, it’s a great alternative to Apache if you are in full control of your web server and apps.

A few days ago nginx came of age with the release of 1.0, so I did a refresh of my simple web dev setup at home:

– Download nginx 1.0 Windows binary here
– Download thread-safe php Windows binary here
– Unzip them to their own folders
– Copy php.ini-development to php.ini. Edit php.ini and uncomment the lines containing extension=php_mysql.dll and extension_dir = "ext".
– Start php by running php-cgi.exe -b You can later stop it with Ctrl-C, taskkill /IM php-cgi.exe or with your favourite process killing method.
– Make the following edits to conf\nginx.conf:
– If you are running Vista or later with IPv6, change the line listen 80 to listen [::]:80. This makes nginx listen on both IPv4 and IPv6. Even if you are not doing any work related to IPv6, your Windows hosts file will probably contain the IPv6 loopback entry for localhost (::1), and your browsers will try to use that IPv6 address for localhost. Enabling IPv6 in nginx lets you use all three loopbacks (, http://[::1]/ and http://localhost/) intercheangeably and without problems.
– Uncomment the block lines starting with location ~ \.php$ to enable php scripts.
– Change the fastcgi_param line to eliminate the hardcoded "scripts" folder path. It should be fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;.
– Add index.php to the index line so it looks like index index.html index.htm index.php;
– Remove all the root html; lines and leave a single root d:\dev\mywebdevfolder line at the server scope. I usually put it just below the server_name localhost; line.
– Start nginx by running nginx.exe or, since it can’t be killed with Ctrl-C, start nginx.exe.
– use the command-line signals to control nginx: nginx -s quit to stop it, nginx -s reload to reload the configuration.

That should be it, nginx+php in 5 minutes or less!

This entry was posted in Uncategorized by Jare. Bookmark the permalink.

2 thoughts on “nginx 1.0

  1. Do you know Node ? I think you would like it for server apps.
    It’s the Google’s Javascript engine written in C++ for unix/win and running on server side.
    It’s faster than Apache and simply to use. It supports i/o async low level access for streaming, chat apps, it’s la caƱa!

Comments are closed.