I wanted to run Mutlisites to host many sites that are NOT all sub-domains but many different website domains for webhosting.  I found that multisites by its self was not setup to do this well.  The plugins available do not really accomplish this ether.  You need a very special set of work-arounds.  I came up with a few on my own and found others scattered in the corners of the Internets (Bush).  I have created this step by step walk-through to help you set this up.  This guide is NOT for the meek.  You must have a pretty firm idea of what you are doing.  If you do not already know how to setup and use a WordPress site then please go do that FIRST.

 

What I am running…

Ubuntu Linux Apache: 2.2.17 – Running virtual domains and mod_rewrite PHP: 5.3.5 WordPress: 3.5.1 Networks for WordPress: 1.1.4  

Instructions…

  1. Install Vanilla WordPress
    • Notes:
      • This setup is designed to run under the www. subdomain of your primary domain.  For example “www.desktopmasters.com” NOT “desktopmasters.com”.
        • Note: Your site may redirect and remove the “www” portion until further down when we build the .htaccess file that has redirects in it.
      • Make sure you type your URL’s in lower case in your configuration ALWAYS or it will break/kill your site later with no explanation (pain)
      • Make sure your Web Server supports Mod Rewrite and has it enabled.
    • A fresh install with no plugins.
    • I like to install Site Offline or Coming Soon plugin just to keep people from looking at the site till it is ready.  This will not affect your setup.
    • Disable ALL the plugins.  I also remove the default ones that install with the site.
  2. Allow Multisite
    • Note: My source document for this: http://codex.wordpress.org/Create_A_Network
    • In the root of your site edit the wp-config.php
    • Look in the file for: /* That’s all, stop editing! Happy blogging. */
      • Note: anything between /* and */ is a remark and ignored by the code of the site.
    • Just Above the “Happy Blogging” line paste in the following lines:

      #-- [ MultSite ] -------------------
      define('WP_ALLOW_MULTISITE', true);
      #-----------------------------------
      									

    • All of the following settings added to this file will be put between those lines for tracking reasons.
    • Note: Remember to save.
  3. Enable the Network
    • Menus: “Tools” -> “Network Setup”
    • Select “Sub Domains
    • [Install]
      • Note: If you see the following error you can likely ignore it.  “”Warning! Wildcard DNS may not be configured correctly! The installer attempted to contact a random hostname (_____________) on your domain. To use a subdomain configuration, you must have a wildcard entry in your DNS. This usually means adding a * hostname record pointing at your web server in your DNS configuration tool. You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.
  4. Updating the configuration files…
    • Important Note:  Do NOT use the configuration info the website supplies to you.  Instead use the info that I give you…
    • Edit the wp-config.php and make the Multisite section look like this…

      #-- MultSite -------------------
      define('WP_ALLOW_MULTISITE', true);
      define('MULTISITE', true);
      define('SUBDOMAIN_INSTALL', true);
      
      define('DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST']); //-> This is important. This is what cloaks the primary domain.
      
      define( 'SITE_ID_CURRENT_SITE', 1 );
      define( 'BLOG_ID_CURRENT_SITE', $siteRow['wp_blog_id'] );
      
      define('PATH_CURRENT_SITE', '/');
      
      define('UPLOADBLOGSDIR', 'wp-sitecontent');
      define('UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/" );
      define('BLOGUPLOADDIR', UPLOADBLOGSDIR . "/{$wpdb->blogid}/");
      
      # Tweaks..
      define('WP_DEFAULT_THEME', 'twentytwelve'); //-> Sets the default theme
      
      # For Contact Form 7 to make all the sites use the same folder outside the uploads folder
      define('WPCF7_CAPTCHA_TMP_DIR', 'wp-sitecontent/wpcf7_captcha' );
      define('WPCF7_CAPTCHA_TMP_URL', '/wp-sitecontent/wpcf7_captcha' );
      
      #define('UPLOADBLOGSDIR', 'wp-content/uploads/sites/'.$blog_id.'/' );
      
      #----------------------------------
      									

    • In the root folder edit (or create and edit) the .htaccess file and add the following (If a WordPress section exists replace it) DO NOT SAVE TILL YOU HAVE READ THE NOTES BELOW… 

      <IfModule mod_rewrite.c>
        RewriteEngine On
      
      #Redirect all users to access the site WITH the 'www.' prefix
        RewriteCond %{HTTP_HOST} !^www\. [NC]
        RewriteCond %{HTTP_HOST} !\.([a-z-]+\.[a-z]{2,6})$ [NC]
        RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
      
      # BEGIN WordPress
        RewriteBase /
        RewriteRule ^index.php$ - [L]
      
      # Switch to network site
        RewriteCond %{HTTP_HOST} !^www.<yourdomain.com>$ [NC]
        RewriteRule ^wp-admin/network/(.*)?$ http://www.<yourdomain.com>/wp-admin/network/$1 [R=302,L,QSA]
      
      # add a trailing slash to /wp-admin
        RewriteRule ^admin/?$ /wp-admin [QSA,L]
        RewriteRule ^login/?$ /wp-login.php [QSA,L]
        RewriteRule ^register/?$ /wp-register.php [QSA,L]
        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]
      
      # END WordPress
      </IfModule>
      									

    • Notes:
      • In the above .htaccess text there is a section to redirect you to the www subdomain if you access the domain directly.
      • IMPORTANT IMPORTANT: In the “Switch to network site” section replace the TWO tags with your website domain.  This includes (remove) the greater and less then sign.  This section is important.  If you are on another multisite domain and you choose to go to the Network in the my “My Sites” area to install plugins it will not automatically switch to the master domain.  These two lines resolve that. If you forget to do this your whole site will break and 404 error.
  5. Turn on and configure your Under Construction / Coming Soon page.
    • If you installed that plugin earlier then you will want to enable, configure this and turn it on.  Modifying the HTML can be a little tricky.  A trick to test it is to use another web browser like IE or FireFox or Chrome separate from from the browser you are configuring the site in.  This way you do not have to login and out to test it.
  6. Create a Must Use folder
    • In your wp-content folder create a folder called mu-plugins so you will have <site root>/wp-content/mu-plugins
    • Note: This is an awesome little folder.  Any php scripts put in here (properly) are automatically exulted by the site like a plugin.  This is a very low level code location. We will be putting some hacks in here to fix some issues.
  7. Add Must Use Folder Hacks
    • Download this file, unzip it, and place it into the mu-plugins folder.  This will make sure that the uploads folder is placed in a subfolder under the Site ID.  Without this all sites will share the same uploads folder and you will be screwed!  This will run like a plugin but requires no activation. Simply put it into the folder. 

        fix-uploads.zip (780 bytes, 613 hits)

  8. Create symlink to uploads folder.
    • Note: The idea here is to replace the uploads folder or relocate it to a more reasonable location.  You could move the uploads folder but just in case I like to create a symbolic link to it just to make sure there is compatibility.  We put settings into the config file to support this.
    • cd into your main website folder and create a symbolic link with this command.
      • ln  -s   wp-content/uploads/  wp-sitecontent
    • When you create a new site it will create a numbered folder in the wp-sitecontent folder to go with the site.  it will also create a “files” folder under that.  I do not like using the files folder so I manually remove it by editing the sites settings from the network site manager.  Look for the “uploads” variable and backspace the “/files” out.  Do this at the time you create the site.  I have not figured out how to prevent that from happening through the configuration.
  9. Create captcha folder.
    • in the wp-sitecontent folder create a subfolder to contain your captcha files for Contact Form 7.  If you want captcha to work (Really Simple Captcha) then you need this folder to go with the settings we created in the wp-config.php file.
      • mkdir  wpcf7_captcha
  10. In the below list of plugins I will be adding to this and breaking it apart into categories.  Install the following plugins….
