Some reasons that makes WordPress that immensely popular are it is easy to use, it is in very active development, it has great community support, many plugins with great functionality, beautiful themes, and one particular feature that makes it a powerful CMS is the ability to create multiple websites with one WordPress installation.
Originally, this WordPress Multisite was developed separately from the main WordPress. Then, the project has been merged since WordPress 3.0. So, if you are using WordPress 3.0 (and above), you are able to enable this feature and start creating multiple blogs. In this post, we will show you how to develop WordPress Multisite with MAMP, before bringing it online.
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
.Then, add the following line.
- define('WP_ALLOW_MULTISITE', true);
As mentioned, we will host our site with sub-domain. In the Network Setup setting page, check the Sub-domains option, and optionally you can name your network websites as well. Then, click on the Install button.
WordPress will generate some configuration lines to add in wp-config.php and .htaccess. The generated output will be slightly different than the one shown below, but the instruction remains the same.
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.Now, when we access the sub-domain we will get our newly created WordPress website.
That’s it; you can then create as many websites as you want, in the same way.
Plugins for Multisite
Additionally, you can install some plugins to power-up your website networks. Below are some of my recommendations.- Jetpack
- Multisite Admin Bar Switcher
- Simple Multisite Sitemaps
- Network Shared Media
- Multisite Language Switcher
- Simple Multisite Login Log
- Multilingual Press
- Multisite Taxonomy Widget
- WordPress Multisite Domain Mapping
Final Thought
The Multisite feature is an incredible addition in WordPress. By utilizing this feature, you are able to build blog or website networks like in Tutsplus.com and New York Times Blog directories. We can also create UGC (User Generated Content) website that is similar to Hubpages, Squidoo, Tumblr, and WordPress.com.We hope that this guide is useful for and can help you get started with WordPress Multisite.
0 comments:
Post a Comment