WordPress Multisite with MAMP 3 on OSX Yosemite 10.10.1

This post documents the steps necessary to set up a WordPress Multisite installation on OSX Yosemite with MAMP 3.

  • Note: This "tutorial" assumes the MAMP projects directory lives in your Mac's Applications folder (default)
  • Note: The procedure below will install WP Multisite in ./Applications/MAMP/multisite/ (cf. the DocumentRoot in step 5). The goal is to leave MAMP's default htdocs folder (in which I have quite some projects up and running) untouched.

Here we go:

Step 1. Create dir and database

  • Create a multisite directory in ./Applications/MAMP
  • Use PhpMyAdmin (included with MAMP) to create a new database, e.g. multisite

Step 2. Edit hosts file

  • Locate ./etc/hosts on your machine
  • Edit the file with nano (Terminal) or a text/code editor like e.g. Textwrangler
  • Add the main domain, and the subdomains you'd like to use:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1           localhost
255.255.255.255     broadcasthost
::1                 localhost 
fe80::1%lo0         localhost

127.0.0.1           multisite.local
127.0.0.1           one.multisite.local
127.0.0.1           two.multisite.local

Step 3. Flush DNS cache

Open the Terminal, type the following and hit enter:

$ dscacheutil -flushcache

Step 4. Enable virtual hosts

Edit ./Applications/MAMP/conf/apache/httpd.conf and uncomment (i.e. remove the # before) the line:

# Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

Step 5. Add an Apache virtual host

Edit ./Applications/MAMP/conf/apache/extra/httpd-vhosts.conf and add a virtual host:

<VirtualHost *:80>
    ServerAdmin webmaster@multisite.local
    DocumentRoot "/Applications/MAMP/multisite"
    ServerName multisite.local
    ServerAlias multisite.local *multisite.local
    ErrorLog "logs/multisite.local-error_log"
    CustomLog "logs/multisite.local-access_log" common
</VirtualHost>

The domain is now accessible via http://multisite.local:8888/

Step 6. Set Apache port

  • Open MAMP preferences
  • Set Apache port number to 80
  • Restart MAMP

The domain is now accessible via http://multisite.local/

Step 7. Install WordPress

  • Download the latest WordPress
  • Unzip the download and drop the contents of the wordpress folder in ./Applications/MAMP/multisite
  • Visit http://multisite.local/ to complete the installation.

Database connection details:

  • Database Name: multisite
  • User Name: root
  • Password: root
  • Database Host: localhost
  • Table Prefix: wp_

Step 8. Allow multisite

Edit ./Applications/MAMP/multisite/wp-config.php to allow multisite:

define( 'WP_ALLOW_MULTISITE', true );

Step 9. Begin network setup

Open a browser and visit http://multisite.local/wp-admin/network.php to begin network setup:

  • Choose option "subdomains"
  • Ignore the "Warning! Wildcard DNS may not be configured correctly!" message
  • Follow the on-page instructions (cf. steps 9a and 9b below)

9a. Configure multisite

Edit ./Applications/MAMP/multisite/wp-config.php and add:

define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
define( 'DOMAIN_CURRENT_SITE', 'multisite.local' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

9b. Configure .htaccess

Open ./Applications/MAMP/multisite/.htaccess (a hidden file) and replace its content with:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>

# END WordPress

Step 10. Log in

Reauthenticate by logging into WordPress.

Step 11. Create your network

Visit http://multisite.local/wp-admin/network/site-new.php to create new sites, e.g. (see subdomains configured in step 1):

  • one.multisite.local
  • two.multisite.local

Step 12. Have a beer

or some champagne if you like!