Plugins
WPMS Site Maintenance Mode – Provides an interface to make a WPMS network unavailable to everyone during maintenance, except the admin. HomePage: http://wordpress.org/extend/plugins/wpms-site-maintenance-mod Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=wpms-site-maintenance-mode
Networks for WordPress – Adds a Networks panel for site admins to create and manipulate multiple networks. HomePage: http://www.jerseyconnect.net/development/networks-for-wordpress Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=networks-for-wordpress
Proper Network ActivationAvoid errors when using WordPress MultiSite network activation HomePage: http://wordpress.org/extend/plugins/proper-network-activation Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=proper-network-activation
Activate Update ServicesWordPress removes the Update Services ability when you create a network. Activate this plugin to get it back. HomePage: http://wordpress.org/extend/plugins/activate-update-services Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=activate-update-services
Multisite Toolbar AdditionsThis plugin adds a few useful admin links to the WordPress Toolbar / Admin Bar in Multisite or Network installs. HomePage: http://genesisthemes.de/en/wp-plugins/multisite-toolbar-additions Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=multisite-toolbar-additions
Add Multiple Users for WordPressBulk add user registrations to a WordPress site using a variety of methods. HomePage: http://addmultipleusers.happynuclear.com/ Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=add-multiple-users
Add User AutocompleteEnables autocomplete for the Add Existing User field at Dashboard > Users > Add New. Requires Multisite. Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=add-user-autocomplete HomePage: https://github.com/boonebgorges/add-user-autocomplete
Multi-Site User Replicator 3000Adds the abilty to add or subtract a user from all sites. (Must copy or symlink this to wp-content/mu-plugins) DO NOT NEED TO ACTIVATE HomePage: http://wpblogtuts.wordpress.com/2013/05/31/make-your-blog-images-search-engine-friendly-using-wordpress-seo-for-image-plugin/ Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=multi-site-user-replicator-3000 Note: sym-link or copy the multi-site-user-replicator-3000/user-replicator-3000.php file into the mu-plugins folder INSTEAD of activating the plugin.
Multisite User ManagementRunning a WordPress network? You no longer need to manually add users to each of your sites. goto: Network Admin > Settings > Network Settings page. Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=multisite-user-management
Capability Manager EnhancedManage WordPress role definitions. Organizes available capabilities by post type, status and source in the guest site on the Users Menu Area. HomePage: http://wordpress.org/extend/plugins/capability-manager-enhanced Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=capability-manager-enhanced
Multisite Plugin ManagerThe essential plugin for every multisite install! Manage plugin access permissions across your entire multisite network. HomePage: http://wordpress.org/extend/plugins/multisite-plugin-manager Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=multisite-plugin-manager
User Switching Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=user-switching
User Management ToolsWith this plugin, you can do it in bulk, by using the familiar “Change role to…” dropdown (This might not work right) Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=user-management-tools
SiteTreeA lightweight and user-friendly tool to enhance your WordPress site with feature-loaded Google Sitemap and Archive Page. HomePage: http://wordpress.org/extend/plugins/sitetree Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=sitetree
AP GravatarsThe Ardent Pixels’ Gravatar plugin adds the gravatar photo associated with the user’s email to their profile page. If they do not have a gravatar account, it displays a link to create one. And is MultiSite compatable! Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=ap-gravatars
Improved Simpler CSSSimplifies custom CSS on WordPress. HomePage: http://wordpress.org/extend/plugins/imporved-simpler-css Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=imporved-simpler-css
Multisite Robots.txt Manager | MS Robots.txtA Multisite Network Robots.txt Manager. Quickly manage your Network Websites robots.txt files from a single administration area. HomePage: http://msrtm.technerdia.com Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=multisite-robotstxt-manager
Simple Multisite SitemapsA very simple solution for generating seperate Google XML Sitemaps for each WordPress site in a multisite network, on-the-fly. HomePage: https://github.com/luckyduck/Simple-Multisite-Sitemaps Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=simple-multisite-sitemaps
Organizational Message NotifierAllows network admin to send organizational messages to blog admins. Includes read confirmation. Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=organizational-message-notifier
Blog CopierEnables superusers to copy existing sub blogs to new sub blogs. WARNING THIS IS NOT WORKING YET HomePage: http://wordpress.org/extend/plugins/blog-copier Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=blog-copier
StatComm (StatPress Community) Multisite EditionStatComm provides Realtime Statistics on your blog, collecting information about visitors, spiders, search keywords, feeds, browsers, OS and more. Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=statpress-community-formerly-statcomm
Ultimate TinyMCEBeef up your visual tinymce editor with a plethora of advanced options. Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=ultimate-tinymce
Dashboard Site Notes Install: http://<your-website>/wp-admin/network/plugin-install.php?tab=plugin-information&plugin=admin-dashboard-site-notes
   

