Joel On Software
The Old New Thing
The Daily WTF
AI Game Dev
Digital Gunfire Radio
You are visitor #
Javier Arévalo Baeza
|nginx 1.0 (Jare)||April 16th, 2011 - 01:56|
|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 127.0.0.1:9000. 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://127.0.0.1/, 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!