Running multiple Magento stores on one install.

References

Notes

  • This assumes a standard LAMP setup. In our case, Ubuntu 10.04 LTS, Apache 2, MySQL 5 and PHP 5.3.
  • It’s necessary to create some symlinks on the filesystem, so you’ll need access to do that. You don’t really want to be trying to run Magento
    on a shared host anyway, so this shouldn’t be a problem.
  • The stores are on different domains, although the principles are the same if it’s a subdomain, subfolder or other configuration.

Magento is powerful and flexible, but not terribly well documented, so figuring out the best way to accomplish something can take some digging
and some experimentation. I needed to set up two stores to run off the same Magento installation as two catalogues (one a subset of the other)
from the same retailer.

There are two broad approaches:

  • A single VirtualHost with aliases for the various domains, with logic added to the root index.php to decide which store to load.
  • A VirtualHost for each domain, linked to one core Magento installation.

I took the multiple VirtualHosts approach, as it seemed a little more logical to me (a matter of taste, really). It has the advantage of each
domain having its own .htaccess, which might be handy if you’re doing other things alongside Magento.

When running multiple stores from one Magento instance, they all share the same back office and catalogue. Once you set up a second website,
store or view then anywhere they need to differentiate the option appears to use the default config or to apply a site- store- or view-specific
setting. This means that themes and extensions for the various stores all live together.

A side note: websites, stores and views

You’ll need to decide whether your new store is a whole new website or a new store of the same website. Broadly
speaking, from the point of view of what the customer sees:

  • Websites are separate entities
  • Stores are distinct but share customer accounts and shopping carts
  • Views may be the same store in a different language or layout

Although that’s pretty configurable. Websites can be set to share customer accounts, for example. And, again, they’ll all share the same admin and
catalogue.

In this case, we went for two distinct websites.

The method

  1. Create a new root category for your new website. You can put a full category tree under it and add products to the categories.

  2. In the control panel, go to System > Manage Shops and create a new website, then shop for that website and view for that shop. Take note of the
    code you assign to the website – you’ll need it later. Assign your newly-created root category to the new store.

  3. Create a new VirtualHost for the new website. Note that the Magento files will need to be accessible to PHP from this VirtualHost,
    so pay attention to any restrictions on your server.

  4. In the new VirtualHost block, you need to set two environmental variables:

    SetEnv MAGE_RUN_CODE "your_new_website_code"

    SetEnv MAGE_RUN_TYPE "website"

    If doing this in the VirtualHost is a problem, your server configuration may allow you to do it in the .htaccess file below.

  5. Copy index.php from the document root of the existing site to the document root of the new site. Find and modify the following variables to point
    to the files in the Magento installation:

    • $compilerConfig
    • $mageFilename
  6. Copy .htaccess from the existing document root to that of the new site. Check it for any hostname-specific rules that have been added, and
    modify them as necessary.

  7. Create symlinks of the following folders in the existing site’s document root to the same locations in the new site’s document root:
    • app
    • errors
    • includes
    • js
    • lib
    • media
    • skin
    • var

    For example, ln -s /path/to/existing/document/root/app /path/to/new/document/root/app.

  8. In the control panel, go to System > Configuration > Web, select hte new website from the dropdown in the top-left corner, uncheck
    Use Default by the Unsecure and Secure Base URLs, then correct the URLs set to those of your new website.

  9. Reindex everything.

  10. Optionally set the theme for the new site under System > Configuration > Design.

  11. Job done.

If, after doing this, the home page of the new website is showing a default Magento 404, then check that the code for the new website
is set exactly the same in the control panel and in the server environment variable. A typo in the control panel setting lost me 45 minutes.
That was frustrating.

Also note that as we’ve edited a core file or two (index.php and maybe .htaccess), keep an eye on them if you upgrade your Magento instance.

Ten.

Ten years ago today I married the best person I’d ever met.

Ten years later, she still is. I don’t expect that to change.

Ten years includes some of the best times in my life, and some of the most difficult. At the highest and at the lowest, I haven’t been alone. The person I have most wanted to have there to share the joys and to help me through the sadnesses has always been there. No exceptions.

Ten years ago, I felt like a child pretending to grow up. I still do. I don’t expect that to change, either.

I have ten years’ more knowledge and experience of the fact that nobody’s perfect. Especially me.

Ten years have proved to me what I believed then: life is hard, but worth it.

After ten years, there are now four of us. And a dog.

Ten years ago I couldn’t have imagined what life would be like now. And I love it.

Ten years ago, I loved her.

Ten years into this, I love her, but I understand better than I did then what that means.

Ten years have been spent realising and marvelling at how lucky I am.

Ten years is a long time. Ten years is no time at all. It’s the beginning.

Prose.

The man holding a sword near Barnes’s throat was a creature worn down almost to the nub, like a pencil eraser with just enough pink rubber left to make one final correction.

Yikes.

Our house, this afternoon.

Mother: “What are you eating?”

Child: “A little bit of snot.”

Stationery.

Stationery

A birthday, and the attendant (generously given, gratefully received) gifts have led to a few new things to feed my not-so-modest stationery addiction. Pictured here, a hint of the Field Notes subscription and the new most stealthy and gruntingly manly fountain pen to join my pen case, the limited edition, all matte black Pilot Capless (Namiki Vanishing Point in some markets) retractable, clicky goodness. It’s very nice, and really needs to be seen in person. Black as black as black.

Joel Ian James Goody

Born on Monday morning, all 6lb 2oz of him.

