Nginx and subdomains on Engine Yard

System administration and setup are my least favorite part of any project. Today I wanted to set up a wiki on a subdomain – The main site, a blog, is hosted on an Engine Yard slice that runs nginx. Since I’m usually more of an apache aficionado, I thought I’d note the process.

  1. Request the subdomain setup from Engine Yard, telling them which slice (staging, production, etc.) to point at. They need to add DNS records pointing at the appropriate IP.
  2. Add a new directory under /data containing wiki software – MediaWiki in this case.
  3. Create a new configuration file under /data/nginx/servers. Anything in this directory with a .conf extension gets picked up in a restart. It should look pretty similar to the one from the application you’re already running, though perhaps with different root and logfile locations. I found a blog post with several sample conf files which was helpful.
  4. Restart nginx using sudo /etc/init.d/nginx restart. It will tell you if there’s something wrong with your config.

And that’s it! I still need to spend some time with the syntax of the config files, particularly nginx’s version of rewrite rules. I couldn’t find any useful references online (at least, not in English), but I got a lot out of reading the code of Chris Wanstrath’s nginx_config_generator gem.

Comments are closed.