Ok. Things are working as the title hints, but only sorta.
I haven’t been online with any web thing for a long time in internet space-time. I’ve been doing other stuff, and getting some different perspectives, but that’s for future stories. These are the technical notes that I am adding to my collection as I rescue my dumpster fire of a journal.
I started making notes in a google doc at the beggining, so the final will be a fun collection of technical and creative brain dumps as i piecemeal this site back together. The original was a sub-directory WordPress Multi-site or Network. I really do not want that structure work for my personal site anymore. I’m glad for the hyperdb domain routing experience, but I’d rather not for my personal junk.
It’s been my digital online sketchbook for almost 30 years. At it’s root is most of the work that got me started, and the words, images, sounds, and vision of it all has kept growing. I did loose a few things, but I might even find those memories too. Here’s my technical journey to get HERE.
I’ve been in Docker-land for a few years as a neighborhood front-end web monkey on WordPres, Drupal, and the Next—NextJS/ReactJS/Svelt thing that appears, so I was already getting a head-full of AI infused local git driven development. I had to find a good method for my mess. Looking at DDEV as a starting point seemed like a great idea with limited funding, and so far it was. These notes go through how I got my old WordPress Multisite network up and running on DDEV and brutally converted it back to a single WordPress site.
I’m going to knock out the prerequisites first and fast. It’s all Terminal commands on MacOS. Homebrew is installed with supporting libraries for DDEV The first goal is to get a WordPress site up and running with ddev. It goes something like this:
https://ddev.readthedocs.io/en/latest/users/install/ddev-installation
brew install ddev/ddev/ddev
mkcert -install
mkdir swampthings-docker-local-mu
cd swampthings-docker-local-mu
ddev config
[Answer ddev setup]
Ddev start
Now we get to the fun part getting the WordPress Multisite network up and running. I went through a few AI hunts and ole Google queries, but getting the config for NGINX was getting beyond me and too technical. For this ole-schooler it was good to know that you could push Apache as the default web-server with DDEV using this command:
ddev stop (yea make sure)
ddev config --webserver-type apache-fpm
Aha! Now with Apache dialed in, we have that simple .htaccess file for majic routing or the WP site which makes a WordPress directory based multisite easy to set up.
Bring it back up.
ddev start
So you should have a local Docroot that you’ve configured with ddev, and in that folder you should find the wp-config-ddev.php file. This is where you will put the WordPress Multisite configuration options. This is a typical advanced WordPress Multisite or Network setup, but the WP Config file is different for DDEV. For this setup the file is: wp-config-ddev.php. You will start with:
define( 'WP_ALLOW_MULTISITE', true );
Which will activate the Tools > Network Setup options. Once this option is available you can select the subdirectory setup options, and you will get two sets of configuration settings.
The first is your WordPress wp-config-ddev.php options for multisite which might look like:
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
define( 'DOMAIN_CURRENT_SITE', 'mysite-local.ddev.site' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
The second set of configuration settings are for Apache, and need to go into the .htaccess file located in the site root like so:
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
So now when you login to the WordPress Dashboard for your local DDEV site, you will see the multisite options and the Network Dashboard area where you can create sites. I ran my local through a few site setups and checked the database using the credentials found using this command:
ddev describe
This gives a full description of the local ddev site and how I was able to interact with site and data to fix things.
Now I confirmed the setup and the database structure, so I did a series of grep find and replace methods to get things working locally mostly as they did on the orginal swampthings.org site. The local test site host was definitely unique with a name like swampthings-docker-local-new.ddev.site. DDEV documentation give great options to control such things if you need.
As I dug into working to strip out my portfolio sub-WordPress site and start from that individual site I came across the very useful WP-CLI plugin from the folks at 10up, https://github.com/10up/MU-Migration
Now I could use DDEV to output my old portfolio work into a separate exported set of configuration files that I could use as the basis for a new site.
Now we get the process of changing all those old blog.dir referenced images from the old WordPress multisite image directory to using the WordPress default uploads directory. Using the 10up plugin with a focus on a single site, I was able to use my previous WordPress multisite originally located at /portfolio as the root site. I can extract individual sites, work with them separately, then recombine them.
I created a new DDEV WordPress site using the basic WordPress set up as a single site. I can now get very specific with the WordPress multisite tables, how they are converted, then how they are exported, and finally how the data is imported into the new single WordPress site.
Sound confusing enough? Good! Here is the collection of DDEV commands including wp-cli and 10up wp-mu migrate commands that I used to piece things back togehter.
# Install the 10up MU-Migrate plugin into the ddev web container
ddev wp package install 10up/mu-migration
# 10up wp-mu-migrate command to spit out a site into a local archive
ddev wp mu-migration export all subsite.zip --blog_id=2 --path=webroot
# Export a local DDEV WordPress site database.
ddev export-db --file=swampthings.sql.gz
# Import that messed up database file after you’ve rgexed it to death.
ddev import-db --file=swampthings.sql
# Image rebuilds seem to have been needed on the old WP Multisite as well as the new single WordPress site.
ddev wp media regenerate --path=./webroot
# Joy! These I found a necessary addition later.
# WordPress Database Repair
ddev wp db repair --path=webroot
# The last one might throw some database errors, so I had to do some table conversions like:
ALTER TABLE wp_commentmeta ENGINE=MyISAM;
ALTER TABLE wp_terms ENGINE=MyISAM;
ALTER TABLE wp_users ENGINE=MyISAM;
ALTER TABLE wp_usermeta ENGINE=MyISAM;
# I rerun the db repairs and the media regeneration scripts after the conversions.
Yup. At this point I don’t have any step by step. Remember this is a weird idea originally, so piecing it back together is proving interesting. So far with careful text search and replace I was able to get a single WordPress site with images relocated.
As I end these notes now. I have a working site on my local with all of my old website posts and images working, AND I was able to get it imported into a new website at my old host Dreamhost with little problems except for my Google/Squarespace DNS ugliness. The remaining work has been manual. This is a small old easy to curate site. In many casses I did need to re-link images by re-uploading them using: https://wordpress.org/plugins/enable-media-replace/
Every old post and page needed to be converted from classic editor to block, and of course most external files were also re-linked.
I do know there are better resources for moving WordPress sites and content into and out of networks, but this might show a place to start. Besides I know those tools are commercial. I will also note that this does not include the conversion of my old theme to a Twenty Twenty Four child theme to do fun Full Site Editing experiments. I did get a page for a redirection of Caidy’s cuttingupwithcaidy.com to a nice landing place. The Web has been my ugly digital sketchbook for a while, I wonder what my next journey holds.
If any of this is useful, then great! I hope it can start a good prompt for an AI.
If you got this far, then “Yes”, this is also a ridiculous way to test design and tech with long titles and strange formatting. I’ll probably test the posts on the social media channel you use to see where that pipe goes and what it looks like.
Have fun!
Leave a Reply