<?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; Virtual Host</title>
	<atom:link href="http://blogs.martiangraphix.com/tag/virtual-host/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>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>

