Guide to WordPress Multisite with MAMP

Make sure you have installed MAMP in your OSX. Otherwise, follow this instruction before proceeding this post.
Step 1: Setting-up Virtual Host
We will first setup Virtual Host so that we can host the website with a custom hostname or domain name, instead of using the defaulthttp://localhost:8888/. To do so, we will need to edit two files, the hosts file and the apache config file, httpd.conf.Step 1.1: Adding a Hostname
Frist, we will add a hostname for local development in thehosts file. The hosts
file is a plain text file to map the hostnames or domain names to their
associated IP Address. When we try accessing a hostname (or a domain
name) through the browser, the Operating System (OS) will first look-up
the hosts file for the corresponding name and its IP address. If it is not available within the file, the OS will then look-up the DNS.
Recommended Reading: Domain Names & Hostnames
So, let’s open the Terminal and run the following command to open the hosts file.- sudo nano /etc/hosts
domain.local, as follows.- 127.0.0.1 domain.local
Furthermore, If we host the sites using sub-directories adding the above line will be sufficient. However, since we are going to use sub-domain for hosting the sites, we need to add one line to specify a sub-domain, like so.
- 127.0.0.1 domain.local
- 127.0.0.1 sub.domain.local
hosts file. Then, press Control + X to exit.Step 1.2: Directing the domain names
Next, we will direct the hostname to the directories where we will install the WordPress. To do so, we need to edit the Apache HTTP Configuration, which is located in Applications/MAMP/conf/apache/httpd.conf.For your convenient run the following command through the Terminal to open it in TextEdit.
- open -a TextEdit /Applications/MAMP/conf/apache/httpd.conf
httpd.conf file, add the following line to
specify the directory where the hostnames, which we have just added,
should refer to it. In my case, I will install my WordPress at /Users/thoriq/Sites/wordpress.- <VirtualHost *>
- DocumentRoot "/Users/thoriq/Sites/wordpress"
- ServerName domain.local
- ServerAlias domain.local *domain.local
- </VirtualHost>
Step 2: Installing WordPress
Installing WordPress is as easy as pie. There is the documentation and a lot of posts that shows you how to install WordPress locally with MAMP. For your convenient, here are a few links to visit.- Installing WordPress Locally on Your Mac With MAMP — WordPress.org
- WordPress for Mac: How to Install Locally with MAMP [Tutorial] — WPMU.org
- If you prefer video over text-based tutorial, then this is one for you: Install WordPress locally using MAMP — Youtube
DocumentRoot in httpd.conf file. So, you are able to access it through the domain name, as shown below.
Step 3: Enable Multisite
The Multisite feature is not activated by default, but we can enable it easily. First, let’s open the WordPressconfig.php.
- define('WP_ALLOW_MULTISITE', true);


Add these lines in
config.php- define('MULTISITE', true);
- define('SUBDOMAIN_INSTALL', true);
- define('DOMAIN_CURRENT_SITE', 'domain.local');
- define('PATH_CURRENT_SITE', '/');
- define('SITE_ID_CURRENT_SITE', 1);
- define('BLOG_ID_CURRENT_SITE', 1);
.htaccess- 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]
Step 4: Creating Multiple Websites
We just need to create the websites. So, let’s login to the dashboard.In the admin bar, go to My Sites > Network Admin > Sites menu. Then, click on the Add New to create the website using the sub-domain name that we have added in
hosts file, like so.





0 comments:
Post a Comment