Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Image

Book Review: Drupal 7 Multi Sites Configuration 35

Michael Ross writes "All the leading content management systems (CMSs), including Drupal, use a combination of source code, in files, and user/configuration data, in a database. There may be some mixing of the two types of components — such as configuration settings stored in small files, or JavaScript code stored in the database — but most CMS-based websites generally employ this separation. One significant benefit is that updates to the non-custom code (the CMS's "core") can be easily made without overwriting user data or custom configuration settings. However, each website has its own copy of the core code, even if the websites reside on the same server — which wastes disk space and wastes developer time when all of those instances of core need to be updated. Thus there is growing interest in running multiple websites on a single core instance, despite the dearth of documentation for how to do so. For those in the Drupal world, one resource is a new book by Matt Butcher, Drupal 7 Multi Sites Configuration." Read below for the rest of Michael's review.
Drupal 7 Multi Sites Configuration
author Matt Butcher
pages 100 pages
publisher Packt Publishing
rating 8/10
reviewer Michael J. Ross
ISBN 978-1849518000
summary A tutorial on how to run multiple Drupal 7 web sites from a single installation.
Released on 26 March 2012 by Packt Publishing under the ISBN 978-1849518000, the book spans 100 pages, organized into five chapters. For developers familiar with the subject — particularly those who have read the (few) articles that cover Drupal multisite — it may seem inconceivable that such a subject could fill an entire book. Yet for the countless Drupal developers and administrators who have encountered critical problems in implementing the advice proffered in the aforesaid articles, a definitive book could be invaluable. Even a brief perusal of the book's table of contents will show that there are more topics to be covered than one might have imagined. This review is based upon a print copy of the book kindly provided by the publisher. An electronic edition is available as well. More details can be found on the publisher's page, where visitors will find an overview, a table of contents, a brief author biography, and links for purchasing the print and electronic versions of the book.

In the first chapter, the author presents the fundamental ideas and many benefits of basing multiple Drupal websites on a single code base, known as "multi-site hosting." He discusses the most common configuration options, and then focuses on the one used throughout the book, namely, Drupal's built-in multi-site capability. One thinks of Drupal (and any other PHP applications) as running on top of the web server layer (typically Apache); so readers will likely be confused by the statement that virtual hosting "is a layer higher than Drupal's multi-site feature" (page 8). Aside from that, the discussion is straightforward.

The second half of the chapter provides detailed instructions on two methods for setting up a server for multi-site usage. The first method utilizes virtualization, specifically VirtualBox and Vagrant, which supposedly are ideal for spinning up disposable websites. However, the instructions for "Installing our tailored Vagrant project" quickly become problematic: The MultiSite Drupal Vagrant Profile directs the user to perform a git clone command, and then "cd multisite_drupal_vagrant_profile," which works fine, as that directory exists. But the next step, on page 15 of the book, calls for the reader to cd into "multisite_vagrant," which does not exist. Was the aforesaid directory intended? Apparently so, as otherwise the third command, "vagrant up," fails. Windows users, at the very least, may find these steps and those that follow to be quite perplexing. In my case, both VirtualBox and Vagrant initially appeared to fail installation; yet upon trying them again, they were apparently running. But certain operations discussed in the book, were never executed. I slogged my way through numerous cryptic error messages, and eventually gave up. Any other reader who experiences anything similar may also chuckle at the author's claim that "This made it easy to get an entire server environment configured and running without dealing with the nuances of configuration" (page 17). The second method presented for setting up a multi-site environment is to manually configure Apache and MySQL. Even though this approach is probably what most readers will settle upon, it is sadly given a backseat to Vagrant.

In the second chapter, "Installing Drupal for Multi-site," the author explains how to perform the standard Drupal 7 installation, but for three example instances. For those readers unable to get the Vagrant method working fully, or who for some other reason choose not to use it, the author's frequent references to Vagrant will likely be increasingly annoying. Fortunately, it tapers off about halfway through the chapter, as the author explicates the details of multi-site configuration, concluding with some tips on where the reader can find assistance if she encounters any difficulties during an install. The only flaw is, on page 41, where the author states that "the lines that typically need changing are highlighted," but none of them are.

The complexities of sharing configuration settings among multiple websites, compose the first topic addressed in the third chapter. All of the technical information appears to be sound, except for the advice on page 46 to add the line "global $conf;" in the shared settings PHP file, which is included in the site-specific settings files. A "global" keyword would only be needed if the line setting the array value $conf['site_slogan'] were inside a function, in which case the variable $conf would have only local scope without the keyword. The PHP documentation on variable scope notes that, for a (non-global) variable, its "scope spans included and required files as well." (I confirmed this with a quick test, in which a shared settings file changed the slogans of two different websites.) The author then explains how to share modules and themes among multiple websites, or keep them separate. The chapter concludes with information on how subthemes in separate Drupal 7 instances can use a single base theme.

