My local web development tool of choice for Mac is MAMP. I’ve used it to create local WordPress sites for years. But, I had a hell of a time trying to get it to work with a WordPress Multisite. After a whole day of research, I finally got it to work though!
If you want the quick summary of the key points, here are the keys to getting WordPress Multisite to work on MAMP:
- You need clean URLs on MAMP to get it to work with Multisite. In other words, it won’t work if your development URLs look like this: 127.0.0.1:8888/mysite.com (see this article on how to get clean URLs on MAMP).
- Migrating a Multisite to a different domain (if you are doing that) is non-trivial. Even after doing a search and replace for the URL in the database, I had to hand-modify my wp-blogs table.
- I had to modify my DOMAIN_CURRENT_SITE setting in wp-config.php to get Multisite to work.
Now on to the details!
1. Get Clean URLs on MAMP
After a lot of struggling and research, I came to the conclusion that it’s basically not possible to set up WordPress Multisite on a local URL like this:
(If you have done it, let me know.)
So, the first step is to make your local URLs “clean” like this:
I wrote a whole article on how to get clean URLs on MAMP. If your URLs include the port number and/or a subdirectory as shown in the first example above, see that article, then come back when that’s all done and totally working for a regular WordPress install.
Note, if you’re not using subdirectories for your sub sites (i.e., you’re using different domains for your sub-sites), you’ll need to enter all of those domains in your local hosts file.
2. Install Your WordPress Site or Migrate it In
Once your URLs are clean and simple, it’s time to set up WordPress.
If you’re starting from a clean install, go ahead and install WordPress in your development directory. Verify that it’s working, then go through the steps in the Codex to convert it to a Multisite. At this point, the site should be broken, i.e., home page not accessible (at least that what’s happened to me). We’ll fix it in the next step.
If you’re migrating a Multisite from somewhere else, there are many ways to do this, ranging from using a plugin to doing it by hand. In either case, it’s non-trivial, so I’m leaving the details for you to find elsewhere, but I’ll tell you what I did.
I decided to use WP Migrate DB Pro plugin with the Multisite add-on. This is a paid plugin but it’s super handy. That involves installing WordPress and the plugin locally, then using it to pull the database, plugins, themes, and images from the site to be copied. Once copied, I went through the steps in the Codex to convert it to Multisite, and then my sub-sites showed up!
Using that technique, I discovered that the plugin’s search and replace wasn’t able to fix the wp_blogs table. You’ll have to fix that manually, but it’s pretty easy. For your base site, change the domain to your parent site’s domain and change the path to “/”. Change the other to the appropriate domain names and paths.
Another way to copy your Multisite is to manually copy over the files, then copy the database and do a search and replace on the database as described in the Codex. This is pretty advanced though, not recommended for beginners!
3. Fix wp-config.php
As I mentioned, after I did all of this, my Multisite’s home page was not resolving. I traced the problem to the wp-config.php settings.
If you go to your install’s Network Setup, it will tell you to use these settings:
define('MULTISITE', true); define('SUBDOMAIN_INSTALL', false); define('DOMAIN_CURRENT_SITE', '127.0.0.1'); define('PATH_CURRENT_SITE', '/'); define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE', 1);
For my Multisite install, I had to change DOMAIN_CURRENT_SITE to the domain name like this:
After I did that, my local Multisite install was working!!
Did this work for you? Please leave a comment or question below! – Brian