Easy nginx with Drupal
If you are impatient, the code is at nginx_drupal. If you want to know what it’s about - read on.
I recently needed to set up a consistent web server configuration for a Drupal web site. That site has 6 web servers and 3 images servers. The goal was to have a single nginx configuration file, with as little duplication as possible. The images servers are meant for the static content, and for imagecache only.
Although the servers are different (some are meant for generic web, some are meant just as images servers) I wanted to have a generic config, that will give maximum flexibility to the administrator. Such a config file can reside in a single location on the internal network, and be accessible from all servers through NFS.
Using option groups with acts_as_tree
When you have a model that acts_as_tree, you might want to use that to generate a nice select element with option groups.
In your view, simply use:
<%= f.select (:category_id, option_groups_from_collection_for_select(
Category.top,
:children, :name,
:id, :name
)) %>
and add a method to your model:
def self.top
find(:all, :conditions => [ 'parent_id IS NULL' ])
end
This generates HTML like this:
<select id="product_category_id" name="product[category_id]">
<optgroup lab
Simple outgoing mail server on Archlinux
It is very common to need an outgoing mail capabilities. If you are using a VPS for your web site, or just you want outgoing mails on your home machine to work natively. Automatic messages from cron, UPS management, or even your blog about new comments are too important to lose.
I am using ArchLinux, but this guide is probably good for other distributions as well. I could not find a simple and concise guide for setting this up - this post is aimed to fill that gap.
First let’s install Postfix (why postfix?
