WordPress network in multiple environments with a single database

Problem

I needed a way in my multisite setup to have multiple environments that shared the same database, but used different domains.

  • server1.example.com
  • server2.example.com
  • example.com

… each of those would point to the same database. This is easy to achieve in a standard WordPress install using define( 'WP_HOME', 'http://server1.example.com' ); and define( 'WP_SITEURL', 'http://server1.example.com' );.

When you add multisite to the mix it breaks.

The problem is that the wp_blogs table defines the domains too, so I needed a way to define them in the config file.

Solution

UPDATE: A more complete solution: https://github.com/developdaly/WordPress-Skeleton

Taking @chrisguitarguy‘s advice, I used sunrise.php to intercept the host and spoof it so that WordPress uses domain I customize to load the site content.

Revisiting my development environment

Below is a graphical representation of what I’m proposing as a new development process/environment for my larger WordPress sites. I want your feedback.

This doesn’t include all the details. For instance, WordPress configuration files have to be customized for each server, database usernames should be specific to each environment, etc. But should this flow work?

WordPress Development Process

My OS X Frustrations

Three months ago I started using a Macbook Pro for work. I really love a lot of things about the hardware and the software, but being a Windows user in my previous life there have been a few things to get used to and some things I think are just really dumb.

No merge?!

Ironically, my biggest frustration began when I was actually trying to make backups of a ton of work I had completed over a three week period. Too bad OS X failed me at this point…

In Windows and most Linux distributions, copying a folder onto another folder results in a prompt to merge the contents of the folder, subsequently asking if you want to overwrite/replace existing files. That’s exactly what I wanted and expected. To my surprise, OS X replaces … i.e. DELETES everything in the folder being pasted to. Those files aren’t sent to the trash. There is no undo. They’re gone. End of story. Pissed.

Side note: maybe someone out there has a workaround for this (other than Terminal) If you’ve got a local WordPress installation that has versioned (SVN or Git) files then you can’t use the WordPress automatic upgrade. But it’s worse than that. You can’t just download a plugin and paste the new directory on top of the old plugin because you wipe out all the .svn directories, breaking everything.

Docking

I’m fortunate to have a nice Apple Cinema display with a Thunderbolt connector to simply dock my laptop. You’d think that having a pure Apple setup (laptop, display, connector, keyboard, mouse), everything native and setup as Apple would like you to have that everything would work seamlessly.

Instead, a third of the time I plug my laptop in and my mouse and keyboard don’t work and the only way to operate the setup is from the laptop itself. The only fix is to restart.

Headphones should be simple

This one baffles me because of how simple it should be. When I plug my headphones into the laptop and music is already playing through my monitor sometimes it doesn’t transfer to the headphones. Sometimes it does — no rhyme or reason. Unplug, plug, unplug, plug.

Windows isn’t perfect either…

Windows may not be as simple for people to use, but so far my experience is that OS X has more flaws. That surprises me, because the hardware and software are so controlled. Windows has the vulnerability of hundreds of OEMs, hardware stacks, many more third-party applications, drivers, and more. Despite all that, I have a less buggy and more expected experience on Windows.

The jury is still out though. I’m more easily frustrated because it’s new; the flaws are new to me. There may be just as many or more problems with Windows that I’ve just become accustomed to. After a few months I may follow up with a more experienced opinion.

HostGator needs you to use https, not git when cloning or adding submodules

Just a quick note that will hopefully save you some time. If you are trying to clone a GitHub repository using git:// you will run into fatal: unable to connect to github.com. You can switch to using the https:// protocol instead.

Further, submodules will need to be called with the git:// protocol as well. This was rather annoying because I had to delete my submodules locally, commit the changes, and re-add the submodule using the https:// protocol.

As annoying as that was to figure out, it’s working now so I’m happy.

You may end up needing a few other resources to figure it all out:

Fortune 100 Websites

