Nikon's new D7000

Nikon announced their new D90 replacement, the D7000 today. It looks like an awesome camera, with a 17.2 MP sensor, two SD card slots, a 39 point AF system, a more rugged magnesium-alloy body, and improved video capabilities. Rather than the D90’s 5 minutes of 720p video with manual focus only, the D7000 can record a full 20 minutes of 1020p video using autofocus. I’m not ready to replace my D90 yet, but when I do, the D7000 seems like a nice step up.

Nginx update

After running Nginx for a day everything seems stable. The memory usage is much lower – I was able to reduce my PS from 458M to 304M. The sites seem faster & more responsive, and memory usage remains pretty much constant rather than fluctuating based on the number of connections, as it did with Apache.

Screen shot 2010-01-29 at 9.18.15 PM.png

Using Nginx at DreamHost

All of my sites are now running Nginx rather than Apache, which has several major advantages. Apache uses a separate process for each connection, so if you have a very busy site with lots of simultaneous connections it can use a huge amount of memory. Nginx, on the other hand, uses one worker process with a fixed number of CGI processes no matter how many connections it’s serving.

As you can see from my resource chart, the memory usage dropped dramatically when I switched over to Nginx.

Screen shot 2010-01-28 at 7.31.50 PM.png

Nginx has a few drawbacks, however. It doesn’t support Subversion or WebDAV, so I first had to move my Subversion repositories off my virtual private server. I ended up moving them to ProjectLocker. Most importantly, Nginx doesn’t use a .htaccess file. Instead, it uses its own configuration files, which DreamHost documents here.

Basically you need to create a nginx folder in your home directory, and make a subdirectory for each domain, for example ~/nginx/mcdevzone.com, and create a configuration file, which can be named anything. The syntax is different than .htaccess, although it has many of the same capabilities such as access control or rewriting URLs.

For a WordPress site, all you need is this:

#######################
# Permalinks

if (!-e $request_filename) {
  rewrite ^.*$ /index.php last;
}

DreamHost provides many more examples on their Wiki page, and you can find even more at the official Nginx site.

One important rule you should add to your config file, which DreamHost leaves out, is this one which will prevent users from viewing your .htaccess file, if you still have one.

location ~ /\.ht {
    deny  all;
}

I ran into a few gotchas, but once I figured them out I was able to get everything running smoothly. According to DreamHost’s documentation, the site-wide Nginx configuration file is at /dh/nginx/servers/httpd-psXXXXXX/nginx.conf, but I found that it didn’t exist, at least on my server. Instead it was named nginx.conf.pushing, so as a result Nginx refused to start. Once I renamed it, I was able to start nginx. You WILL need to have an admin user on your private server in order to access that file and restart nginx.

UPDATE: The problem I ran into with the missing config file was because the update didn’t finish properly for some reason.

DreamHost’s older virtual private servers don’t support Nginx, so if you want to use it, you may have to request to have your PS moved to a newer system.

If you have a very busy site, Nginx can help you deal with the load, so it’s worth checking out. Several major sites including WordPress.com, Hulu, and Github are using Nginx, so it’s definitely production quality.