Entries Tagged 'Mac/OSX' ↓

Of Tornadoes and Drupal Multi-site Installs

Late last night, in the time between running down to our nasty basement to avoid tornadoes and some big storm action, I got to coding. I couldn’t sleep and it was a pleasant distraction — not to mention my laptop wasn’t plugged in, so I didn’t have to worry about electricity. My Drupal-enthusiast friends and I have been trying to do a multi-site install for a few weeks, and to my amazement, with a howling wind, hail, etc., the last piece finally fell into place. One of my pals had said the issue was symbolic links. Bingo. That was it.

To back up, a multi-site install means you set up the core of Drupal just once, and then you can easily create lots of other sites using that one installation. The other sites don’t even have to have the same domain. It’s very cool. For example, at work I hope to set up one master Drupal site, and then create instances for each of the labs. After that, the labs can maintain their own sites.

For now all I’ve done is to set it up on my Macbook using localhost. I made it as modest as possible — just using one database and subdirectories. But having worked through this, it will be much easier to get it working in production.

Here are the gory details.

  1. Go to the “sites/” directory and set up your new directory. At first, I named it “sites/site2/”, but that turned out to be a mistake. Given that the URL I was going for was http://localhost:8888/drupal/site2/, the correct name was “sites/8888.localhost.drupal.site2/”. It still looks weird to me, but that’s how you do it. The pattern is:
    [Port #.]domain[.directory][.subdirectory]/
    So if the URL were to be http://happywebdiva.com/drupal/site2, then the new directory would have to be happywebdiva.com.drupal.site2/
  2. Copy the “settings.php” file found in “sites/default/” into the new directory.
  3. Edit the new “settings.php” file. Leave the $db_url the same, but on the next line, give $db_prefix a value. I cleverly edited mine to read:
    $db_prefix = ’site2_’;
    This way you won’t have to set up a new database. Once you install the second site (step 6 below), the database size will double — from 40 tables to 80 tables.
  4. Further down in the “settings.php” file, look for a line that’s something like:
    # $base_url = ‘http://www.example.com’;
    Uncomment this and change it to your desired URL. In my case this was:
    $base_url = ‘http://localhost:8888/drupal/site2′;
  5. Next it’s time to create the dreaded symbolic link. Open Terminal (on a Mac) and use the ln -s command followed by first the full path of your base install and then the full path of the second sites’ directory (leaving off the characters before the periods in the final directory, e.g. changing “8888.localhost.drupal.site2″ to just “site2″). In my example, it was:
    ln -s /home/username/public_html/drupal/ /home/username/public_html/drupal/site2
    One caution: be sure there’s not a file or directory in the first directory that’s the same name as your new install. You don’t want the symbolic link overwriting something critical.
  6. The last step…. In your browser, go to the new site’s URL followed by install.php, e.g. http://localhost:8888/drupal/site2/install.php

That’s it. You should now have a second site (and soon a third and fourth) to play with.

Addendum: In the myriad of multi-site documentation that’s on the web, these three pages helped me the most:

Black Turtleneck Day

Black turtleneckTomorrow, Tuesday January 15, I’ll be wearing a black turtleneck.

It’s not that I’m an Apple zealot nor is it a statement of solidarity, although I do like many of their products — a lot. In truth it’s just one less early-morning wardrobe decision.

No jeans, though.

Some people look a lot better in dungarees than others.

Want PHP and MySQL? Get MAMP First

MAMPLike any self-respecting web diva, one of my first jobs on a new laptop is to turn it into a development server. In other words, I need Apache, PHP and MySQL running on my own machine where no one else can see it and I can be as bad as I want to be.

In the past, I’ve had to do this the old-fashioned way, jumping through various scary hoops like downloading raw PHP and editing obscure hidden files. But that was then.

In the intervening years, a series of app’s named things like WAMP and MAMP have come along. (Gotta love techno-babble.) These AMP’s do all this heavy lifting for you. “AMP” stands for Apache, PHP and MySQL. If you tack a W on the front, it’s for a Windows machine. If you tack an M on instead, it’s for (you guessed it) Mac OSX.

I’d heard about MAMP before, but installing is believing. In fact it was so easy I started frantically looking for fancy instructions, but just couldn’t find any. In the end, after downloading, unzipping and moving MAMP to the Applications folder, I finally crossed my fingers and double-clicked it. Voila — in about 10 seconds everything was done for me. It even gives you various choices, like PHP 4 or PHP 5.

And now, just a few hours later, I have localhost copies of things like Drupal running on my little old MacBook. I’m free to be as bad as I want to be.

MacBook At Last

Yesterday was a banner day. After months (years?) of pining for a small Mac laptop with an Intel processor, I now have one of my very own. It’s a 2.2GHz Intel Core 2 Duo MacBook — and it’s everything I hoped it would be. As of Day 2, here are my top five reasons.

5. It’s black and sleek and elegant, like my cat — not to mention it matches most of my clothes.
4. It may be handsome, but it’s not showy.
3. Thanks to Parallels, it now runs Windows as a guest OS. Next up: Ubuntu.
2. It’s small and light, at least compared with other laptops I’ve known and loved. I hope to take it with me everywhere.
1. All in all, it feels very me.