The fourth chapter, "Updating Multi-site Drupal," focuses on the administration of multiple websites sharing Drupal code. Readers will learn of the numerous pitfalls that can catch the unwary (or at least the inexact). The fifth and final chapter, "Advanced Multi-sites," continues the discussion of other factors that can complicate and undermine working off a single Drupal code base: favicons in themes, robots.txt files, shared authentication, shared content, and other topics that one may never encounter if only working with simple websites — but could be critical otherwise. The only readily apparent flaw is his referring to the project at http://drupal.org/project/virtual_site as "the Virtual Site module" (page 80), when in fact it is the Virtual Sites module — not be confused with the actual Virtual Site module.

Unlike most Packt Publishing books, this one contains relatively few errata: "served [a] few" (on the first "About the Reviewers" page), "start its" (page 17; should read "start it"), "Drupal looks for, for site configuration" (page 30), "trouble shooting" (42), and a missing ")" in the first sentence on page 67. Scattered throughout the book are several instances of title case used inappropriately when referring to generic concepts that are not proper names, e.g., "Version Control System" (page 10). Fortunately, all of these flaws are quite minor, and should have been caught by the publisher's production team.

Some of the narrative is a bit redundant, such as a question being asked at the end of one section, only to be repeated at the beginning of the next section, sometimes more than once. The (unneeded) chapter summaries add to the repetition, as do the introductory paragraphs of each chapter, many of which merely tell the reader what she just read in the previous chapter. Yet the author's narrative style is generally clear and easy to understand.

The main problem with this book is the VirtualBox and Vagrant pair — specifically, the (unjustified) heavy emphasis upon them, and the spotty instructions for configuring them, which could easily confuse and discourage readers. The information is mostly confined to the first two chapters, yet all of it should have been left out, or consolidated and relegated to an appendix — especially as most readers would not use Vagrant for their development environments, and probably no one would use it for a live production environment.

But for anyone interested in setting up multiple Drupal-based websites that share a single code base, these blemishes are of little consequence. Although modest in size, Drupal 7 Multi Sites Configuration provides the most thorough coverage to date of this worthwhile yet oft-neglected subject.

Michael J. Ross is a freelance web developer and writer.

You can purchase Drupal 7 Multi Sites Configuration from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

*

This discussion has been archived. No new comments can be posted.

Book Review: Drupal 7 Multi Sites Configuration

Comments Filter:
  • CTRL-F opcode (Score:5, Informative)

    by Anonymous Coward on Monday July 16, 2012 @05:46PM (#40666933)

    If the book is anything like the description, it entirely misses the point of a multisite configuration.

    I can use drush and with one command update multiple sites at the same time. I regularly update 20 sites with just "drush @all up" and it takes about 2 minutes. This would work multisite or not. Hell they wouldn't even need to be on the same server. If you're updating your site without drush, you're probably doing it wrong.

    Since I can rule out updating the site as a motivation, what *is* the motivation?

    Simply, efficiency for the opcode cache. You can *easily* feed APC (or xcache etc.) enough memory to completely cache all PHP on all the sites in a multisite. I'm doing so with 20 sites right now. If those 20 sites were not in a multisite config, each site would have its own copies of the same file, which is horribly wasteful when you're allocating ~64MB per site. When people make the mistake of thinking "oh, I have the php cache thingy", the biggest problem is that the default memory allocated to APC is 16MB, and for Xcache its also 16MB. This means that once the opcode cache runs out of memory, every file not currently stuffed into the insufficient space available is going to compile every time its used.

    Maybe they avoided mentioning Drush and the Opcode cache, assuming that readers would not understand what they were. Sadly, if you don't know what an opcode cache is and how to appropriately tune it, you are probably not the target audience for a book that focuses on Vagrant and VirtualBox.

    For anonymous sites, Nginx + php-fpm + APC + Memcache + Boost is an incredibly efficient way of setting up sites. Combine that with a multisite and you can host many sites on a budget VPS (I'm using Linode) and still get great pageload times because its all coming from cache, and if it needs to regenerate the cache it has plenty of power available with idle php-fpm workers + APC.

    For this reason, I find the focus on apache to be a bit sad. If the book does a "sudo tasksel" lamp stack install and uses mod_php, thats complete fail because of all of the additional overhead in the apache processes that are going to spend most of their time serving statically cached pages.

It is easier to write an incorrect program than understand a correct one.

Working...