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.
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)
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.
Go into your WordPress dashboard and select the section called tools:
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):
sudo mkdir /var/www/wp-content/blogs.dir
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);
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.
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:
You can create new sites by going to My Sites at the top, clicking on Network Admin, and clicking on Sites:
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
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!
nginx users should take a look at this: http://codex.wordpress.org/Nginx#WordPress_Multisite_Subdirectory_rules
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/
Thanks for sharing this article here in the community. We’re working on a lot new tutorial, so keep checking the community for new releases!
Regards
Excellent tutorial too btw, worked great on Ubuntu 12.10 x64 Server.
The tutorial was updated several times, since then. It should be fully working on Ubuntu 20.04 as well.
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.
Thanks for sharing this!
Yes, some of the settings might have changed. I’ll pass this internally so we can ge the tutorial updated.
Regards
<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?
this post did not address the question asked
Heya,
Yes, you can still set up WordPress multisite on your existing installation without needing to delete WordPress and start over. Follow these steps to enable multisite on your existing WordPress installation:
Backup Your WordPress Site: Before making any changes, it’s always a good idea to create a backup of your WordPress site, including the files and database.
Edit
wp-config.php
: Open thewp-config.php
file located in the root directory of your WordPress installation for editing.Enable Multisite: Add the following lines to the
wp-config.php
file just before the line that says “That’s all, stop editing! Happy blogging.”:phpCopy code
/* Multisite */ define( 'WP_ALLOW_MULTISITE', true );
Save Changes: Save the
wp-config.php
file after adding the above lines.Network Setup: Now, visit your WordPress admin dashboard (
http://yourip/wp-admin/
) and navigate to “Tools” > “Network Setup”.Network Setup Wizard: Follow the instructions on the Network Setup page. You’ll need to choose between subdomains or subdirectories for your multisite setup. Enter the necessary information, including the network title and your admin email address.
Update
wp-config.php
and.htaccess
: After completing the Network Setup Wizard, WordPress will provide you with code snippets to add to yourwp-config.php
and.htaccess
files. Follow the instructions to add these code snippets to the respective files.Save Changes: Save both the
wp-config.php
and.htaccess
files after adding the code snippets.Log Back In: You’ll be prompted to log in again. Log back into your WordPress admin dashboard.
Activate Multisite: Once logged in, go to “My Sites” > “Network Admin” to access the network admin dashboard. From there, you can manage your multisite network, add new sites, and configure network settings.
Regards
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?
You’ll need to update all references to match the correct IP address. In order to resolve this you can use plugin like Duplicator or All-In-One-Migration plugin to handle the process for you.
Regards
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?
Heya,
This is likely related to the configuration of WordPress multisite and the permalink settings.
In a WordPress multisite setup, pretty permalinks are required for sub-sites to work correctly. Go to the Network Admin dashboard (
http://yourdomain.com/wp-admin/network/
) and navigate to “Settings” > “Permalinks”. Make sure “Common Settings” are set to anything other than “Plain” (e.g., “Post name”).Also, confirm that the
.htaccess
file in the root directory of your WordPress installation (wherewp-config.php
resides) contains the necessary rewrite rules for WordPress multisite.Regards
@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!
The issue you’re experiencing could be related to the Apache configuration or DNS settings.
Verify that the Apache configuration allows
.htaccess
overrides for your WordPress site’s directory. Look for the<Directory>
directive in your Apache configuration file (/etc/apache2/apache2.conf
or individual virtual host files) and ensure that it includesAllowOverride All
.Double-check the DNS configuration for your subdomain to ensure that it’s correctly pointing to the IP address of your server. You can use tools like
nslookup
or online DNS lookup tools to verify the DNS records.As a troubleshooting step, you can try temporarily renaming or moving the
.htaccess
file to see if it resolves the issue. If the site works without the.htaccess
file, there might be a problem with the rewrite rules.Hope that this helps!
@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?
You need to ensure that the wildcard DNS record (
*.yourdomain.com
) is correctly configured and pointing to the correct IP address. You can use tools likenslookup
or online DNS lookup tools like ours to verify the DNS configuration.https://www.digitalocean.com/community/tools/dns
Confirm that the Apache virtual host configuration for the subdomain is correctly set up. There should be a separate
<VirtualHost>
block for the subdomain in your Apache configuration files (usually located in/etc/apache2/sites-available/
).Regards
@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…
Heya,
The WordPress configuration file is typically named
wp-config.php
, notwp_config.html
If your Apache setup doesn’t include directory pointers and instead points to a specific document root, you might need to adjust your Apache virtual host configuration to ensure that it serves the correct site. This involves editing the Apache configuration files, typically located in
/etc/apache2/sites-available/
You can check our article on how to setup an apache virtual host on Ubuntu 20.04 here,
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-20-04
Regards
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.