Adding a multisite network to your local development environment can be a real pain. I wrote a script describing the major steps and configurations I use to get up and running. The goal here is to have the following sites set up in a local network for testing:
- http://ms1.test (The main network site)
- http://sub1.ms1.test (Subdomain site)
- http://sub2.ms1.test(Another subdomain site)
- Start MAMP PRO and go to the Ports tab. Choose the option Set server ports to 80, 81, 443, 7443, 3306 and 11211
- Go to the Hosts tab and create a new host. Select the site root directory – any empty writable directory is fine. Check “Install WordPress” when creating the host.
- Add your desired WP admin user info and your local database credentials in the following dialog screen, then click “Create Host”.
- Stop and restart your webservers in MAMP if they are not automatically restarted for you.
- Check your local database to confirm the database was created successfully, and confirm in the wp_options table that the site URL is correct.
- Go to http://ms1.test/wp-admin in a browser and log in using the admin credentials you already provided.
- Edit your site’s wp-config.php file. Add the following line:
define('WP_ALLOW_MULTISITE', TRUE);
- Reload the dashboard in wp-admin and go to Toolset > Network Setup. Select “subdomains” instead of subdirectories, and add your network title and admin email information.
- Copy the .htaccess code shown on the next page and save it into your site’s .htaccess file, overwriting any existing information. Disregard the other code and warnings shown on this page.
- Edit wp-config.php again. Remove or comment out the WP_ALLOW_MULTISITE line and paste the following lines just after it:
define('MULTISITE', true); define('SUBDOMAIN_INSTALL', true); define('DOMAIN_CURRENT_SITE', 'ms1.test'); define('PATH_CURRENT_SITE', '/'); define('SITE_ID_CURRENT_SITE', 1); define('ADMIN_COOKIE_PATH', '/'); define('COOKIEPATH', ''); define('SITECOOKIEPATH', ''); define('NOBLOGREDIRECT', 'http://ms1.test' );
- Save wp-config.php and return to MAMP PRO. Select the ms1.test host entry and find the Aliases panel. Add an alias for each subdomain:
sub1.ms1.test sub2.ms1.test
- Save and restart the webservers.
- Go to ms1.test/wp-admin, where you will have to log in again. Use the network admin credentials.
- Go to My Sites > Network Admin > Sites, and add subdomains here as separate network sites.
- Log in to each site’s dashboard from Sites > All Sites.