I just started work for Santander Consumer USA last month. It’s my first taste of the corporate world, having worked for a startup company right out of college and then several years as a freelancer. Wanting to become more acquainted with the possibilities and/or restrictions in the corporate world I figured I might take a look at what the Fortune 100 companies are doing.

We’re all fairly used to poorly designed, out of date corporate websites. Corporations tend to stay behind the trend in web design whether it’s because they move more slowly, don’t recognize the need to keep up, have leadership that thinks they already have a work of art, or any other number of reasons. The bottom line is that a smaller company is more nimble and not only react to business changes more quickly, but customer’s expectations as well.

Which corporations are innovating on the web? Which industries see the most innovation? Can any lessons be learned?

2012 Fortune 100 Websites

The standouts are mostly websites that customers would tend to interact with more (i.e. shopping, account administration) rather than holdings companies or business to business focused sites. This certainly makes sense, and there’s little need for some of the businesses listed here to spend much time on keeping their branding fresh and website modern (best exemplified by Berkshire Hathaway).

Auto websites like General Motors and Ford are visually stimulating and modern, likely because their product branding changes so regularly and because they’re designers at heart.

Communications companies like AT&TVerizon, and Comcast are playing it safe, but they’re admirably modern (in their design, at least … not so much in user experience) for companies that so rapidly change their products and services.

Home improvement competitors, Lowe’s and Home Depot, seem equally equipped to make your weekend shopping experience easy, with Lowe’s pull slightly ahead.

Technology behemoths HP, Apple, IBM, Microsoft, Dell, Intel, Google should be a step ahead of the rest of the companies in this list because of their access to the right people. Some are clearly doing better than others.

http://exxonmobil.com

http://walmart.com

http://chevron.com

http://conocophillips.com

http://gm.com

http://ge.com

http://berkshirehathaway.com

http://fanniemae.com

http://ford.com

http://hp.com

http://att.com

http://valero.com

http://bankofamerica.com

http://mckesson.com

http://verizon.com

http://jpmorganchase.com

http://apple.com

http://caremark.com

http://ibm.com

http://citigroup.com

http://cardinal.com

http://unitedhealthgroup.com

http://kroger.com

http://costco.com

http://freddiemac.com

http://wellsfargo.com

http://pg.com

http://adm.com

http://amerisourcebergen.com

http://intlfcstone.com

http://marathonpetroleum.com

http://wallgreens.com

http://aig.com

http://metlife.com

http://homedepot.com

http://medcohealth.com

http://microsoft.com

http://target.com

http://boeing.com

http://pfizer.com

http://pepsico.com

http://jnj.com

http://statefarm.com

http://dell.com

http://wellpoint.com

http://caterpillar.com

http://dow.com

http://utc.com

http://comcast.com

http://kraftfoodscompany.com

http://intel.com

http://ups.com

http://bestbuy.com

http://lowes.com

http://prudential.com

http://amazon.com

http://merck.com

http://lockheedmartin.com

http://coca-cola.com

http://express-scripts.com

http://sunoco.com

http://enterpriseproducts.com

http://safeway.com

http://cisco.com

http://searsholdings.com

http://thewaltdisneycompany.com

http://johnsoncontrols.com

http://morganstanley.com

http://sysco.com

http://fedex.com

http://abbott.com

http://dupont.com

http://google.com

http://hess.com

http://supervalu.com

http://unitedcontinentalholdings.com

http://honeywell.com

http://chs.com

http://humana.com

http://goldmansachs.com

http://ingrammicro.com

http://oracle.com

http://delta.com

http://libertymutual.com

http://wfscorp.com

http://newyorklife.com

http://paalp.com

http://tiaa-cref.org

http://aetna.com

http://sprint.com

http://newscorp.com

http://generaldynamics.com

http://allstate.com

http://hcahealthcare.com

http://americanexpress.com

http://tyson.com

http://deere.com

http://murphyoilcorp.com

http://pmi.com

http://nationwide.com