How I Add A Site…

  1. Create a symbolic link in the subsite to the network site.
    • On our server we do this with a symbolic link using the FULL path that the web server uses to get to the site.  So the symbolic link would point to “/var/www-auto/desktopmasters.com/www/”
    • If I was to create a subsite called test I would go into the desktopmasters.com folder and use: “ln  -s  /var/www-auto/desktopmasters.com/www/  test“.  The server would then piont test.desktopmasters.com at the same code as www.desktopmasters.com.
    • If we were going to point a whole new website we would create a subsite then edit the name in the site settings to the full site “www.someotheriste.com” and go to the config folder for that site and symlink it (the www folder) to the main site the same way.
  2. Network Admin” -> “Sites” -> “Add Site” (or) from the main site “Sites” -> “Add Site
  3. For the “Site Address” it will be creating a subdomain.  So in the “Site Address” box put “temp”.  Fill in the other fields with whatever fits your liking.
  4. [Add Site]
  5. On the left click “All Sites” under “Sites”
  6. Find your site, hover over your site, and click [Edit]
  7. change the domain name to the full domain you are wanting to use including the “www.” part and make it all lower case.
  8. [Save Changes]
  9. On the themes tab enable the themes you want this site to have access too.
  10. On the “Settings” tab make sure the “home” and “siteurl” reflect the full new domain/site url in lower case.  Also check the “uploads” path to make sure it is correct.  Remove “/files” off the end if it is there and you want to take that extra folder level out.
  11. At the bottom of the settings tab you can enable any plugins for this one site that are disabled network wide.
  12. Network Admin” -> “Settings” -> “Network Setup“: At the bottom of the page set the default add permissions from the “Multisite User Management” plugin.
  13. Point the new site at the same folder that the network/original site is running from.  I use a symbolic link.