<?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/"
	>

<channel>
	<title>Molindo Techblog &#187; Wordpress</title>
	<atom:link href="http://techblog.molindo.at/tag/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://techblog.molindo.at</link>
	<description>Molindo Techblog – formerly known as talk-on-tech.blogspot.com</description>
	<lastBuildDate>Tue, 20 Dec 2011 10:22:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Virtual WordPress Hosts Made Easy (obsolete)</title>
		<link>http://techblog.molindo.at/2008/12/virtual-wordpress-hosts-made-easy.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=virtual-wordpress-hosts-made-easy</link>
		<comments>http://techblog.molindo.at/2008/12/virtual-wordpress-hosts-made-easy.html#comments</comments>
		<pubDate>Mon, 15 Dec 2008 21:16:00 +0000</pubDate>
		<dc:creator>Stefan Fußenegger</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[apache]]></category>

		<guid isPermaLink="false">http://tech.molindo.at/2008/12/virtual-wordpress-hosts-made-easy.html</guid>
		<description><![CDATA[Currently, we are planing to consolidate all our blogs that we (quite carelessly) created all over the internet. At the moment, we have three blogs hosted on Blogger (1, 2, 3) two blogs running on their own WordPress (1, 2) three private blogs running on Blogger and Serendipity and one or two new ones to [...]]]></description>
			<content:encoded><![CDATA[<p>Currently, <a href="http://www.molindo.at/">we</a> are planing to consolidate all our blogs that we (quite carelessly) created all over the internet. At the moment, we have</p>
<ul>
<li>three blogs hosted on Blogger (<a href="http://blog.songtexte.com/">1</a>, <a href="http://blog.setlist.fm/">2</a>, <a href="http://talk-on-tech.blogspot.com/">3</a>)</li>
<li>two blogs running on their own <a href="http://www.wordpress.org/">WordPress</a> (<a href="http://www.internetszene.com/">1</a>, <a href="http://www.internetszene.at/">2</a>)</li>
<li>three private blogs running on Blogger and <a href="http://www.s9y.org/">Serendipity</a></li>
<li>and one or two new ones to come</li>
</ul>
<p>All in all, there&#8217;s quite a bit of blogging going on <img src='http://techblog.molindo.at/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Yesterday, I was looking into solutions on how to host all those blogs on a single installation of WordPress.<br />
<span id="more-32"></span><br />
The first thing I stumbled upon was <a href="http://mu.wordpress.org/">WordPress MU</a>. However, I didn&#8217;t have a good feeling about it. I wasn&#8217;t sure about compatibility of plugins, themes or tutorials and the like. Well, just the normal problems you have if you do things differently than everybody else.</p>
<p>Still I like doing things differently <img src='http://techblog.molindo.at/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  That&#8217;s why I started playing around with an <a href="http://www.domainsmalltalk.com/2008/09/21/wordpress-multidomain-faehig/">idea suggested by Richard Martin (german only)</a>. He suggested to use <a href="http://at.php.net/manual/en/reserved.variables.server.php">$_SERVER['HTTP_HOST']</a> inside <a href="http://codex.wordpress.org/Editing_wp-config.php">wp-config.php</a> in order to get a <a href="http://codex.wordpress.org/Editing_wp-config.php#table_prefix">unique $table_prefix</a> for each <a href="http://httpd.apache.org/docs/2.2/en/vhosts/">virtual host</a>. While I liked the idea to dynamically create the prefix, I didn&#8217;t like that the wp-config.php file would become useless outside a web request (what about cron jobs?). So I came up with the following snippet of code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$table_prefix</span> <span style="color: #339933;">=</span> <span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WORDPRESS_PREFIX'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$table_prefix</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$table_prefix</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;wp_&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">define</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WPLANG'</span><span style="color: #339933;">,</span> <span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WORDPRESS_LANG'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now, it&#8217;s easy to change the prefix (and language) with an environment variable. In order to use this with Apache Httpd do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
&nbsp;
<span style="color: #00007f;">ServerName</span> foo.example.com
<span style="color: #adadad; font-style: italic;">#ServerAlias www.foo.example.com, oldfoo.example.com</span>
&nbsp;
<span style="color: #00007f;">ServerAdmin</span> admin@example.com
&nbsp;
<span style="color: #00007f;">DocumentRoot</span> /path/to/wordpress
&nbsp;
<span style="color: #00007f;">CustomLog</span> <span style="color: #7f007f;">&quot;| /usr/bin/cronolog /var/log/wordpress/foo/%Y-%m-access.log&quot;</span> common
&nbsp;
<span style="color: #00007f;">DirectoryIndex</span> index.php
&nbsp;
<span style="color: #adadad; font-style: italic;"># Wordpress Config</span>
<span style="color: #00007f;">SetEnv</span> WORDPRESS_PREFIX foo_
<span style="color: #00007f;">SetEnv</span> WORDPRESS_LANG de_DE
&nbsp;
&lt;<span style="color: #000000; font-weight:bold;">Location</span> /&gt;
<span style="color: #00007f;">Order</span> <span style="color: #00007f;">Deny</span>,<span style="color: #00007f;">Allow</span>
<span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span>
&nbsp;
<span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">All</span>
&lt;/<span style="color: #000000; font-weight:bold;">Location</span>&gt;
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></div></div>

<p>It might still take a little fine tuning, but it&#8217;s working perfectly so far. Only a single WordPress installation to maintain, a single plugin and theme repository for all blogs and a single database to backup. Quite cool if you&#8217;re the only admin of all blogs. It might also be cool to write a WordPress plugin to create virtual WordPress hosts from the admin console &#8211; I leave this up as an exercise to the reader though <img src='http://techblog.molindo.at/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>The only thing to worry about is that some plugins write to the file system directly (e.g. <a href="http://wordpress.org/extend/plugins/google-sitemap-generator/">Google XML Sitemaps</a>). Those will conflict with each other as all blogs share the same directory on the file system.</p>
<p>PS: This might have been the last post on blogger. Which means that it might have been the last time, you&#8217;ve had the pleasure to enjoy the lovely green of this blog <img src='http://techblog.molindo.at/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>EDIT: This article is obsolete since WP3 now supports multiple bloge, i.e. a network of blogs. See <a href="http://codex.wordpress.org/Create_A_Network">Create A Network</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.molindo.at/2008/12/virtual-wordpress-hosts-made-easy.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

