Report this

What is the reason for this report?

How To Set Up Multiple WordPress Sites Using Multisite

Updated on March 14, 2021
How To Set Up Multiple WordPress Sites Using Multisite

About Multiple WordPress Installs

In 2010, WordPress released version 3.0 of it popular content management platform. Among the many improvements included in the release, the WordPress community combined WordPress MU into the main WordPress configuration. Since the change, WordPress has made it easier to create multiple WordPress sites on one server. Whereas earlier, each WordPress blog on a server needed to have its own installation, now a new WordPress site can be installed once, and other blogs can be set up from within the WordPress dashboard.

Setup

The steps in this tutorial require the user to have root privileges. You can see how to set that up in the Initial Server Setup

Before working with WordPress, you need to have LAMP installed on your virtual private server. If you don't have the Linux, Apache, MySQL, PHP stack on your VPS, you can find the tutorial for setting it up in the Ubuntu LAMP tutorial.

Once you have the user and required software, go ahead and Install WordPress. However—make sure you stop at the end of step 4 (We will add one more thing to the Wordpress config file in the next step)

Step One—Setup Your WordPress Installation


With WordPress installed, we need to take a series of steps in a variety of configuration files.

To begin with, modify the WordPress configuration, activating the multisite networking:

sudo nano /var/www/wp-config.php

Add the following line above "/* That’s all, stop editing! Happy blogging. */"

/* Multisite */
define('WP_ALLOW_MULTISITE', true);

After that save the file and exit. You can do so by pressing CTRL+O to save and then followed by CTRL+X to exit.

Activate the apache Mod_Rewrite module:

sudo a2enmod rewrite

Follow up by permitting .htaccess changes in the virtual file. Open up your virtual host file (I am simply going to make these changes in the default Apache one).

sudo nano /etc/apache2/sites-enabled/000-default

In the following section, change AllowOverride to All:

<Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
</Directory>

Restart apache:

sudo service apache2 restart

Once that is all done, the WordPress online installation page is up and waiting for you:

Access the page by adding /wp-admin/install.php to your site's domain or IP address (eg. example.com/wp-admin/install.php) and fill out the short online form.

Step Two—Setup Multiple WordPress Sites

Go into your WordPress dashboard and select the section called tools:

networking setup

Once you have filled out the required fields, go through the directions on the next page (I have elaborated on them further under the image):

next page
  1. Create a directory for your new sites:
    sudo mkdir /var/www/wp-content/blogs.dir

  2. Alter your WordPress configuration. Make sure to paste this above the line /* That’s all, stop editing! Happy blogging. */:
    sudo nano /var/www/wp-config.php
     define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    $base = '/';
    define('DOMAIN_CURRENT_SITE', 'YOUR IP ADDRESS HERE');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
  3. Finally, add WordPress’s rewrite rules to /var/www htaccess file:
     sudo nano /var/www/.htaccess
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    

    uploaded files

    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

    add a trailing slash to /wp-admin

    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).) $1 [L] RewriteRule ^[_0-9a-zA-Z-]+/(..php)$ $1 [L] RewriteRule . index.php [L]

After making all of the necessary changes, log into WordPress once more.

Step Three—Setup Your New WordPress Site

After you log into your site once again, you will notice that the header bar now has a section called, “My Sites” instead of simply displaying your blog’s name:

header

You can create new sites by going to My Sites at the top, clicking on Network Admin, and clicking on Sites:

create a new site
By Etel Sverdlov

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author

Etel Sverdlov
Etel Sverdlov
Author
See author profile

Former Director of Community at DigitalOcean. Expert in cloud topics including LAMP Stack, CentOS, Ubuntu, MySQL, SSL certificates, and more.

Category:

Still looking for an answer?

Was this helpful?
Leave a comment...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

How to set up WordPress Multisite for nginx ? Any tutorials ? Im newbie.

@ozan

I came across this article. I’ve not tried the tutorial, but I look forward to another Digital Ocean tutorial on this topic.

http://wpmu.org/wordpress-multisite-wordpress-nginx/

Excellent tutorial too btw, worked great on Ubuntu 12.10 x64 Server.

As of 6/24/13 the images in the post do not show the Subdomain option of multisite. If you use the subdomain option it does change the rest of the instructions slightly since you don’t need to create a blogs.dir folder.

I just learned that the change I referred to previously in regard to blogs.dir is due to a change in how Wordpress handles multisite uploaded_file_path after version WP 3.5.

http://codex.wordpress.org/Multisite_Network_Administration#Uploaded_File_Path

This article should probably be updated to reflect the change.

<p>As @andrew pointed out…</p> <p> The .htaccess rules referenced above should only be used with WP Multisite installs that started out with WordPress 3.0 through 3.4.2. For WordPress 3.5+ installs, use the rules below; but, ONLY use the rules below if you STARTED Multisite on 3.5. If you upgraded from 3.4 to 3.5, use the old ones referenced above! </p> <pre>RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L]

add a trailing slash to /wp-admin

RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(..php)$ $2 [L] RewriteRule . index.php [L]</pre>

