<?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>Martian Thoughts on Design &#187; Planet Drupal</title>
	<atom:link href="http://blogs.martiangraphix.com/tag/planet-drupal/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.martiangraphix.com</link>
	<description>Design, Web Development, and Interesting Technology</description>
	<lastBuildDate>Wed, 11 May 2011 03:32:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Updating Drupal Multi-Site on OS X</title>
		<link>http://blogs.martiangraphix.com/2010/03/updating-drupal-multisite-on-os-x/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=updating-drupal-multisite-on-os-x</link>
		<comments>http://blogs.martiangraphix.com/2010/03/updating-drupal-multisite-on-os-x/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 21:06:21 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Multi-Site]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Planet Drupal]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Update]]></category>

		<guid isPermaLink="false">http://blogs.martiangraphix.com/?p=189</guid>
		<description><![CDATA[We&#8217;re continuing on with the tutorials for the Drupal Multi-Site configuration that I set up on my Mac. All the domain and directory structure is based on that tutorial, so if you&#8217;ve done something slightly different, you&#8217;ll need to adjust as appropriate. Were following the basic procedure laid out in the UPGRADE.txt in your Drupal [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re continuing on with the tutorials for the <a href="http://blogs.martiangraphix.com/2009/09/building-a-drupal-development-environment-for-mac/">Drupal Multi-Site configuration</a> that I set up on my Mac.  All the domain and directory structure is based on that tutorial, so if you&#8217;ve done something slightly different, you&#8217;ll need to adjust as appropriate.</p>
<p><span id="more-189"></span>Were following the basic procedure laid out in the UPGRADE.txt in your Drupal core installation, so if you run into any problems you can get some additional tips there. </p>
<p>I&#8217;m writing a special tutorial on this because, when we set up our installation in the <a href="http://blogs.martiangraphix.com/2009/09/building-a-drupal-development-environment-for-mac/">Building A Drupal Development Environment page</a>, I set up some permissions on the <em>sites/</em> directory.  These permissions made it easier for us to access the files, but we&#8217;ll need to tweak a few things in the upgrade procedure to preserve these permissions.</p>
<p>So, in this tutorial, I&#8217;m going to show you step by step how to easily accomplish the upgrade.  </p>
<h2>Step 1: Log into your Drupal site as the administrative user</h2>
<p>Hopefully this is pretty self explanatory.</p>
<h2>Step 2: Set the site into maintenance mode</h2>
<p>Now, you&#8217;ll navigate to the <strong>Site maintenance</strong> page for the site, using the navigation links: <strong>Administer > Site configuration > Site maintenance</strong></p>
<h2>Step 3: Switch to one of the default themes</h2>
<p>If you&#8217;ve installed a custom theme, you&#8217;ll need to switch out to one of the ones that came with Drupal.  I&#8217;ll use Garland.</p>
<p>You get there by navigating to: <strong>Administer > Site building > Themes</strong>.</p>
<p>Make sure that Garland is <strong>Enabled</strong>, and that it is selected as the <strong>Default</strong>.  Save the configuration.</p>
<h2>Step 4: Disable any added modules</h2>
<p>We need to disable any modules that we&#8217;ve installed, which were not part of the Drupal Core.  Navigate to the modules page: <strong>Administer > Site building > Modules</strong></p>
<p>You do NOT need to disable anything in <strong>Core &#8211; required</strong> or <strong>Core &#8211; optional</strong>, but disable anything you see in the other section.  You can do this by unchecking the box in front of the module.  As you go through this, you&#8217;ll want to make a list of which modules you&#8217;re disabling, so you can turn these back on when we&#8217;re done.</p>
<p>When you&#8217;ve unchecked the modules, select <strong>Save configuration</strong> at the bottom of the list when done.</p>
<p>You may need to go through this several times to make sure all the modules are turned off, because some modules are required by others, and can&#8217;t be unchecked the first time through.  </p>
<h2>Step 5: Repeat Steps 1-4</h2>
<p>You&#8217;ll need to perform <strong>Steps 1-4</strong> for each site that you&#8217;ve installed.  You should be able to see all the sites you have by looking in your <em>~/Sites/drupal/6/sites/</em> folder.</p>
<p>Once you&#8217;ve gotten all your sites ready for upgrade, return here.</p>
<h2>Step 6: Backup the databases</h2>
<p>Now we need to make a backup of our databases.  We&#8217;ll start by opening the Terminal, and navigating to the our ~/Sites/drupal/ folder.  Once there, we&#8217;ll double check the name of our database.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>drupal<span style="color: #000000; font-weight: bold;">/</span>
$ mysql <span style="color: #660033;">-u</span> yourrootaccount <span style="color: #660033;">-p</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;SHOW SCHEMAS&quot;</span></pre></div></div>

<p>Again, we&#8217;re using <em>yourrootaccount</em>, because I change the name of the root user on my databases as a simple security precaution.</p>
<p>Identify the database for the website, and we&#8217;ll back it up.  Following my previous examples, I&#8217;d need to backup &#8220;drupal_sandbox&#8221; and &#8220;drupal_essentials&#8221;, plus the other databases I&#8217;ve added.  To do this, do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysqldump <span style="color: #660033;">-u</span> yourrootuser <span style="color: #660033;">-p</span> <span style="color: #660033;">--databases</span> drupal_sandbox drupal_essentials <span style="color: #000000; font-weight: bold;">&gt;</span> drupal_20100301.sql</pre></div></div>

<p>Verify that the file looks correct:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ls</span>
$ <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">100</span> drupal_20100301.sql</pre></div></div>

<h2>Step 7: Download the latest version of Drupal</h2>
<p>You can get this from the <a href="http://drupal.org/project/drupal">Drupal Project Download</a> page.  At the time of this writing, Drupal 6.15 is the latest production build, so that&#8217;s what we&#8217;re using.</p>
<p>Download the file and move it into your <em>~Sites/drupal/</em> directory.  If your browser is set up to use your user&#8217;s <em>Downloads/</em> folder, switch back to the Terminal and perform the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Downloads<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #c20cb9; font-weight: bold;">mv</span> drupal-<span style="color: #000000;">6.15</span>.tar.gz ~<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>drupal<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Verify that the file is in your <em>~/Sites/drupal/</em> folder.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>drupal<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span></pre></div></div>

<h2>Step 8: Rename the core directory</h2>
<p>We&#8217;re going to move our Drupal files directory to a new location as a backup.  We&#8217;re going to need our <em>sites/</em> folder later on.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>drupal<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000;">6</span> <span style="color: #000000;">6</span>_backup</pre></div></div>

<h2>Step 9: Install the new version of Drupal</h2>
<p>Now we&#8217;ll unpack the new version of Drupal that we downloaded in <strong>Step 7</strong>.  We&#8217;re also going to rename it to <em>6/</em>, as we had in our original installation.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xzf</span> drupal-<span style="color: #000000;">6.15</span>.tar.gz
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> drupal-<span style="color: #000000;">6.15</span> <span style="color: #000000;">6</span></pre></div></div>

<h2>Step 10: Copy the old files back to the new installation</h2>
<p>Now we need to move all of our custom files back into the new directory. </p>
<p>To start with, we need to make sure we grab the cronall script we created in<a href="http://blogs.martiangraphix.com/2009/09/building-a-drupal-development-environment-for-mac/"> Building a Drupal development environment on Mac OS X</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000;">6</span>_backup<span style="color: #000000; font-weight: bold;">/</span>cronall.php <span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>If you&#8217;ve modified any other files, in Drupal&#8217;s core (e.g. .htaccess, robots.txt, or something in <em>themes/</em>), copy those into the <em>6/</em> folder now.</p>
<p>Now we&#8217;re at the step where we need to make sure to preserve the permissions for the webserver. In order to do this we&#8217;ll use the <strong>cp -Rp</strong> command.  You&#8217;ll need to make sure to include the <strong>sudo</strong> command in front of the copy command, or you&#8217;ll loose the permissions in the <em>sites/</em> folder.  So run the following in the Terminal:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-Rp</span> <span style="color: #000000;">6</span>_backup<span style="color: #000000; font-weight: bold;">/</span>sites <span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Verify that the folders in sites still have the www group.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span> <span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<h2>Step 11: Run the update</h2>
<p>Go back to your browser and run the update script:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">http://drupal6.local/update.php</pre></div></div>

<p>Follow the screen prompts, using the defaults.  You should select <strong>Continue</strong> and then <strong>Update</strong>, and the process will run automatically.  Select the <strong>Administration pages</strong> link at the end of the process.</p>
<h2>Step 12: Check the Status Report</h2>
<p>You&#8217;ll want to verify that the update process ran correctly by checking the status report.  Navigate to <strong>Administer > Reports > Status report</strong> and click <strong>run cron manually</strong>. </p>
<p>You should see the new version at the top of the table, and everything else should be green.</p>
<h2>Step 13: Restore your Modules</h2>
<p>Go back into the Modules page and restore your modules.  Navigate to the page by going to: <strong>Administer > Site building > Modules</strong></p>
<p>Using the list of modules you made in <strong>Step 4</strong>, select the check box in front of each module to turn it back on.  You should be able to select all the modules the first time through the screen.  When you&#8217;re done, select <strong>Save configuration</strong> at the bottom of the screen.</p>
<p>Once the configuration has been saved, you should get a yellow box at the top asking about new releases.  Select the <strong>check manually</strong> link in this box, to see if you need to update any of your modules.</p>
<p>If you get a message that says you need to update your modules, select the <strong>available updates</strong> link to see which modules need to be updated.  If all your modules are current, skip to <strong>Step 15</strong>.</p>
<h2>Step 14: Update your Modules</h2>
<p>From the <strong>Available updates</strong> page, select the <strong>Download</strong> link for each module that needs to be updated.  Copy the tar file into the <em>modules/</em> folder for this particular site.  For example, if it was the CCK module, you would do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>drupal<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6</span>
$ <span style="color: #c20cb9; font-weight: bold;">cp</span> ~<span style="color: #000000; font-weight: bold;">/</span>Downloads<span style="color: #000000; font-weight: bold;">/</span>CCK-<span style="color: #000000;">6</span>.x-<span style="color: #000000;">2.1</span>.tar.gz sites<span style="color: #000000; font-weight: bold;">/</span>drupal6.local<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Now copy the existing module folder someplace else temporarily, and then unpack the new module.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> sites<span style="color: #000000; font-weight: bold;">/</span>drupal6.local<span style="color: #000000; font-weight: bold;">/</span>modules
$ <span style="color: #c20cb9; font-weight: bold;">mv</span> cck ~<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span>cck_backup
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xzf</span> CCK-<span style="color: #000000;">6</span>.x-<span style="color: #000000;">2.1</span>.tar.gz</pre></div></div>

<p>Back in the browser, check that your updates are all correct, by refreshing the <strong>Available updates</strong> page.  Once you have all the correct versions of your modules, proceed to <strong>Step 15</strong>.</p>
<h2>Step 15: Restore your theme</h2>
<p>Return to the <strong>Themes</strong> page, by navigating to <strong>Administer > Site building > Themes</strong></p>
<p>Make sure your theme is <strong>Enabled</strong> and selected as the <strong>Default</strong>, and then select <strong>Save configuration</strong>. </p>
<h2>Step 16: Bring the site back online</h2>
<p>Now we need to reactivate the site.  Navigate to <strong>Administer > Site configuration > Site maintenance</strong> and set your site&#8217;s status to <strong>Online</strong>.</p>
<p>Then select <strong>Save configuration</strong> to reactivate the site.  Log out and go back to the <strong>Home</strong> page, to verify that your site is functioning correctly.  Navigate through some of your pages, to make sure everything looks OK.</p>
<h2>Step 17: Repeat Steps 12-16</h2>
<p>You&#8217;ll need to repeat <strong>Steps 12-16</strong> for each site that you&#8217;re maintaining.</p>
<p>Note: Sometimes an update will change some of the underlying database tables.  These changes can affect your modules, so you&#8217;ll need to make sure to run the status report on each site you have installed.  You may need to run the database update script on each site, before you can reactivate the modules.</p>
<p>That should be all you need to do.  Once you have checked through your sites, and everything looks to be running correctly, you can delete your backup folders.</p>
<p>Hopefuly you&#8217;ve found this tutorial useful.  Let me know if you run into any issues when running through this tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.martiangraphix.com/2010/03/updating-drupal-multisite-on-os-x/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Automating Drupal cron with OS X’s launchd</title>
		<link>http://blogs.martiangraphix.com/2009/10/automating-drupal-cron-with-os-xs-launchd/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=automating-drupal-cron-with-os-xs-launchd</link>
		<comments>http://blogs.martiangraphix.com/2009/10/automating-drupal-cron-with-os-xs-launchd/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 01:04:47 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[launchd]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Multi-Site]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Planet Drupal]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blogs.martiangraphix.com/?p=147</guid>
		<description><![CDATA[Found this great post on Configuring cron on Mac OS X Server 10.5.x in the Drupal documentation. I&#8217;d been wanting to do that with my original post on Building a Drupal Multi-Site development environment, but I hadn&#8217;t had time to figure it out. The title of the page at Drupal says &#8220;Mac OS X Server&#8220;, [...]]]></description>
			<content:encoded><![CDATA[<p>Found this great post on <a href="http://drupal.org/node/562904">Configuring cron on Mac OS X Server 10.5.x</a> in the Drupal documentation.  I&#8217;d been wanting to do that with my original post on <a href="http://blogs.martiangraphix.com/2009/09/building-a-drupal-development-environment-for-mac/">Building a Drupal Multi-Site development environment</a>, but I hadn&#8217;t had time to figure it out.</p>
<p>The title of the page at Drupal says &#8220;<strong>Mac OS X Server</strong>&#8220;, but there&#8217;s nothing that says you can&#8217;t use this technique on <strong>OS X Client</strong>, and I believe it will work on everything 10.4.x and up.</p>
<p>So I&#8217;m going to show you how to tie it into the Multi-Site setup I created on my local machine for the previous blog post.  <span id="more-147"></span>If you haven&#8217;t read that post, you might want to do so, because some of what we&#8217;re going to do here is specific to that installation.</p>
<p>Again, we&#8217;ll be using the <strong>Terminal</strong> a lot for this to make sure that everyone can play, with no special software necessary.</p>
<h3>Step 1: Remove the crontab Installation</h3>
<p>The first thing I&#8217;m going to do is remove the information that I put into the crontab previously.  Obviously, if you did not follow the procedure for creating a crontab file described in <strong>Step 10</strong> for building a Drupal Multi-Site development environment, then this step is not necessary.</p>
<p>The user crontab files are located in <em>/var/cron/tabs/</em>.  The first thing you need to do is make sure that the cronall statement that we put in earlier is the only thing in the file.  In your <strong>Terminal</strong> application do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cron<span style="color: #000000; font-weight: bold;">/</span>tabs<span style="color: #000000; font-weight: bold;">/</span>www</pre></div></div>

<p>If the only thing you see is the statement to execute http://drupal6.local/cronall.php, then it is safe to just delete this file.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>cron<span style="color: #000000; font-weight: bold;">/</span>tabs<span style="color: #000000; font-weight: bold;">/</span>www</pre></div></div>

<p>We&#8217;ll need to stop and start the cron process in order for our changes to take effect.  You can either restart your computer, or a better way is to just use Activity Monitor to quit the cron process.</p>
<ul>
<li>Open <strong>Finder</strong> and navigate into your <strong>Applications &gt; Utilities</strong> folder</li>
<li>Launch the <strong>Activity Monitor</strong></li>
<li>Select <strong>Administrator Processes</strong> in the pulldown at the top</li>
<li>In the <strong>Filter</strong> box at the top, type &#8220;<strong>cron</strong>&#8220;</li>
<li>Highlight the process and select <strong>Quit Process</strong> at the top</li>
<li>You should see the process go away, and come right back again with a new <strong>Process ID</strong></li>
</ul>
<p>If you saw additional commands in the file when you executed the cat command, then it&#8217;s probably best just to edit the crontab file and remove the lines related to Drupal.  If you need to do that then do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">EDITOR</span>=<span style="color: #c20cb9; font-weight: bold;">nano</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> crontab <span style="color: #660033;">-u</span> www <span style="color: #660033;">-e</span></pre></div></div>

<p>Remove the line containing <strong>http://drupal6.local/cronall.php</strong>.</p>
<h3>Step 2: Create a plist file</h3>
<p>Again, we&#8217;re basically following the recommendations found in <a href="http://drupal.org/node/562904">Configuring cron on Mac OS X Server 10.5.x</a>, so if you want to tweek this installation, please read that article.  Now we need to create a launchd daemon .plist file.  We&#8217;ll call this file <em>drupal6.local-cronall.plist</em>, and place it in <em>/Library/LaunchDaemons/</em>.  Open your <strong>Terminal</strong> application and do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchDaemons
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> drupal6.local-cronall.plist</pre></div></div>

<p>Enter the following into the file:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span> 
<span style="color: #00bbdd;">&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot;</span>
<span style="color: #00bbdd;">         &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;</span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plist</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Label<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>drupal6.local-cronall<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>UserName<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>nobody<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>GroupName<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>www<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ProgramArguments<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/usr/bin/curl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>-s<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://drupal6.local/cronall.php<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>RunAtLoad<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;true</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span> 
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>StartInterval<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;integer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>3600<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/integer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plist<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Save the file.</p>
<p><strong><em>Important!!!</em></strong> Note that we changed the <strong>GroupName</strong> from _www as described in the documentation to simply <strong>www</strong>.  Not sure if this is a variation between the OS X Server and the Client version, or it could be a difference between 10.4 and 10.5+.  In any case, for me on 10.4.x Client, it wouldn&#8217;t work until I got this value correct.</p>
<p>As you can see, we&#8217;ve used the <strong>StartInterval</strong> approach described in the article.  I think this approach is more appropriate for our development environment, because it won&#8217;t care if you laptop or desktop is asleep at a specific time.</p>
<h3>Step 3: Start the process</h3>
<p>Ok, so now let&#8217;s load the agent into <strong>launchd</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> launchtl load <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchDaemons<span style="color: #000000; font-weight: bold;">/</span>drupal6.local-cronall.plist</pre></div></div>

<p>When I ran this, I got an error about &#8220;<strong>Workaround Bonjour: &#8230;.</strong>&#8220;, but the script seems to be executing ok, so I think you can ignore it.</p>
<p>Now let&#8217;s do a little testing.</p>
<h3>Step 4: Testing</h3>
<p>There are a couple of ways to test out what we&#8217;ve just done.  The main thing is to open the Drupal status report (<a href="http://drupal6.local/admin/reports/status">http://drupal6.local/admin/reports/status</a>), and check how long it&#8217;s been since your cronall process ran.  If you want to alter the interval while testing, change StartInterval.  I used <strong>120</strong> to make the process run every 2 minutes.  To get your changes to take effect, do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> launchtl unload <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchDaemons<span style="color: #000000; font-weight: bold;">/</span>drupal6.local-cronall.plist</pre></div></div>

<p>This is important, you don&#8217;t want to alter things in the .plist file until you unload it, or you&#8217;ll lose access to the service.  Now change the value of <strong>StartInterval</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchDaemons<span style="color: #000000; font-weight: bold;">/</span>drupal6.local-cronall.plist</pre></div></div>

<p>And then restart the service:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> launchtl load <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchDaemons<span style="color: #000000; font-weight: bold;">/</span>drupal6.local-cronall.plist</pre></div></div>

<p>Just make sure that you reset the <strong>StartInterval</strong> to something like <strong>3600</strong> (1 hr), so that your computer isn&#8217;t constantly banging on your network connection.</p>
<p>That&#8217;s it for this article.  I hope you&#8217;ve found it useful.  If you got into this article from <strong>Step 10</strong> of <a href="http://blogs.martiangraphix.com/2009/09/building-a-drupal-development-environment-for-mac/">Building a Drupal development environment for Mac</a>, then continue back to that article at <strong>Step 11</strong>.  </p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.martiangraphix.com/2009/10/automating-drupal-cron-with-os-xs-launchd/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Building a Drupal development environment for Mac</title>
		<link>http://blogs.martiangraphix.com/2009/09/building-a-drupal-development-environment-for-mac/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=building-a-drupal-development-environment-for-mac</link>
		<comments>http://blogs.martiangraphix.com/2009/09/building-a-drupal-development-environment-for-mac/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 18:00:07 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Multi-Site]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Planet Drupal]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Virtual Host]]></category>

		<guid isPermaLink="false">http://blogs.martiangraphix.com/?p=12</guid>
		<description><![CDATA[I&#8217;ve been working on understanding the Drupal CMS for the past couple of weeks, and it can be a little bit confusing.  As usual with an open source project most of the documentation focuses on Unix/Linux or Windows.  There is some good information for Mac users, but for me, it seemed a little disjointed and [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on understanding the <a href="http://drupal.org" target="_blank">Drupal CMS</a> for the past couple of weeks, and it can be a little bit confusing.  As usual with an open source project most of the documentation focuses on Unix/Linux or Windows.  There is some good information for Mac users, but for me, it seemed a little disjointed and was hard to bring together for a coherent setup.  This is my attempt to explain a <strong><em>complete</em></strong> setup, from start to finish, for doing web development on my local machine running OS X 10.4.  I&#8217;m completely new to Drupal, so if I could have done something better here, please let me know.</p>
<p><span id="more-12"></span>Let me start by saying that all of this information was gathered from the <a title="Drupal Handbooks" href="http://drupal.org/handbooks" target="_blank">Drupal documentation</a>.  I&#8217;ll try to give references to those sources as I go along, and point out where I made slightly different choices than the authors of those sections. Let&#8217;s look at what we&#8217;re trying to accomplish.  I really like the Multi-Site capability of Drupal.  It&#8217;s awesome that you can work with several websites, while only having to install the Drupal code once on your machine.  So:</p>
<ul>
<li>We&#8217;re going to use Drupal&#8217;s Multi-Site capability.</li>
<li>We&#8217;re going to have a separate database for each site that we use.</li>
<li>We&#8217;re going to host Drupal in our local user&#8217;s <em>Sites/</em> folder, instead of in the master web folder.</li>
<li>We&#8217;re going to set up Virtual Hosting on our webserver to help ourselves out.</li>
</ul>
<p><strong>Assumptions:</strong> You have MySQL 5.0+ and PHP 5.2+ already set up on your machine. That should be all you need.  Some of this could definitely be done easier with additional tools, but I&#8217;m trying to make sure that everyone can follow along with this, whether they have tools like PHPMyAdmin or MySQL Workbench installed or not.  So I&#8217;m going to be working a lot on the command line in the Terminal.  Don&#8217;t let this intimidate you, I try to take it step by step. Ok, so let&#8217;s get started.</p>
<h2>Step 1: Setting up the database</h2>
<p>We&#8217;ll start by setting up the database for our first installation of Drupal.  You can find some additional information about installing the database for Drupal <a title="Drupal.org - Create the database" href="http://drupal.org/getting-started/6/install/create-database" target="_blank">here</a>.  We&#8217;ll skip some of the unnecessary details like flushing privileges, because MySQL handles that for us with the GRANT statement. Open a Terminal window, and create a new database.  In this case we&#8217;ll call our database &#8220;drupal_sandbox&#8221;, but you can call it whatever you like.</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">$ mysql <span style="color: #CC0099;">-</span>u yourrootaccount <span style="color: #CC0099;">-</span>p
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">SCHEMA</span> drupal_sandbox<span style="color: #000033;">;</span></pre></div></div>

<p>Notice that I put <em>yourrootaccount</em> as the username when launching the mysql client.  This is an account which has privileges to CREATE databases and GRANT privileges.  In most case this user will be <em>root</em>, but when I install MySQL on my systems, I always change the root user to a different username, as a simple security measure.  This follows with the OS X methodology of not enabling the root account for Unix.  In the future I&#8217;ll post an article on my MySQL installation procedures. </p>
<p>Now we&#8217;ll create the application user for the database.  You want to create a separate username for the application, to prevent any hacker who cracks your application from having total access to the database.  In SQL users are created by using the GRANT statement, which has the form <strong>GRANT <em>privileges</em> ON <em>dbname</em>.* TO &#8216;<em>username</em>&#8216;@&#8217;<em>location</em>&#8216; IDENTIFIED BY &#8216;<em>password</em>&#8216;</strong>.  We need to use the same database name we created above, our username will be &#8220;<em>drupal_app</em>&#8220;, and the password will be &#8220;<em>fuzzy</em>&#8220;.</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">GRANT</span> <span style="color: #990099; font-weight: bold;">SELECT</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">INSERT</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">UPDATE</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">DELETE</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">CREATE</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">DROP</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">INDEX</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">ALTER</span>
    <span style="color: #CC0099;">-&gt;</span>   <span style="color: #990099; font-weight: bold;">ON</span> drupal_sandbox.<span style="color: #CC0099;">*</span>
    <span style="color: #CC0099;">-&gt;</span>   <span style="color: #990099; font-weight: bold;">TO</span> <span style="color: #008000;">'drupal<span style="color: #008080; font-weight: bold;">_</span>app'</span>@<span style="color: #008000;">'localhost'</span>
    <span style="color: #CC0099;">-&gt;</span>   IDENTIFIED BY <span style="color: #008000;">'fuzzy'</span><span style="color: #000033;">;</span></pre></div></div>

<p>That&#8217;s it.  Drupal will install all the database tables during installation. Exit MySQL by typing the following:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> quit<span style="color: #000033;">;</span></pre></div></div>

<h2>Step 2: Add a new host entry to the local machine</h2>
<p>Next, let&#8217;s set up the Apache webserver that comes with OS X 10.4.  For OS X 10.5+ these instructions will be slightly different, since it uses Apache 2.2.  The basics for this virtual host setup can be found in the Drupal documentation <a title="HowTo: Configure your local workstation to serve multiple sites using Drupal's multisite configurations and Apache's VirtualHost" href="http://drupal.org/node/238805" target="_blank">here</a>, which does a good job of describing the Apache 2.2 setup. </p>
<p>We&#8217;re going to add an entry to <em>/etc/hosts</em>, so that a request to DOCUMENT_ROOT will point to our Drupal installation in <em>~/Sites</em>. Drupal would normally expect our installation to be in the <em>/Library/Webserver/Documents</em> folder, but I prefer not to clutter that up with all my development work.  Open a Terminal window, and type the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>hosts</pre></div></div>

<p>Add the following lines to the end of the file:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">##################################
# Virtual Hosts section
##################################
127.0.0.1    drupal6.local</pre></div></div>

<p>Save the file. This is similar to what was done in the documentation, but we&#8217;re changing the hostname to drupal6 to allow for greater flexibility in the future, when we install Drupal 7.x.  In that case, we&#8217;ll probably want a drupal7.local path.</p>
<h2>Step 3: Edit the Apache configuration files</h2>
<p>Begin by editing httpd.conf located in <em>/etc/httpd</em>.  This file will be in <em>/etc/apache2</em> on OS X 10.5+.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>httpd
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> httpd.conf</pre></div></div>

<p>Verify that the Rewrite module is enabled.  Make sure the following line is uncommented:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">LoadModule</span> rewrite_module        libexec/httpd/mod_rewrite.so</pre></div></div>

<p>Again, this will be somewhat different for Apache 2 which is on OS X 10.5+.  We just want to make sure that we are able to use <em>.htaccess</em> files. Enable the following line by removing the # in front of it:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">NameVirtualHost</span> *:<span style="color: #ff0000;">80</span></pre></div></div>

<p>Scroll to the end of the file and verify that the following directive is enabled:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">Include</span> /private/etc/httpd/users/*.conf</pre></div></div>

<p>This will enable us to add our virtual host directives in a separate file in the users directory.  On OS X 10.5+ you&#8217;ll be looking for something in the <em>httpd/extra/</em> folder.  Close the <em>httpd.conf</em> file.  We&#8217;re going to add a file called <em>httpd-vhosts.conf</em> to the users directory.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">users</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">touch</span> httpd-vhosts.conf
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> httpd-vhosts.conf</pre></div></div>

<p>Add the following lines to this configuration file (obviously changing <em>yourusername</em> to your user name on your local system):</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;">#</span>
<span style="color: #adadad; font-style: italic;"># Virtual hosts</span>
<span style="color: #adadad; font-style: italic;">#</span>
&nbsp;
&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
    <span style="color: #00007f;">DocumentRoot</span> <span style="color: #7f007f;">&quot;/Library/WebServer/Documents&quot;</span>
    <span style="color: #00007f;">ErrorLog</span> <span style="color: #7f007f;">&quot;/private/var/log/httpd/error_log&quot;</span>
    <span style="color: #00007f;">CustomLog</span> <span style="color: #7f007f;">&quot;/private/var/log/httpd/access_log&quot;</span> common
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;
&nbsp;
&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
    <span style="color: #00007f;">ServerAdmin</span> webmaster@drupal6.local
    <span style="color: #00007f;">DocumentRoot</span> <span style="color: #7f007f;">&quot;/Users/yourusername/Sites/drupal/6&quot;</span>
    <span style="color: #00007f;">ServerName</span> drupal6.local
    <span style="color: #00007f;">ServerAlias</span> *.drupal6.local
    <span style="color: #00007f;">ErrorLog</span> <span style="color: #7f007f;">&quot;/private/var/log/httpd/drupal6.local-error_log&quot;</span>
    <span style="color: #00007f;">CustomLog</span> <span style="color: #7f007f;">&quot;/private/var/log/httpd/drupal6.local-access_log&quot;</span> common
    &lt;<span style="color: #000000; font-weight:bold;">Directory</span> <span style="color: #7f007f;">&quot;/Users/yourusername/Sites/drupal/6/&quot;</span>&gt;
        <span style="color: #00007f;">Options</span> <span style="color: #0000ff;">Indexes</span> <span style="color: #0000ff;">FollowSymLinks</span>
        <span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">All</span>
        <span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span>
        <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span>
    &lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></div></div>

<p>As stated in the article listed above, the first section needs to match what is in your httpd.conf file.  The second section sets up our Drupal virtual host.  In addition to what was described in that article, we&#8217;ve added the &lt;Directory&gt; section.  This change is important because we want to make sure that SymLinks are followed, and we need the AllowOverride directive to make sure that our .htaccess file is read. Open your System Preferences, select Sharing, stop and restart Personal Web Sharing.  Ok, so now we&#8217;re ready to move on.</p>
<h2>Step 4: Create the directory for your local copy of Drupal</h2>
<p>Navigate to your local <em>Sites/</em> directory and create a folder for Drupal.  You can do this through Finder or on the command line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Sites
$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> drupal
$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> drupal<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6</span></pre></div></div>

<p>Our installation of the Drupal files will go inside the <em>6/</em> sub-folder. When Drupal 7.x is released, we&#8217;ll add a <em>drupal/7/</em> folder for the installation of it.</p>
<h2>Step 5: Test our installation so far</h2>
<p>Navigate to your Sites and open up the <em>drupal/6/</em> folder with Finder.  Create a new file, and name it index.php.  Open this file with the text editor of your choice, and insert the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;h1&gt;You are in the Drupal 6 folder&lt;/h1&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Save the file and in your web browser enter <a href="http://drupal6.local/">http://drupal6.local/</a> and hit return.  If you see a page with &#8220;<strong>You are in the Drupal 6 folder</strong>&#8220;, then your virtual host configuration is working correctly.</p>
<h2>Step 6: Install the Drupal files</h2>
<p>We&#8217;ll be using Finder for the first part of this step, but keep the Terminal handy for the second part.</p>
<ul>
<li>Open your <em>Sites/</em> folder</li>
<li>Open the drupal/ folder and move the <em>6/</em> folder we created in Step 4 to the Trash</li>
<li>Download the latest copy of <a title="Drupal.org" href="http://drupal.org" target="_blank">Drupal</a> (6.13 at the time of this writing)</li>
<li>Find the file you downloaded, and move it into your <em>Sites/</em> folder</li>
<li>Double click the compressed file you downloaded to extract the contents</li>
<li>You should now have a folder like <em>drupal-6.13/</em> in your <em>Sites/</em> folder</li>
<li>Drag <em>drupal-6.13/</em> onto your <em>drupal/</em> folder</li>
<li>Open the <em>drupal/</em> folder and rename <em>drupal-6.13/</em> to <em>6/</em></li>
</ul>
<p>Now switch back to the Terminal so we can verify that we have all the files we need.  Type the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>drupal<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6</span>
$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-la</span></pre></div></div>

<p><em>Verify that the list contains the <strong>.htaccess</strong> file.</em>  This file is important to have.</p>
<h2>Step 7: Setting up the <em>sites/</em> directory and configuration script</h2>
<p>Now we&#8217;re ready to set up our configuration script.  All we&#8217;d really need to do now, would be to copy the configuration script in the <em>sites/default/</em> directory in our drupal installation, but we&#8217;re going to change things up a bit to help ourselves out with setting up the MultiSite cron jobs later on. In the Terminal, navigate to our installation folder and then into the <em>sites/</em> sub-folder as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>drupal<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">/</span>sites
$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> drupal6.local</pre></div></div>

<p>While we&#8217;re at it, let&#8217;s go ahead and make the directories for site specific themes and modules.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> all<span style="color: #000000; font-weight: bold;">/</span>modules
$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> all<span style="color: #000000; font-weight: bold;">/</span>themes
$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> drupal6.local<span style="color: #000000; font-weight: bold;">/</span>modules
$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> drupal6.local<span style="color: #000000; font-weight: bold;">/</span>themes</pre></div></div>

<p>We need to copy the default.settings.php file, in the <em>sites/default/</em> directory, into the <em>drupal6.local/</em> directory we just created.  We also need to rename the copy <em>settings.php</em>.  We can take care of both of those items with the following command.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cp</span> default<span style="color: #000000; font-weight: bold;">/</span>default.settings.php drupal6.local<span style="color: #000000; font-weight: bold;">/</span>settings.php</pre></div></div>

<p>The Drupal documentation tells you that you need to set permissions for the settings file.  We won&#8217;t be doing that explicitly, because our next step will take care of it.</p>
<h2>Step 8: Giving ownership to the webserver</h2>
<p>The web server will need access to the files in these directories, so we&#8217;re going modify the access privileges for the <em>~/Sites/drupal/6/</em> directory.  We&#8217;re also going to change the group of this directory to www, which is the web server.  You can do this through the Finder by selecting the <em>6/</em> folder and pressing Command-I, and editing the Ownership &amp; Permissions info, but it&#8217;s simple to do from the command line.  So type in the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>drupal<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">/</span>sites
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> g+<span style="color: #c20cb9; font-weight: bold;">w</span> drupal6.local
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> g+<span style="color: #c20cb9; font-weight: bold;">w</span> drupal6.local<span style="color: #000000; font-weight: bold;">/</span>settings.php
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chgrp</span> <span style="color: #660033;">-R</span> www <span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

<h2>Step 9: Installing Drupal</h2>
<p>We&#8217;re finally ready to set up our installation of Drupal.  Open your web browser of choice, and enter the following in the address bar:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">http://drupal6.local/</pre></div></div>

<p>This should start the installation process.  If you don&#8217;t see the Drupal logo and &#8220;Choose a Language&#8221; on the webpage, go back and check your settings.</p>
<ul>
<li>Select Install Drupal in English</li>
<li>Leave the Database type at mysqli</li>
<li>Enter the database information you used in Step 1 above</li>
<li>Leave the Advanced database options alone unless you need to use them</li>
<li>Hit save and continue, and the site will install</li>
</ul>
<p>The final process of the setup  asks you to Configure the site.  You&#8217;ll enter a Site name, username for your administrator, and some email addresses for automated notifications.</p>
<ul>
<li>Site name: Drupal Sandbox</li>
<li>Site e-mail address: youremail@yourdomain.com</li>
<li>Administrator Username: whatever you like (admin)</li>
<li>Admin email address: youremail@yourdomain.com</li>
<li>Password: yourpassword</li>
<li>Set your timezone</li>
<li>Enable Clean URLs if possible</li>
<li>Check for updates</li>
</ul>
<p>Now change the permissions of the drupal6.local/ folder and the settings.php file back to not writable</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>drupal<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">/</span>sites
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> g-w drupal6.local
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> a-w drupal6.local<span style="color: #000000; font-weight: bold;">/</span>settings.php</pre></div></div>

<p>That should be it.  Click on &#8220;your new site&#8221; to see that the webpage is functioning properly.  If you look under &#8220;Administer&#8221; you should see a warning that &#8220;Cron has not run&#8221;. We&#8217;ll take care of that next.</p>
<h2>Step 10: Configuring cron</h2>
<p>Running a cron process is extremely important for Drupal.  There are multiple functions for which Drupal uses the cron process, including: indexing content, pruning logs, checking for updates, and others.  The simple way to get this to work would be to just update the systems crontab to update the site, as described in <a title="Drupal - Configuring cron jobs" href="http://drupal.org/cron" target="_blank">Configuring cron jobs</a>.  However, since we&#8217;re installing a multi-site system, and we don&#8217;t want to have to remember to update the crontab each time we add a site, we&#8217;re going to use a script to automate this process.  </p>
<p>Again, the <a title="Multisite cron" href="http://drupal.org/node/237503" target="_blank">Drupal documentation</a> has many examples of scripts, using bash, php, python and more.  I encourage you to take a look at them. I made my own here, because I either didn&#8217;t understand what the ones on the Drupal site were trying to do, or they didn&#8217;t seem flexible enough, but most of them looked like they might not cover all the likely possibilities. </p>
<p>There was a pretty good one posted by <a title="Multi-site cron without wget or curl" href="http://drupal.org/node/511960" target="_blank">Carl van Denzen</a>, that had a similar methodology to this script, but it had external dependencies.  So I just dove in and tried to come up with my own solution. (As an option, I&#8217;ve posted a <a href='http://blogs.martiangraphix.com/wp-content/uploads/2009/09/cronall.tar.gz'>copy of the file</a> for you to download, so you don&#8217;t have to type it all in). </p>
<p>Open a new file in your text editor and save it as <em>cronall.php</em> in the <em>drupal/6/</em> folder.  Add the following to this file:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #009933; font-style: italic;">/**
    *   This script will call a cron job for each valid Drupal site
    *   in your installation.  Whether you have one site or many in a
    *   Multi-Site configuration.  It will find all folders contained
    *   in the &quot;sites&quot; folder of your code base which contain a
    *   settings.php file.  These are assumed to be valid sites.
    *   This script should be put in the top level of your code base.
    *
    *   Note: It is assumed that you have properly configured your
    *   webserver to map each top level directory in &quot;sites&quot; to an
    *   equivalent VirtualHost.
    *
    *   This script will take these folders and transfer them to URLs.
    *   For example:
    *
    *       sites/drupal6.local        ==&gt;   http://drupal6.local/cron.php
    *       sites/drupal6.local/site1  ==&gt;   http://drupal6.local/site1/cron.php
    *       sites/bunnies.local        ==&gt;   http://bunnies.local/cron.php
    *
    *   It is a &quot;Best Practice&quot; to use a directory for your master
    *   domain, instead of using the 'default' folder.  However, if
    *   you use the 'default' folder, the value in $masterDomainName
    *   will be inserted to replace 'default' in the URL.
    *
    *       sites/default          ==&gt;   http://drupal6.local/cron.php
    *       sites/default/site1    ==&gt;   http://drupal6.local/site1/cron.php
    *
    *   For any sites not picked up by this script automatically, you can
    *   manually specify the path in the $addedSites array.
    *
    *   Notice:  This script is provided &quot;As Is&quot;.  No warranty is expressed
    *            or implied.  You may freely modify/use it as you like.
    */</span>
&nbsp;
    <span style="color: #000088;">$sitesDir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;./sites&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$cronURL</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://%s/cron.php'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//  any additional sites not picked up by this script may</span>
    <span style="color: #666666; font-style: italic;">//  be manually inserted here, just uncomment $addedSites</span>
    <span style="color: #666666; font-style: italic;">//$addedSites = array('insertDomainPathHere');</span>
&nbsp;
    <span style="color: #000088;">$masterDomainName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'drupal6.local'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$sites</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//  populate the $sites array by calling find_sites()</span>
    find_sites<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$sites</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//  If $addedSites is not empty and it is an array,</span>
    <span style="color: #666666; font-style: italic;">//  merge it with $sites</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$addedSites</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$addedSites</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$sites</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$sites</span><span style="color: #339933;">,</span> <span style="color: #000088;">$addedSites</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//  remove any duplicate entries in $sites</span>
    <span style="color: #666666; font-style: italic;">//  this is in case the 'default' directory</span>
    <span style="color: #666666; font-style: italic;">//  and a $masterDomainName directory both exist</span>
    <span style="color: #000088;">$sites</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_unique</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$sites</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//  for each site in $sites, execute a cron command</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$sites</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$site</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//  Use ONE of the following command lines</span>
        <span style="color: #666666; font-style: italic;">//$cmd = '/usr/bin/lnyx -source ' . sprintf( $cronURL, $site );</span>
        <span style="color: #666666; font-style: italic;">//$cmd = 'wget -O - -q -t 1 ' . sprintf( $cronURL, $site );</span>
        <span style="color: #000088;">$cmd</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/usr/bin/curl --silent --compressed '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$cronURL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$site</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Executing command: <span style="color: #006699; font-weight: bold;">$cmd</span>&lt;br/&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">exec</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$cmd</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     *   Recursively find all valid Drupal sites
     *
     *   This method recursively looks in the $sitesDir directory
     *   and will find all folders that include a settings.php
     *   file.  These are assumed to be valid/active sites in
     *   the Drupal installation.  Any folder containing the
     *   settings.php file will be added to the $sites[] array,
     *   which is passed into the function by reference.
     *
     *   If the 'default' folder is used, the value in $masterDomainName
     *   will be substituted into the path in the $sites[] array.
     *
     *   @param  string[]  &amp;$sites  a string array containing all the sites.
     *                              This parameter is passed by reference, so
     *                              changes will persist outsite the function.
     *   @param  string   $dirPath  a string containing the directory path
     *                              to traverse
     *   @return void
     */</span>
    <span style="color: #000000; font-weight: bold;">function</span> find_sites<span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$sites</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dirPath</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$sitesDir</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$masterDomainName</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$dh</span> <span style="color: #339933;">=</span> <span style="color: #990000;">opendir</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$sitesDir</span>/<span style="color: #006699; font-weight: bold;">$dirPath</span>&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #990000;">readdir</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$dh</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">//  must account for the empty $dirPath the</span>
                <span style="color: #666666; font-style: italic;">//  first time through the function</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$dirPath</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$subDirPath</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$dirPath</span>/<span style="color: #006699; font-weight: bold;">$filename</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #b1b100;">else</span>
                <span style="color: #009900;">&#123;</span>  <span style="color: #666666; font-style: italic;">//  This is not the first time through,</span>
                   <span style="color: #666666; font-style: italic;">//  just add the filename</span>
                   <span style="color: #000088;">$subDirPath</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$filename</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #666666; font-style: italic;">//  ignore the 'all' directory, the '.' and '..' directories</span>
                <span style="color: #666666; font-style: italic;">//  also ignore regular files</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$filename</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'all'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$filename</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'.'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span>
                     <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$filename</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'..'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$sitesDir</span>/<span style="color: #006699; font-weight: bold;">$subDirPath</span>&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#123;</span>
                    <span style="color: #666666; font-style: italic;">//  if the directory contains a settings.php file, it is</span>
                    <span style="color: #666666; font-style: italic;">//  a valid site.  we need to add it to the $sites[] array</span>
                    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$sitesDir</span>/<span style="color: #006699; font-weight: bold;">$subDirPath</span>/settings.php&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
                    <span style="color: #009900;">&#123;</span>
                        <span style="color: #666666; font-style: italic;">//  if the path contains 'default', replace 'default'</span>
                        <span style="color: #666666; font-style: italic;">//  with $masterDomainName and insert it into $sites[]</span>
                        <span style="color: #666666; font-style: italic;">//  need to keep 'default' in $subDirPath</span>
                        <span style="color: #666666; font-style: italic;">//  so we can navigate the tree</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$subDirPath</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'default'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
                        <span style="color: #009900;">&#123;</span>
                            <span style="color: #000088;">$sites</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr_replace</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$subDirPath</span><span style="color: #339933;">,</span> 
                                                       <span style="color: #000088;">$masterDomainName</span><span style="color: #339933;">,</span>
                                                       <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'default'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span>
                        <span style="color: #b1b100;">else</span>
                        <span style="color: #009900;">&#123;</span>
                            <span style="color: #000088;">$sites</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$subDirPath</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span>  <span style="color: #666666; font-style: italic;">//end if else</span>
&nbsp;
                        <span style="color: #666666; font-style: italic;">//  enter the next loop of recursion</span>
                        <span style="color: #666666; font-style: italic;">//  pass find_sites the current dir path</span>
                        find_sites<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$sites</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subDirPath</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                    <span style="color: #009900;">&#125;</span>  <span style="color: #666666; font-style: italic;">// end if</span>
&nbsp;
                <span style="color: #009900;">&#125;</span>  <span style="color: #666666; font-style: italic;">// end if</span>
&nbsp;
            <span style="color: #009900;">&#125;</span>  <span style="color: #666666; font-style: italic;">// end while</span>
&nbsp;
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;Unable to find directory <span style="color: #006699; font-weight: bold;">$sitesDir</span>/<span style="color: #006699; font-weight: bold;">$dirPath</span>&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>  <span style="color: #666666; font-style: italic;">// end if else</span>
&nbsp;
        <span style="color: #990000;">closedir</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$dh</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>  <span style="color: #666666; font-style: italic;">// end function find_sites()</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Save the file.  Now we need to make sure that our cronall script is called automatically by the system.  You have 2 options for making this happen:</p>
<ul>
<li>Set up cron to call cronall once per hour, as described in the rest of this Step</li>
<li>Use OS X&#8217;s launchd to automate the task, as I described in my subsequent post <a href="http://blogs.martiangraphix.com/2009/10/automating-drupal-cron-with-os-xs-launchd/">Automating Drupal cron with OS X’s launchd</a></li>
</ul>
<p>If you&#8217;ve chosen the more Unix like approach, using cron, then we&#8217;re first going to set the default editor to <strong>nano</strong>.  We&#8217;re also going to edit the cron script and run it as the user www, for security reasons.  So, switch back to the Terminal and do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">EDITOR</span>=<span style="color: #c20cb9; font-weight: bold;">nano</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> crontab <span style="color: #660033;">-u</span> www <span style="color: #660033;">-e</span></pre></div></div>

<p>Add the following line to the end this file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>curl <span style="color: #660033;">--silent</span> <span style="color: #660033;">--compressed</span> http:<span style="color: #000000; font-weight: bold;">//</span>drupal6.local<span style="color: #000000; font-weight: bold;">/</span>cronall.php</pre></div></div>

<p>That first position is what minute of each hour you want the script to run (0-59).  So if you prefer to go at 30 min after the hour, you would subsitute 30 for 0.  You can also do a little bit of testing by changing the first number to */1, or */2.  This will set the cronall script to run every minute or every other minute respectively.  Navigate in your Drupal website to <em>Administer &gt; Reports &gt; Status report</em> and update every couple of minutes to verify that cron is running.  Just remember to set it back to a whole number when you are done.</p>
<h2>Step 11: Decide how to organize additional sites</h2>
<p>Ok, so now we&#8217;re ready to add additional sites to our system.  The first thing to do is decide what structure you want to use.  You have basically three options.  You can:</p>
<ol>
<li>Host the site as a subdirectory to your existing site (eg. <a href="http://drupal6.local/site1/">http://drupal6.local/site1/</a>)</li>
<li>Create a subdomain to the existing site (eg <a href="http://sub1.drupal6.local/">http://sub1.drupal6.local/</a>)</li>
<li>Or you can create an entirely different domain (eg <a href="http://bunnies.local/">http://bunnies.local/</a>)</li>
</ol>
<p>We&#8217;re going to cover the 2nd option.  But if you want to do the 1st option, you basically create a new database with appropriate user privileges, add a folder named &#8216;site1&#8242; in the <em>drupal6.local/</em> folder, copy the <em>default.settings.php</em> to the new directory as before, and point your browser at <a href="http://drupal6.local/site1/">http://drupal6.local/site1/</a> For more details about the 3rd option, you should be able to look at <a title="Setting up multi-site Drupal 5 on Windows or Linux" href="http://drupal.org/node/169034" target="_blank">Setting up multi-site Drupal 5 on Windows or Linux</a>, and figure out how to mash it up with these instructions. </p>
<p>In my case, I&#8217;m going to use the new site to work through the <a title="Lynda.com - Drupal Essentials" href="http://www.lynda.com/home/DisplayCourse.aspx?lpk2=620" target="_blank">Drupal Essentials</a> training by <a title="TomGeller.com" href="http://www.tomgeller.com/" target="_blank">Tom Geller</a> over at <a title="Lynda.com" href="http://www.lynda.com/" target="_blank">Lynda.com</a>, so I&#8217;ll use that when choosing a naming scheme for this additional site.</p>
<h2>Step 12: Adding a database for your Multi-Site</h2>
<p>Now we&#8217;ll add our new database.  We follow the same process as in <strong>Step 1</strong>, except we&#8217;ll just use the same application user from above.  If you want to create a new user, just follow the GRANT procedure from before.  Switch to the Terminal, and enter the following:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">$ mysql <span style="color: #CC0099;">-</span>u yourrootaccount <span style="color: #CC0099;">-</span>p
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">SCHEMA</span> drupal_essentials<span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">GRANT</span> <span style="color: #990099; font-weight: bold;">SELECT</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">INSERT</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">UPDATE</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">DELETE</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">CREATE</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">DROP</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">INDEX</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">ALTER</span>
    <span style="color: #CC0099;">-&gt;</span>   <span style="color: #990099; font-weight: bold;">ON</span> drupal_essentials.<span style="color: #CC0099;">*</span>
    <span style="color: #CC0099;">-&gt;</span>   <span style="color: #990099; font-weight: bold;">TO</span> <span style="color: #008000;">'drupal<span style="color: #008080; font-weight: bold;">_</span>app'</span>@<span style="color: #008000;">'localhost'</span><span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span> quit<span style="color: #000033;">;</span></pre></div></div>

<h2>Step 13: Update the hosts file</h2>
<p>We&#8217;re going to modify /etc/hosts again so that our machine recognizes a call to <a href="http://essentials.drupal6.local/">http://essentials.drupal6.local/</a> is really just pointing to the local machine.  Go to your Terminal window and type the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>hosts</pre></div></div>

<p>Add the following entry at the end of the file:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">127.0.0.1     essentials.drupal6.local</pre></div></div>

<p>Save the file.  We&#8217;ve already taken care of configuring the Virtual Hosts, so this should be all we need.</p>
<h2>Step 14: Setting up the <em>sites/</em> folder</h2>
<p>Now we need to set up the <em>sites/</em> folder like we did before.  We&#8217;ll breeze through it, but this is almost identical to process covered in <strong>Steps 7-8</strong> above, if you want to look back at any of it.  In your Terminal do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>drupal<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">/</span>sites
$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> essentials.drupal6.local
$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> essentials.drupal6.local<span style="color: #000000; font-weight: bold;">/</span>modules
$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> essentials.drupal6.local<span style="color: #000000; font-weight: bold;">/</span>themes
$ <span style="color: #c20cb9; font-weight: bold;">cp</span> default<span style="color: #000000; font-weight: bold;">/</span>default.settings.php essentials.drupal6.local<span style="color: #000000; font-weight: bold;">/</span>settings.php
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> g+<span style="color: #c20cb9; font-weight: bold;">w</span> essentials.drupal6.local
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> g+<span style="color: #c20cb9; font-weight: bold;">w</span> essentials.drupal6.local<span style="color: #000000; font-weight: bold;">/</span>settings.php
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chgrp</span> <span style="color: #660033;">-R</span> www essentials.drupal6.local</pre></div></div>

<h2>Step 15: Installing the new Drupal site</h2>
<p>To install the new site you should open your web browser of choice and type in: <a href="http://essentials.drupal6.local/">http://essentials.drupal6.local/</a> Follow the same procedures as listed in <strong>Step 9</strong>.  Again, when we are done, we should remove the write permissions from the <em>essentials.drupal6.local/</em> folder and the <em>setings.php</em> file.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Sites<span style="color: #000000; font-weight: bold;">/</span>drupal<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">/</span>sites
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> g-w essentials.drupal6.local
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> a-w essentials.drupal6.local<span style="color: #000000; font-weight: bold;">/</span>settings.php</pre></div></div>

<h2>Step 16: Repeat</h2>
<p>Congratulations! You&#8217;re done. Really, that&#8217;s all there is to it.  Turn off your computer! </p>
<p>You can repeat <strong>Steps 11-15</strong> as many times as you like, and set up as many sites as you need to work on.  Each one can have it&#8217;s own unique modules and themes. I hope you&#8217;ve gotten something useful out of this tutorial.  I know it&#8217;s rather long.  There are obviously some simpler ways to do some of this stuff, but I wanted a system that was pretty flexible, robust and easy to expand.  Hopefully I&#8217;ve accomplished that. Enjoy!</p>
<p>[Update] When you get ready to update your Drupal installation, you can check back here for my other tutorial, <a href="http://blogs.martiangraphix.com/2010/03/updating-drupal-multisite-on-os-x/">Updating Drupal Multi-Site on OS X</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.martiangraphix.com/2009/09/building-a-drupal-development-environment-for-mac/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
	</channel>
</rss>

