Powering 180+ domains with a single instance of Wordpress (w/o Multi-site)

Preview:

Citation preview

&

Scott McCollumExtension Information Technologyscott_mccollum@ncsu.edu | @scottmccollum

Mike VysockaExtension Information Technology

mike_vysocka@ncsu.edu | @thewebvy

1997

Through the years ...

2004

2005 2010

2012

● Thousands of pieces of content to move● Update and request new DNS entries● Setup tons of 301 Redirects, RedirectMatch● Actively communicate with users● Provide training for users

What did WordPress give us?

● A real Content Management System● Blogging: Point, Click, Publish● Core Updates● A huge user community ● ...

Could a single Wordpress instance, without any plugins, and just a single theme keep 100+ site owners happy

?

BUT …

and no, we’re not using WordPress MU

YES

184 domains created

strawberries

pender growingsmallfarms

www.ces.ncsu.edu

148 are live today.

mecklenburg

651 usershave published or edited content

19,000 pages/posts currently published

6,500,000 page views since launching July 1, 2012

As of April 2014 ...

October 25, 2013

We went mobile

* .ces.ncsu.edu domainsalamance - alexander - alleghany - als - anr - anson - ashe - avery - beaufort - bertie - bladen - blueberries - brunswick - buncombe - burke - cabarrus - cabbage - caldwell - calsleadership - camden - carteret - caswell - catawba - chatham - cherokee - chowan - clay - cleveland - colecrops - columbus - communitydevelopment - conference - cotton - craven - cucurbits - cumberland - currituck - cutflowers - dare - davidson - davie - duplin - durham - ebci - edgecombe - eggplant - energy - entomology - eod - espanol - evaluation - extensiongardener - fcs - fieldtoschool - floriculture - foodsafety - forsyth - franklin - gardening - gaston - gates - giving - graham - granville - grapes - greene - greenhousecrops - greens - growingsmallfarms - guilford - halifax - harnett - haywood - henderson - hertford - hoke - horticulture - hyde - intranet2 - ipm - iredell - jackson - johnston - jones - lee - lenoir - lettuce - lincoln - localfood - macon - madison - marketingtoolkit - martin - mcdowell - meatgoats - mecklenburg - mitchell - montgomery - moore - nash - nc10percent - ncce100years - ncchoices - nccommunitygardens - ncdisaster - ncstepstohealth - newhanover - northampton - northcentral - northeast - onslow - orange - pamlico - pasquotank - peaches - pender - peppers - perquimans - person - pesticidenews - pitt - plantpathology - poinsettias - polk - postharvest - poultry - poultry4hyouth - randolph - registration - richmond - robeson - rockingham - rootcrops - rowan - rubus - rutherford - sampson - scotland - shellfish - soils - southcentral - southeast - soybeans - spinach - stanly - state - stokes - strawberries - surry - sustainability - swain - sweetpotatoes - therapeutic-hort - tobacco - tomatoes - transylvania - tyrrell - union - vance - vegetables - wake - warren - washington - watauga - wayne - weeds - west - wilkes - wilson - yadkin - yancey

How does it work?

We use all 4th level domainssomeName.ces.ncsu.edusomeOtherName.ces.ncsu.edu... yes, we use 180+ of them.

You could easily do this for your domainmySiteName.myuniv.edumySiteName2.myuniv.edu... ^ and, they don't even have to be fourth level!

Using DNS, every sub-domain is aliased to the same server

http://wolfpack.ces.ncsu.edu

$_SERVER[“HTTP_HOST”]

echo preg_replace(“/\.ces\.ncsu\.edu$/”, ‘’, $_SERVER[“HTTP_HOST”] );// prints “wolfpack”

Keep it simple.Do your best to avoid one-off feature requests, use a common header / footer with only slight variations. Can the code you write be used on 10 or more domains?

lines of code in our theme’s functions.php file handle the edge cases, quirky requests, custom views, and self-imploding ideas our 650+ users have for their 180+ websites

1900

/* and about 15% of those lines are comments! */

Creating a new site is easy.1. We get a DNS entry for the new domaini.e. wolfpack.ces.ncsu.edu

2. We create a Wordpress user named wolfpack, just as you normally would. This creates an entry in wp_users

We use our campus authentication to supersede the native Wordpress login

But you could just as easily use OAuth, LDAP, htaccess, etc.

You could argue, this adds a layer of security.

But really, we're just using it so we can map multiple real users, real people and their logins to a single wordpress user.

3. We create an access table in the Wordpress database that will map organizational userIDs to a particular Wordpress username in the wp_users table.i.e. an email address, eXtensionID, unityID

user_id wp_user_login access_level

jesmith2@ncsu.edu wolfpack editor

jesmith2@ncsu.edu sweetpotatoes editor

brjohnson@ncsu.edu wolfpack admin

Having multiple folks sign in under the wordpress user ‘wolfpack’ makes author

attribution messy.

Use wp_postmeta table

4. Create another custom table with some meta data about each of your sites.

You can choose to leverage Wordpress' wp_usermeta table instead

Use native Wordpress functions (hooks, actions, filters)

● get_post_meta()● get_author_meta()● get_posts($args)● get_usermeta()

Or write your own ...● __get_site_type()● __get_site_name()● __get_author_ldap()

portal

county

county

if($siteType == ‘portal’){

get_full_banner();

}elseif($siteType == ‘county’){

get_color_block();get_small_banner();

}

1 theme, and a few small tweaks

the codethe visual

We put every WordPress author on an island

Use Wordpress' built-in filters and actions behind the scenes

● Centralized Google Analytics● Content Sharing● Content QA● Faster Feature Rollouts● Wider, Faster A/B Split Tests● Easier Access Control● One Stop Publishing

BIG Benefits to being under the same umbrella

Link to these slides:go.ncsu.edu/wordpress

How did we do?joind.in/9879

Recommended