the (very)
Large Side
of WordPress

Arūnas Liuiza

WordPress Core Contributor, WordPress Kaunas Meetup co-organizer, WordCamp (Lithuania, Riga, Stockholm, Jyväskylä, Oslo, Norrköping) speaker and one of the editors of the Lithuanian WordPress translation team and co-host of Kodo Poetai podcast.

 

Free & premium WordPress plugin developer

 

Software Engineer at

For Developers

deployer.seravo.com - a service that syncs WordPress plugins from GitHub to WordPress.org automatically.
 

TryoutWP.com - a service to spin up live temporary demo sites for WordPress plugins and themes.

Maintaining a WP site

  • Keeping up to date
    • Core
    • Vendor plugins and themes (on average ~13)
    • Custom plugins and themes (on average ~3)
  • Users (~5)
  • Content (~200)
  • Uploads (~300)
  • ...

Maintaining 10 WP sites

  • Keeping up to date
    • Core x 10
    • Vendor plugins and themes (on average ~13 x 10)
    • Custom plugins and themes (on average ~3 x 10)
  • Users (~5 x 10)
  • Content (~200 x 10)
  • Uploads (~300 x 10)
  • ...

Maintaining 100 WP sites

  • Keeping up to date
    • Core x 100
    • Vendor plugins and themes (on average ~13 x 100)
    • Custom plugins and themes (on average ~3 x 100)
  • Users (~5 x 100)
  • Content (~200 x 100)
  • Uploads (~300 x 100)

Plus

  • Server software
  • Backups
  • ...

Maintaining 30k WP sites

  • WP Core - from 1.5.1 to 5.2.3 (18.2%)
  • 12.9867 plugins per install
  • 22k unique plugin names
  • 58k plugin name+version combinations

 

​Data courtesy Peeter Marvet from zone.ee

Optimize!

Stage 1. Management SaaS

WordPress Management Software/SaaS

Stage 1. Management SaaS

  • Great for general housekeeping tasks
  • Very useful when sites are distributed on different platforms

 

  • Can get clunky as the number of sites grows
  • Requires a 'client' plugin on all the sites you manage

Stage 2. Multisite

  • Multisite mode in WordPress Core
  • Merged in 3.0 (used to be a separate WPMU project)
  • Allows to run a lot of WP sites from single codebase

Stage 2. Multisite

  1. For best results, use a fresh WP install
  2. Add one line to wp-config.php:
        define( 'WP_ALLOW_MULTISITE', true );
  3. Go to WP Admin > Tools > Network Setup and follow instructions

 

More details

Stage 2. Multisite

  • A good solution when all sites are hosted in single server
  • Data is stored in single database
  • All sites share plugins, themes and users table
  • Quite hard to move one site out

Stage 3. Multi Network

  • One step up from Multisite - a network of Multisites
  • Can be enabled via a plugin - WP Multi Network
  • Different networks have different set of network-enabled plugins and themes 

Stage 3. Multi Network

  1. Start with a Multisite WP install
  2. Install and enable a plugin - WP Multi Network
  3. WP Admin > Networks > Add New

 

More details

Stage 3. Multi Network

  • Gives you more flexibility
  • Still a single database and a single users' table
  • The very edges of WP codebase - you can run into bugs with cobwebs on them

Stage 4. Docker

  • The opposite of Multisite/Multi-network
  • Putting every site in a different container
  • Starting point for setting things up
version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress
volumes:
    db_data: {}
cd my_wordpress/

touch docker-compose.yml
# content here -->

docker-compose up -d

Stage 4. Docker

  • Better isolation between different sites
  • Can be easily split, moved to different servers, etc
  • Some resource overhead

Stage 5.

  • Shared WP Core
  • Separate wp-config.php ( databases, prefixes, salts, etc.)
  • Separate assets
    • Just uploads
    • Whole wp-content
$domain = $_SERVER['HTTP_HOST'];

// sanitize and validate here !!!
require_once( "wp-configs/{$domain}" );

define ('WP_CONTENT_DIR', __DIR__. '/assets/' . $domain );
define ('WP_CONTENT_URL','https://'.$domain.'/assets/' . $domain );

Stage 5.

Stage 5.

  • Single codebase - easy to maintain and update
  • Separated sites - no shared data, easy to move to different system/service
  • Plugins/themes sometimes have problems with this setup

No magic bullet

Different projects require different solutions

 

  • Management SaaS - great for client sites, distributed among different environments.
  • Multisite/multi-network work well when single user base is a feature, or at least not an issue.
  • Docker and other setups are mostly for projects on your own servers.

Bonus. WP-CLI

The official command line tool for interacting with and managing your WordPress sites.

 

Yup, the Terminal.

 

Official Handbook

Bonus. WP-CLI

# Download
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

# Try running it
php wp-cli.phar --info

# Make it executable and put into your PATH
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

# Try running again
wp --info

wp ... anything

wp config

wp core

wp cache

wp comment

wp cron

wp db

wp export

wp import

wp media

wp menu

wp network

wp option

wp package

wp post

wp post-type

wp profile

wp rewrite

wp role

wp server

wp sidebar

wp search-replace

wp site

wp super-admin

wp taxonomy

wp term

wp transient

wp widget

...

Update WordPress

wp core update

 

wp core update-db

 

wp core update-db --network

Install WordPress

wp core download --locale=lt_LT

wp config create --dbname=testing --dbuser=wp
--dbpass=securepswd

 

wp core install --url=example.com --title=Example
--admin_user=supervisor --admin_password=strongpassword --admin_email=info@example.com

Search & Replace

wp search-replace olddomain.com newdomain.com 'wp_post*'

 

  • works with serialised data
     
  • can do regular expressions
     
  • might be a little... slow :)

 

wp db search - another option

Remote commands

wp --ssh=[<scheme>][<user>@]<host>[:<port>][<path>] ...

 

  • You need a copy of WP CLI on the remote server
  • You need an SSH access to the server
  • You can also use vagrant, docker or docker-compose for schema

 

Questions?

the (very) Large Side of WordPress

By Arūnas Liuiza

the (very) Large Side of WordPress

WordPress Meetup Kaunas #42

  • 2,538