On having chosen a DNS host.

Further to my previous post, I ended up going with Nettica. A friendly enough control panel, and a quick and easy to base service makes for sufficient happiness.

I did have my first experience with their support team today (I should clarify that it wasn’t a problem needing solved; rather, it was to do with transferring DNS for a domain between two Nettica accounts), and they were quick and helpful. Happy there for now, then.

On choosing a DNS host.

There can be several moving parts to a website. Three big ones are the domain name (the .com address), the hosting (the space on a hard disk somewhere where the website lives, from which your web browser will download it) and the DNS (the Domain Name System which translates the human-friendly .com address to the string of numbers — soon numbers and letters — that computers need to find the hosting).

From a management point of view it’s often easiest to have all three of these handled by the same company, and that’s a very common setup. I’m not too keen on the “eggs in one basket” feel of that, though, and I tend to have the domain name and the hosting for any given website in different places, with the DNS taken care of by one or the other.

I have domains registered all over the place, so keeping track and making updates takes a little bit of doing. I was also thinking about getting in a complete separation, with DNS taken care of by a third provider.

So, I tweeted:

Contemplating a specialist DNS host, rather than scattering amongst domains’ registrars. DNSMadeEasy, DNSimple, who else should I look at?

I got quite a response back, both from friends and colleagues and from DNS hosts who were watching the tweets go by. My research into possible hosts, partly informed by the twitterly response, turned up a number of possibilities.

DNS Made Easy

The first of the two I was vaguely aware of, DNS Made Easy comes recommended by Aaron, who is a difficult man to please. They also sent me a friendly, not too pushy, tweet or two. For my needs, I’d be looking at US$60 a year, probably plus a few US$2s per year for domains beyond the 25 included in that price.

DNSimple

DNSimple was the other one I kind of knew about, although I can’t remember who recommended them to me. A bit more expensive than DNS Made Easy, at US$10 per month. However, that’s for 50 domains and they have a bunch of other useful features and offer a broader range of records for the DNS. They, too, sent me a friendly tweet.

Dyn

Two separate Dyn reps jumped on my tweet. The second one was a little intense. I emailed the first guy to see which of their offerings would suit my needs. They offer a few nice features, especially around import and export of sets of records, but US$95 per month is a fair bit more than I was planning on spending. (Dyn are the folks behind DynDNS, which I have a paid account with as well. That’s a good service, but not quite the same thing as I’m looking for.)

Nettica

David chimed in with a recommendation for Nettica. Their Bulk DNS service sounds pretty great, especially the template setup and the straightforward-as-a-straightforward-thing US$50/50 domains/year pricing.

Hover

Stuart, supported by Ryan, really likes Hover. It’s not really what I’m looking for, though, as it’s a registrar with good DNS management. I’m not looking to shift domain registration at the moment, and it misses the separation I’m after.

Amazon Route 53

Amazon’s Route 53 is part of the Amazon Web Services lineup, and I kind of half expected it to be the answer I was after. Pricing of US$1/domain/month, plus low per-request charges, place it at the higher end of the mid-price range. However, there’s no control panel — everything is done with straight API calls by feeding a little Perl script with XML. While I may be intrigued by the possibility of writing a decent client, I don’t want to have to faff about with that in the meantime.

Conclusions, then

I have none solid, yet. Hover’s out, as it’s not really what I’m after. Dyn is too expensive and Route 53 is too fiddly. That leaves DNS Made Easy, DNSimple and Nettica. All the services make nice, reassuring promises about uptime, with a couple of solid guarantees in there, but everyone has downtime sometimes. I’m working on the basis that a reputable provider will manage it acceptably.

My decision would be an approximate toss up between the first two, with a slight bias to DNSimple for their wider range of services, but I am intrigued by Nettica’s Bulk DNS service. A little more research is in order, then. Shifting a whole bunch of domains around is too painful to want to do it more than once.

Credit where due.

Some industries get a bad reputation; telecoms, including ISPs, is one of them.

For almost five years we got our broadband from Zen. They aren’t the cheapest out there, but they provided us with a solid service that I can only recall flickering once or twice in all that time. When necessary, their staff were helpful and pleasant.

When fibre hit our area we ended up moving away from Zen (BT seem to offer the best balance of cost and features on the service). I expected to be paying an extra month’s charges for the 30 day notice period on our contract. Instead, they sent me a statement saying I was £16 in credit with them. Today I received another letter, asking for bank details so that they could send the £16.

I suppose it shouldn’t be remarkable that a company is offering to refund a customer money that they overpaid, but it is. So, well done to Zen.

Tuesday Tunes: I Am The Doctor

For an SF nut, I never really got Doctor Who. I remember watching Peter Davison and Sylvester McCoy when I was a kid, but don’t remember them as being very good.

The current, eleventh, Doctor has really grabbed my attention, though. I’ve been well and truly sucked in, and it’s some cracking TV. The BBC has been making some interesting science fiction over the last few years. Russell T Davies, the showrunner for the previous two modern Doctor Whos (Eccleston and Tennant) seems to have had something to do with bringing the genre back into the mainstream, landing Doctor Who on Saturday evenings, then getting more mature with Torchwood (Children of Earth was a stormer).

Today’s tune (the first here in quite some time) is from the soundtrack of last year’s series of Doctor Who. It’s from the first episode, and introduces the Eleventh Doctor’s theme. The soundtrack for the series is very high quality, and this is probably its high point.

“I Am The Doctor” [Spotify]