What if I already installed wordpress (and passed step 4) via this guide: https://www.digitalocean.com/community/articles/how-to-install-wordpress-on-ubuntu-12-04

Can I still set up multisite without deleting wordpress and starting over and if so how?

Ok, I went ahead with the steps to configure multisite and it appears to have mostly worked, though I’m now running into this issue: I’ve finished wordpress setup and I have the “My Sites” menu available but when I select “Network Admin” I get a “website unavailable” page; It appears that it’s trying to pull up the address: “youripaddresshere/wp-admin/network”. How do I set that address to my droplets IP or hostname?

Sorry to leave another comment but it won’t let me amend my previous one… So I tried pointing my browser directly at myip/wp-admin/network with no luck either— seems like it’s still trying to route to “youripaddresshere/wp-admin/network” even though I’ve put replaced with my IP address and still saying website unavailable.

Fixed my problem! I hadn’t replaced the “youridaddresshere” text in wp-config.php. Doh!

John, I’m glad to hear you got it working :]

After trying to troubleshoot this myself and coming up with no solutions, I thought I would post the problem here. I am trying to set up multisite from a fresh install of LAMP and Wordpress. It seems like the install goes just fine until I either create a site or even a regular page. For the new site I receive a 404 error when I try to visit the dashboard. It is pointing me to - “http://myipaddress/thenewsite/wp-admin/”. The same thing goes for creating a new page for the base site. I go to visit the page at “http://myipaddress/new-page-here/” and receive a 404 error.

I have a feeling that it is an issue with mod_rewrite or pretty permalinks, but I have enabled both and updated my .htaccess file. Any thoughts?

@ekkletec: Assuming you’re on Wordpress 3.5, please see Pablo’s comment above.

Kamal - Thank you for your response. Unfortunately, I already used those rules in my .htaccess file. I don’t know if it helps, but I am trying to install on Ubuntu 12.04. Also, here are the rules in my .htaccess file:

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

RewriteEngine On

RewriteBase /

RewriteRule ^index.php$ - [L]

add a trailing slash to /wp-admin

RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^ - [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]

RewriteRule . index.php [L]

Let me know if there is further information I can provide that might help troubleshooting. Thanks!

@ekkletec: Delete the first 6 lines, does that fix it?

It looks like I edited the wrong line in the virtual host file, so it wasn’t allowing apache to change the .htaccess file. Thank you so much for your help. Everything seems to be working now!

@ekkletec: Awesome! Glad to hear that :]

I’ve got everything setup right and chose subdomain. Everything works until I try to to go the subdomain site itself where I get a server not found error.

I did add the virtualmin/webmin panel to my install and then used that to add the * wildcard dns A option. I even checked the config file for the site to make sure I had the * wildcard Alias in there.

Of course I have also rebooted apache.

This is the first time I have ever had this issue, so not quite sure where to go from here. Ideas?

@gaffneyiphone: I believe you can’t have a wildcard A record, what’s the domain name and what subdomain are you trying to access? It looks like it’s a DNS error.

Sorry if I’m being dumb, but using the pre installed Wordpress droplet, the first attempted edit of wp-config.php is not in /var/www. Where is it?

It’s at /home/wordpress/public_html/wp_config.html. However, the Apache setup now doesn’t include any directory pointers - only to a specific document root. So, are these instructions past their sell by date for the currently distributed Wordpress pre configured droplet? Not sure where to go next…

I followed the guide, but after finish the 2nd step section “My Sites” is missing. I can’t go ahead with the guide. Help please!!!

@Ian.waring: Replace all occurrences of /var/www/ in this article with /home/wordpress/public_html and /etc/apache2/sites-enabled/default with /etc/apache2/sites-enabled/yourdomainname.com

Let me know if that works.

@mmerino: Try clearing your browser’s cache – does that fix it?

Hi Kamal,

The file named after my domain name contains only two Virtualhost definitions for port 80. It has no Directory entries for /var/www on board at all to add the override to.

In theory, I should be adding a document root in there, not sure whether directory is something I need to add also.

Just the Apache config file left to do - the rest is all set.

Hi Kamal,

Thank you for your response. I used firefox to install WordPress multisite. I cleared firefox’s cache… no fix it. I tested to access using others browser on my PC and “My Sites” still missing. I tested to access using another PC and the same thing. I checked the database, network tables were created. I enabled WordPress’s debug (define(‘WP_DEBUG’, true);) and get message “Constant MULTISITE already defined in /usr/share/sites/blog/wp-config.php on line 94”

@mmerino: The constant is already defined – you have the define() line twice in wp-config.php

Delete one of them.

The instructions tell me to edit /etc/apache2/sites-enabled/yourdomainname.com

In my case, that file corresponding to my domain name contains (between the ++ and – here):

++ <VirtualHost *:80> ServerAdmin webmaster@yourdomainname.com DocumentRoot /home/wordpress/public_html Servername yourdomainname.com ServerAlias www.yourdomainname.com </VirtualHost>

<VirtualHost *:80> ServerAdmin webmaster@yourdomainname.com DocumentRoot /home/wordpress/public_html Servername x.x.x.x (where x.x.x.x is the ip address of my droplet) </VirtualHost>

