comment 0

What Problems to Solve

You say you are a nameless man. You are not to your wife and to your child. You will not long remain so to your immediate colleagues if you can answer their simple questions when they come into your office. You are not nameless to me. Do not remain nameless to yourself – it is too sad a way to be. Know your place in the world and evaluate yourself fairly, not in terms of your naïve ideals of your own youth, nor in terms of what you erroneously imagine your teacher’s ideals are.

comment 0

Which .conf file(s) is Apache using?

I spent the majority of this week debugging some Apache ModRewrite rules. (Yes, today is Wednesday.) It shouldn’t have taken so long. The rules themselves weren’t complex, but the server environment is.

Our production web site consists of a load balancer, Memcached server, two synchronized app servers, and two synchronized static file servers. There are obsolete, broken, and duplicate Apache config files distributed in various directories across the app and static servers. Many of the config files recursively included directories full of other config files. By trial-and-error, I sifted through them all, adding debug statements and restarting httpd, over and over and over. Nothing worked; Apache ignored every file I touched.

As usual, it turns out there’s an easier way to discover exactly which .conf files Apache is using.

First, get some data about your running Apache process:

$ ps ax | grep httpd
21765 ?        Ss     0:00 /usr/sbin/httpd -f /var/www/conf/example.com.conf -E /var/www/logs/example.com-20140514-startup.log

This is valuable information, because now that we know the exact binary and config file Apache is running with, we can use the -S option to show VirtualHost settings:

$ /usr/sbin/httpd -f /var/www/conf/example.com.conf -S
VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server www.example.com (/var/www/conf/virtual/example.com/www.example.com.conf:1)
         port 80 namevhost www.example.com (/var/www/conf/virtual/example.com/www.example.com.conf:1)
         port 80 namevhost www2.example.com (/var/www/conf/virtual/example.com/www2.example.com.conf:1)
...

From the output above, we see that www.example.com’s VirtualHost is defined in /var/www/conf/virtual/example.com/www.example.com.conf.

That’s all there is to it — no guesswork necessary.

comment 0

WordPress multisite proxy configuration

I’ve been using WordPress multisite for a few projects at work lately, and it’s been great — mostly. Unfortunately, because of its reliance on ModRewrite, anything beyond the most basic configuration can be complicated.

In this case, I needed to install a multisite network in a subfolder, served from behind a load-balancing proxy. WordPress multisite is very particular about hostnames, so it detects that the proxy server hostnames (proxy1.mysite.com and proxy2.mysite.com) don’t match the site hostname (www.mysite.com), and degrades to an infinite redirect loop.

The solution below comes after days of research, testing, and tearing out my hair. Of course, all environments are different, so your mileage will probably vary.

The solution (well, maybe)

After enabling your multisite network, WordPress provides the following code snippets (which we’ll modify in just a moment):

# wp-config.php

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'www.mysite.com');
define('PATH_CURRENT_SITE', '/subfolder/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
# .htaccess

RewriteEngine On
RewriteBase /subfolder/
RewriteRule ^index.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]
RewriteRule . index.php [L]

Now let’s make some additions. New lines are bold:

