<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>

<channel>
	<title>Will Norris &#187; buddypress</title>
	<atom:link href="http://willnorris.com/tag/buddypress/feed" rel="self" type="application/rss+xml" />
	<link>http://willnorris.com</link>
	<description>Thoughts on Identity, OpenID, WordPress, and Life</description>
	<lastBuildDate>Tue, 26 Jan 2010 16:25:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
		<item>
		<title>WordPress MU in a development environment</title>
		<link>http://willnorris.com/2008/09/wordpress-mu-in-a-development-environment</link>
		<comments>http://willnorris.com/2008/09/wordpress-mu-in-a-development-environment#comments</comments>
		<pubDate>Fri, 19 Sep 2008 05:44:44 +0000</pubDate>
		<dc:creator>Will Norris</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[buddypress]]></category>
		<category><![CDATA[localhosting]]></category>
		<category><![CDATA[mu]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wpmu]]></category>

		<guid isPermaLink="false">http://willnorris.com/?p=311</guid>
		<description><![CDATA[Most of the development I do for my job is within WordPress, so I have quite a few WordPress instances running on my local workstation. I&#8217;ve been using the same custom Apache setup for three years, and have been developing on WordPress for almost as long, so I&#8217;ve been a bit bewildered with the amount [...]

<div class="related-posts">
Possibly related posts:<ul><li><a href='http://willnorris.com/2005/05/dev_environment' rel='bookmark' title='Permanent Link: Setting up a web development environment'>Setting up a web development environment</a></li>
<li><a href='http://willnorris.com/2007/12/wordpress-plugins-development-version' rel='bookmark' title='Permanent Link: WordPress plugins - development version'>WordPress plugins - development version</a></li>
<li><a href='http://willnorris.com/2005/03/bashrc' rel='bookmark' title='Permanent Link: ~/.bashrc'>~/.bashrc</a></li>
</ul></div>]]></description>
			<content:encoded><![CDATA[<p>Most of the development I do for my job is within WordPress, so I have quite a few WordPress instances running on my local workstation.  I&#8217;ve been using the same <a href="http://willnorris.com/2005/05/dev_environment">custom Apache setup</a> for three years, and have been developing on WordPress for almost as long, so I&#8217;ve been a bit bewildered with the amount of trouble I&#8217;ve had the several times I&#8217;ve attempted to get <a href="http://mu.wordpress.org/">WordPress MU</a> running on my laptop.  I identified a couple of specific problems and solutions, which I wanted to outline here.</p>

<p><span id="more-311"></span></p>

<h3>Choosing the right hostname</h3>

<p>Part of my custom setup is that I have a whole slew of bogus hostnames pointing to localhost, which Apache then dynamically maps to the correct document root.  For the most part, I just drop the TLD from the actual hostname&#8230; so <em>http://willnorris/</em> is my locally hosted development site for this blog <em>http://willnorris.com/</em>, and <em>http://will.norris/</em> is my development site for <em>http://will.norris.name/</em>.  I also keep a handful of WordPress versions running locally, so I can test plugins in those different environments &#8212; <em>http://wordpress-2.3/</em>, <em>http://wordpress-2.5/</em>, etc.  When I began to setup my WordPress MU (and <a href="http://buddypress.org/">BuddyPress</a>) instance, I used the site <em>http://wpmu/</em>.  The installation went fine, but when I tried to login it failed every time.  Given that this same setup worked fine with single-user WordPress, I was quite confused.  I quickly realized though, that the authentication cookies were never being set for WPMU&#8230; in fact no cookies were.</p>

<p>The difference between the two versions of WordPress is the value of <code>COOKIE_DOMAIN</code> which is passed to <a href="http://php.net/setcookie">setcookie()</a>.  Both flavors of WordPress allow you to define this constant in <code>wp-config.php</code>, but they differ in what happens if it is not defined there.  WordPress sets it to the boolean false, whereas WordPress MU sets it to <code>'.'.$current_site-&gt;domain</code>.  This results in a different <code>Set-Cookie</code> HTTP header between the two.  Take for example the <code>wordpress_test_cookie</code> cookie.  WordPress sends the response header</p>

<pre><code>Set-Cookie: wordpress_test_cookie=WP+Cookie+check; path=/
</code></pre>

<p>whereas WordPress MU sends the response header</p>

<pre><code>Set-Cookie: wordpress_test_cookie=WP+Cookie+check; path=/; domain=.wpmu
</code></pre>

<p>The difference of course is the <code>domain=.wpmu</code> there on the end.  In a production environment, this wouldn&#8217;t make a bit of difference.  But because I&#8217;m using fake hostnames in a development environment, this makes all the difference in the world.  You see, the <a href="http://www.ietf.org/rfc/rfc2109.txt">HTTP Cookie Spec</a> (Section 4.3.2 Rejecting Cookies) requires that the domain attribute includes an &#8220;embedded dot&#8221;.  This is a security feature that prevents a site from setting a cookie on a top level domain like &#8220;.com&#8221;.  Since single-user WordPress wasn&#8217;t specifying a domain attribute, it didn&#8217;t have any problem setting the cookie.  Because my hostname <em>wpmu</em> doesn&#8217;t contain an embedded dot, the browser was properly rejecting the cookies, preventing me from being able to login.  So our solution here was to use the site <em>http://wp.mu/</em> (note the added dot in the middle) for hosting our WordPress MU development site.</p>

<h3>Sending Mail</h3>

<p>The other main problem I had with WordPress MU was that none of the notification emails were being delivered.  This was actually a problem with single-user WordPress as well, but it didn&#8217;t matter as much then.  Now I&#8217;m needing to test the account sign-up process a bit more, and so I need the activation emails that are being sent out.  It&#8217;s been a long time since I&#8217;ve administered an email server, so I won&#8217;t embarrass myself by trying to explain what the problem was (something along the lines of my ISP&#8217;s SMTP server not liking what <a href="http://php.net/mail">mail()</a> was sending) .  I was however able to fix it by writing a very simple plugin, <a href="http://willnorris.com/svn/will.norris.name/trunk/public/wordpress-content/plugins/development-mailer.php">Development Mailer</a>, that changes a few configuration options of PHPMailer.  This works for me on Mac OS X (Leopard), but I make no guarantees for anyone else.  Keep in mind that his plugin should only ever be needed for a development environment&#8230; if you&#8217;re unable to send notification emails from your production blog, then you&#8217;ve got other problems.</p>


<div class="related-posts"><p>Possibly related posts:</p><ul><li><a href='http://willnorris.com/2005/05/dev_environment' rel='bookmark' title='Permanent Link: Setting up a web development environment'>Setting up a web development environment</a></li>
<li><a href='http://willnorris.com/2007/12/wordpress-plugins-development-version' rel='bookmark' title='Permanent Link: WordPress plugins - development version'>WordPress plugins - development version</a></li>
<li><a href='http://willnorris.com/2005/03/bashrc' rel='bookmark' title='Permanent Link: ~/.bashrc'>~/.bashrc</a></li>
</ul></div>]]></content:encoded>
			<wfw:commentRss>http://willnorris.com/2008/09/wordpress-mu-in-a-development-environment/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
	</channel>
</rss>