So, where do I put the text you highlighted, vis:

<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>

? I guess everyone using the same Wordpress 12.10 droplet will have the same issue on a fresh install…

Hi Kamal,

Again thanks for you reply!!! You give me an importante clue to find my huge mistake. The lines to configure multisite on wp-config.php were BELOW the line /* That’s all, stop editing! Happy blogging. */. I’m not english speaking and I ignored the word ABOVE in the guide. Thanks for your time!!! and sorry.

Hello everyone, i have been trying since a while to retrieve the subdomain posts to main domain homepage. Can anyone please help me in giving a step step by procedure to do the same.

If incase you require more info from my side, please let me know. 123nagar.com@gmail.com is my id. Thanks for your valuable time.

sub-domain is possible, here are some tips:

• create droplet > one-click digital ocean WP install • create wildcard record by —> digital ocean dashboard > dns > view > add record > select “a” record > host = asterix symbol > enter ip > click create. • ignore direction above to “make directory” (not needed) • update your wp-config file, .htacess file plus default file AFTER you log into WP for the first time. • change the default WP URL BEFORE you configure network (dashboard > settings > etc…etc…)

p.s. I wish the comment system has “preview” or “edit” - pitiful to see how powerful Digital Ocean is, yet so backwards in community comment technology.

@123nagar.com: I’m not sure if that’s possible – try googling it.

Fixed it. The Wordpress install in this droplet uses subfolders, but these go into the database, not into the file system, so the Directory additions to the Apache config file weren’t needed. I also put quotes around the word false when editing one of the wp-config lines, which confused it further.

The only gotcha I’m having is that the default site, and indeed any network site I’m about to create, all reference my IP address rather than the true domain name. Looks like the database has been set up that way, and I’m not sure how to get it back to using my domain name. If I change the site domain name in the wp-config file, then any access attempt from a browser just spits out a Database query error :-(

Any ideas on how I engineer that change?

Dollar base = ‘/’ in wp-config.php also appears to have broken things. The Wordpress install didn’t mention that line, and mine started working when it was omitted.

Kill my query. I deleted the droplet and started over, and got it completely working this second time around. Just extra careful to follow the directions from the Wordpress install to the letter, and to be consistent with my domain name throughout the install process. Now working like a dream :-)

Why not install two different Wordpress installations? I followed the guide here https://www.digitalocean.com/community/articles/how-to-set-up-multiple-wordpress-sites-on-a-single-ubuntu-vps and had no problems with it. Are there any performance considerations with this method?

@bora.aymete: You should choose which method that fits your needs. It’s generally recommended to use multiple wordpress installations unless you need to use mutlisite.

Great tutorial. Thanks!

@Kamal why would you need to use Multisite?

Hi, I’ve just signed up and used 1-click Wordpress install via Applications and have finished my Wordpress installation. However I want to turn it into a Multisite installation, but if I ssh into my droplet I can’t find my Wordpress files. ls /var/www only shows “index.html”

Where do I find my site’s (i.e. wordpress files) folder? How should I make my Wordpress into a multisite installation from here?

@Kamal just in case, when I do: sudo nano /var/www/wp-config.php

it only creates an empty new file, but I need access to a proper “wp-config.php” file and don’t know where to look for it. Thanks!

Ok this might be a stupid question but I’m having trouble with this… I believe I have successfully set this up (main site working, sub sites are also working fine). NOW I’m trying to point additional domains to the sites I’ve built using the digitalocean tutorial (How To Set Up Apache Virtual Hosts on Ubuntu 12.04 LTS), but I’m getting stuck on the part where you have to work with the directory of the domain… because I can’t find where the directory actually exists (IP/OTHERDOMAIN doesn’t exist physically… I assume it’s being redirected to somewhere else).

Please help! I’m just trying to have multiple sites run through multisite, each with custom domain names, and I feel like I’m just missing something really simple.

UPDATE: I think I’ve found a partial answer to my question… I’ve installed the WP domain mapping plugin (which seems to be where most of my googling lands). I’ve set it up, added a domain to one of my sites - but now, when I visit the site, I’m just redirected to the root site, and not the site in question (one of the multi site creations). I believe my CNAME records are correct (added * and www for @), so I’m a little lost on what I’m missing. Thanks in advance for the help!

UPDATE: FACEPALM - I knew it was something stupid… it looks like I had an old index.html sitting on the root from one of the initial installs of the droplet that was overriding the Wordpress index.php file. Soon as I removed that index file everything is working like a charm.

Rookie move.

After following this tutorial step by step by the letter, I had to delete the file /var/www/index.html in order for my blog to begin displaying correctly…

How would I handle this when in my existing hosting I have the old website that is current (that isn’t WP) and I’ve installed the new WP into /wp folder. I did the wp-config.php but do I need to do the apache? I can access the .htaccess file but not sure what the correct path would be if I have WordPress installs /wp instead of root? Can you advice? RewriteEngine On

RewriteBase /

RewriteRule ^index.php$ - [L]

add a trailing slash to /wp-admin

RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^ - [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]

RewriteRule . index.php [L]

Creative CommonsThis work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.