# wp-config.php

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
$base = '/subfolder/';
define('DOMAIN_CURRENT_SITE', 'www.mysite.com');
define('PATH_CURRENT_SITE', '/subfolder/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

if ( isset( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) {
  $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}
# .htaccess

RewriteEngine On
RewriteBase /subfolder/
RewriteRule ^index.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{HTTP:X-Forwarded-Host} !^$
RewriteCond %{HTTP:X-Forwarded-Host} !^www. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.mysite.com%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]
RewriteRule . index.php [L]

And that’s it. This combination of rules delicately nudges your URLs into a format that WordPress and Apache won’t choke on.

comment 0

Melissa Godowski, a rock climber whose blog I’ve enjoyed following for years, just posted her Top 31 Things I Have Learned in 365 Days. It’s a great list, and applies equally to climbing and life. I have a few favorites, which seem especially applicable to my life at the moment:

  • Slow and steady wins the race. Go at your own pace, not someone else’s.
  • The present will dictate the future. Be in the moment and make smart decisions.
  • There is no such thing as normal. Even if there was, individuality is too special to give up.
  • It is important to have variety. Have a variety in activities and interests just like you would have a variety of vegetable colors.
  • Get to know yourself. Learn your patters, likes, and dislikes. Become aware of your emotions. Work together with you body. Having this knowledge about yourself will help you reach your goals faster.
comment 0

Relationships are everything. Getting what we want, having things our way, having control, being right … these things matter nothing compared to relationships. Imagine being in your death bed at the age of 80 … will your sense of being right and in control comfort you when you have no good relationships, no one who has loved you?

comment 0

I think as experienced game developers / engineers / artists / makers, we don’t realize how we’ve developed strong senses of “vision” — the ability to visualize and maintain this thing in our head, and gradually work to realize that thing into existence despite countless obstacles. Frequent failure is expected! But this kind of emotional intelligence, to be patient with yourself and your work, takes time to cultivate. People have trouble grasping this if they are new to making things, and maybe it’s our mission to help them own their constant failures.

comment 0

Talk to someone who rejects the conclusions of climate science and you’ll likely hear some variation of the following: “That’s all based on models, and you can make a model say anything you want.” Often, they’ll suggest the models don’t even have a solid foundation of data to work with—garbage in, garbage out, as the old programming adage goes. But how many of us (anywhere on the opinion spectrum) really know enough about what goes into a climate model to judge what comes out?

One of the major problems with political discourse in America is that everyone thinks they have the answer, but very few have the knowledge to back up their answer.

comment 0

Theme Details

Like many designers and developers these days, I set up a lot of blogs and web sites, often without enough time or budget to design a custom theme. In these cases, installing a free or cheap off-the-shelf theme is usually the best option.

And there are hundreds of beautiful themes available. Browsing Themeforest seems, at first, like an embarrassment of riches. But each time I mine the theme directories, flagging my favorites,  I notice a problem: the details are off.

Out of every 10 themes with impressive and beautiful splash pages, it seems that 9 have fatal flaws which disqualify them from my search (often discovered only after purchasing and installing). Most are minor issues: a misaligned search box, a sidebar that deviates from the baseline grid, a lazily-chosen secondary typeface, unstyled page number indicators, and so on. But such minor issues often break the design’s gestalt, and prevent so many good themes from being truly excellent.

Of course, it’s likely that my graphic design background has hyper-sensitized me to some of these flaws, but design principles exist whether we consciously acknowledge them or not. A designer may recognize that your theme’s H2 tags have awkward margins; a non-designer will simply move on to a theme that feels “right”.

comment 0

On Contributing

The other day, my good friend Brad asked a question on Stack Overflow regarding LESS and Bootstrap 3. Sensing an opportunity for some easy reputation points, I hopped on and posted a quick solution.

Except, it didn’t work. Neither did my next solution, or the next, or the next. I’m familiar enough with Bootstrap, and with LESS, to know my solutions should have worked. But they didn’t. So I dug in, forked the repo, and built a test case.

It turned out that Bootstrap didn’t support the functionality that Brad was trying to use. The docs weren’t even totally clear on whether it should. So after explaining the problem, and workaround, on Stack Overflow, I thought: why not submit the “fix” back as a pull request? So I did, and to my surprise, it was accepted and rolled into Bootstrap 3 RC2.

For you veteran Githubbers, my experience is nothing special. In fact, I’ve submitted plenty of pull requests myself. But this was my first to a major open-source project, so it still feels shiny and cool to me.

More importantly, though, it’s a valuable reminder: just because a project is large and popular, it not necessarily free of issues. Don’t assume that other developers are smarter than you, or that you have nothing valuable to contribute. You probably do! But you’ll never know unless you get your hands dirty.