<?php echo "Hello Again, World!"; ?>
Greetings and salutations.
This is my second blog, which is here to serve as a repository for the really die-hard geekery that I feel just doesn’t belong in my regular blog. When I realized the need for a second blog, installing it ended up being a longer process than i anticipated, and I thought I would share the fruits of my experience.
Let me step back for a moment. I am a true hacker at heart, in the traditional sense: I love to pull things apart and take a look. To see how they work and how they might work better. I’m also an avid Mac-head, and since the rise of OS X, I’ve been learning the ins and outs of its Unix-like underbelly.
In a nutshell, my computer is highly customized.
A few years back I got a second computer — a laptop — and quickly discovered that while keeping one computer tweaked to prime operation just the way I like it is kind of fun, trying to keep two computers in such a state, and relatively synchronized, is a frustrating exercise in futility.
I also know a good bit of web coding. As I’ve been working with Wordpress for a couple years now, I’ve come across a number of good plugins and expansions along the way. Beyond issues involved with installing them, (which is admittedly pretty easy, usually) over time I have to keep up with updates to these — not to mention updates to Wordpress itself. From time to time I even delve into the plugin files myself and make improvements….
And I want to put in a second blog? Am I nuts??? Thinking of what a pain it would be to maintain two copies of Wordpress, I started looking into the various multi-blog solutions people have come up with. Most of them involve a lot of weird modifications to several files and basically comprise major modifications to large swaths of the Wordpress code that are fundamentally incompatible with the regular version.
I am a great fan of what I consider “elegant” coding, which means that the designer does his job with the simplest and most straightforward methodology possible. And I found a very elegant solution to the “multiple blog on one install” question. Allan Mertner came up with something that blew me away with its simplicity and power.
Wordpress holds all of its data in a MySQL database, and there is a single file called wp-config.php that holds the database login information. Allen looked at this and realized that if you can change that one file, you can completely replace the blog. With this key realization he came up with a cunningly straightforward multi-blog system:
- Replace the standard wp-config.php file with a new version that calls a different configuration set depending on what directory it’s in.
- Set up symbolic links that serve as “virtual directories” that all point to the Wordpress directory.
Using the example of this site, I have an install of Wordpress in the root web directory, and a symbolic link called “nerdaphernalia” (that’s right, you’re soaking in it!) that points back to the root. The modified wp-config file points to either the default or nerdaphernalia config file, depending on which of those two directories it thinks it’s in.
So other than a happy user, where do I come in in all this? Well, I made a number of improvements. First, Allan’s system was great, but it required us to install various files in and around the core Wordpress files, which for me at least defeats part of the purpose of using a multiblog system in the first place. I’m trying to make updates easier, remember? Updating Wordpress generally involves deleting everything but the wp-config.php file and the wp-content folder, and then dropping in the new versions of everything else; but if there are important but non-standard files strewn about, I can’t just do that. I have to remember to go through and preserve those files, and then replace them when they’re done. Add in a few plugins that work the same way, and we have a real hassle.
So first off, I tucked all the files, except for the one modified wp-config.php, into a folder in a safe place. Next, I greatly streamlined the install process. At a minimum, the user only need edit a single configuration file, autoconfig.php. If desired, the various blogs can each have individual config files, but it’s no longer necessary.
I’ve added user-accessible functions (and the really handy VUSER constant) that can be used in themes and plugins. I’ve added the ability to customize the location of the configuration files, so the security-conscious can move them entirely out of the Web directories if they wish. Overall, we are left with a easy but powerful system for running virtually any number of blogs off a single install of Wordpress.
Still have questions? Check out the FAQ.
Download
Here’s what you’re really looking for: the download link. Have at it!
(v1.1 is still available here.)
Is this download worth a dollar to you? If you have found this system useful, please consider making a donation. Even as little as a dollar is appreciated:
History/ Acknowledgements
For a detailed history, please see the readme file in the download.
- v 1.0: The basic symlink methodology was created by Allan Mertner.
- v 1.1: Stephen Rider (That’s me!) picked it up and did extensive reorganization, code cleanup, and full documentation. Among other improvements, the whole package became self-contained within the wp-content directory.
- v 2.0: Hugely improved ease of setup and improved (i.e. fixed) usability with domains and subdomains.
- v 2.1: Ability to have virtual blogs in subdirectories. Also added a rudimentary support plugin.
- v 2.2: Several bug fixes and lots of code optimization. Added the $vmb global variable — all user functions now run as $vmb->function()
Many of the improvements to version 2 were based upon or inspired by commenters to my blog. To them, and to everyone who has sent comments, I am grateful.
Good luck. Have fun.
166 Comments
I have WP on a test server running Debian. I read your instructions on the multiblog. Created the symlink. However I get a 403 forbidden everytime. I have wp installed in the root directory. However I am not sure how to fix this issue. I have pointed the symlink to various places according to the comments of other users and directions. With no change. It is currently pointed at the root directory(where the wordpress files are located).
The symlnk should be pointed to the directory in which you installed WordPress.
Do you only get the error when you go to the symlink, or do you get it on the “real” WordPress directory as well?
I was only getting errors when I went to the symlink. I did however fix the problem. It was something silly. The mb-config files had .php twice on the file names and apache freaked out about it. I guess next time I will work on stuff when I am a little less tired. It is working great right now. I am really impressed with it. Thanks for the speedy reply and apologize if I wasted your time.
Stephen, I got to step 5 in your Easy Setup instructions, but am stuck there. I have wordpress in /etc/wordpress, so I’ve moved the wp-config.php file there. I have my other wordpress files in /usr/share/wordpress. I currently have one blog, but want to set up a second. My first blog has the url dennistein.com/blog and I want my second one to have the url erivellino.org/blog Using Linux, I just use the ln -s command to make a symlink which I can point to /etc/wordpress. What folder to I put this symlink in?
Step 6 says to go to each site, blogs through Five Minute Install. I thought the Virtual Multiblog idea was so that you don’t have multiple installs of Wordpress on the same computer. I’m new at this… I’m hosting this on my own computer.
Thanks for your help.
Did not tried it yet, but just for the idea i nrrd to WOW !!
I’ll try it this weekend hope all go well
Stephen, thanks for the great work.
I set up multiblog as you outlined in the advanced setup instructions. As a test, I set up a symlink to the wordpress folder in http://www.mysite.com/dog and included only that one user in mb-users.php. I went to the http://www.mysite.com/dog and it launched me into the Wordpress install, which worked perfectly.
Then I created a second symlink: http://www.mysite.com/cat and edited mb-users.php to add that user. When I went to http://www.mysite.com/cat, I saw the page for http://www.mysite.com/dog. When I tried http://www.mysite.com/cat/wp-admin/install.php, I got the "Wordpress is already installed" message.
Can you tell me where I’ve gone wrong?
Thanks!
Dan –
What exactly do you have in the
vusers[]array? Where are the WordPress files installed? Where exactly do the two symlinks point?Stephen–
Thanks for the response.
The document root for my website is /nfs/users/ayso/public_html
I installed WordPress outside the document root in /nfs/users/ayso/wordpress
In the file /nfs/users/ayso/wordpress/wp-content/multiblog/config/mb-users.php:
$vusers[] = ‘www.mysite.com/dog’;
$vusers[] = ‘www.mysite.com/cat’;
My symlinks point to /nfs/users/ayso/wordpress:
ln -s /nfs/users/ayso/wordpress /nfs/users/ayso/public_html/dog
ln -s /nfs/users/ayso/wordpress /nfs/users/ayso/public_html/cat
When I configured the first blog, database tables were created which were prefixed by "wp_mysite_com_dog_".
–Dan
Dan — Honestly, I’ve never even tested it with an “install in one place, site in another” setup . You’re the first person to ask about it!
That VUSER and table prefix is correct for the “dog” URL. Off the top of my head I don’t know why the “cat” one would not work, but I’m not surprised, either….
I’ll have to look into it. I’ve never done a setup like that, but it’s worth my looking at, I think.
Stephen–
Ok, I did a fresh install and got some things working.
I installed wordpress outside the document root as I described before, and created symlinks to it called dog and cat in the document root. Now http://www.mysite.com/dog and http://www.mysite.com/cat each show separate blogs. That is, everything works as advertised.
For that, I say thank you and great job. That will make my job as webmaster easier.
What does not work is if I try to add a blog at http://www.mysite.com/lizard/gecko.
It appears that all the blogs have to be at the document root level. I see in mb_get_virtual_user() you use
$mbroot = substr( $mbroot, 0, strpos( $mbroot, ‘/’ )
to truncate everything after the first slash. So a blog in a subdirectory below the document root will not work. I’ve tried changing that as follows:
if ( strpos( $mbroot, ‘/’ ) ) $test_mbroot = substr( $mbroot, 0, strpos( $mbroot, ‘/’ ) );
if ( $test_mbroot == ‘wp-admin’ || $test_mbroot == ‘wp-content’ || $test_mbroot == ‘wp-includes’ ) $mbroot = ”;
That allows mb_get_virtual_user() to return a user like mysite_com_lizard_gecko. But that is not the whole answer, and I’m trying to trace out the other changes that are needed.
Am I going down a bad path trying to edit your code to work with blogs at different levels in the website? Is there a fundamental reason that blogs need to be on the document root level?
Thanks for your help!
–Dan
There’s nothing inherently _wrong_ with it, but it is dangerous….
A setup allowing for lower nested blogs allows for some really screwy setups. If you put a directory “lizard” at the root, and then put a “gecko” symlink back to the root directory, you would also have /lizard/gecko/lizard/ (err… I think…). You might not even realize it, but if somebody else _did_ they could come along and literally set up another blog on _your_ site.
I left out that ability because of the potential for mischief and error. So… go for it, but be careful you know _all_ the blogs you are creating….
Stephen Hi - this seems like an extraordinary tool.
I’ve tried a few times to get it up and running, but each time I do, something very strange happens. The wp-login.php works just fine on both blogs, but for some reason the homepage for each is blank. I’m trying to install this for a school site that needs a second blog for displaying Spanish language content, so the setup i hope to build is as follows:
A. One instance of wordpress, installed in the root at http://www.mitatlawrence.net.
B. The base website, the English version, would just be http://www.mitatlawrence.net (this instance is already installed and has received some use).
C. The Spanish version would be http://www.mitatlawrence.net/espanol .
I believe i’ve successfully created the appropriate symlink. the site is hosted on godaddy, so i had to run a php command in browser, using the following:
symlink (’.', ‘espanol’) ;
It created a shortcut link in the root directory, so I’m assuming it worked.
Then i followed the instructions for setting up the users, adding these:
$vusers[] = ‘www.mitatlawrence.net’;
$vusers[] = ‘www.mitatlawrence.net/espanol’;
and finally dropped the new wp-config.php file in the root, with db info loaded.
the result is that i visit each blog for the first time, and it runs through the set up. Then I’m taken to the dashboard, which works great. But for some reason, any time i try to go to the site itself after that, the pages turn up completely blank. Have tried a few different approaches, but each results in the same problem.
Thank you very much for the plugin, I’m confident it will work. Any advice you may have is greatly appreciated.
jase
Dan — Actually, I’m forgetting the full ramifications of why this can be problemeatic. (I saw things as I went, but didn’t keep track — I just didn’t pursue subdirectory blogs).
I think you’ll be okay if you use the full directory $vusers[] (e.g. “www.mysite.com/dog” instead of “dog”). It gets very dicey with people who don’t use the mb-users file (that is “easy setup” could cause problems) or who don’t specify the whole domain/directory structure.
I suppose i could go back in and add subdirectory ability _only_ if $vusers[] is used AND domain/directory is specified. I might just do this. Let me know if you figure it out, because I don’t think it’s terribly difficult, and you might already be on top of it.
Jase — fix your markup and see if that fixes your problem. Invalid (X)HTML is a huge source of rendering mischief.
W3C Validator report for your site
Strider thank you - i will look in to the markup. I checked validation of your site - striderweb.com, and the base site passes with flying colors. However, I checked out this particular page, and it has 11 errors -
http://validator.w3.org/check?uri=http%3A%2F%2Fstriderw...
Yet it seems that you have great success with the multiblog tool. Would there be any other reasons besides invalid xhtml that I’m getting blank pages from the multiblog tool? Perhaps I’m doing something wrong on the inputs or something.
Thank you for the quick response and for the multiblog tool. I’m confident that i’ll get it to work for mit at lawrence and it will save the day.
jase
Jase — thanks for pointing out a flaw in my markup.
In answer to your question — there are millions (literally) of potential causes. Validating your HTML will reduce them by an order of magnitude.
Incidentally, the validation of my own page is a completely moot point, as I am not having any rendering problems of which I know. The fact that you successfully ran the install for both blogs strongly suggests that the multi-blog system is working just fine, and that your problem lies elsewhere. Invalid markup is the most obvious candidate.
thanks for the quick response. Will try my best to clean up the code, though i am not a proficient coder like you so fixing all the errors may take awhile. Alternatively, it seems like the tool you developed works wonderfully with fresh installs of wordpress, so perhaps it would be the path of least resistance if i just start afresh with a new install. will give that a shot and report back.
also regarding the validation of this page - everything here shows up wonderfully and the site is functional and aesthetic. as far as a lay user like me is concerned there are no flaws here.
Thanks Stephen,
jase
Stephen–
When I said I got multiblog working as advertised, I was mistaken. I was actually back to the first problem that I had posted on December 6. Regardless of which blog I viewed, the first user in the vusers array was selected.
I traced the problem down and had to make a modification to correct what I believe is an error in the code in order to get it working on a site with a url beginning with http://www.
In mb_get_virtual_user you get the server name like so:
$server = $_SERVER['HTTP_HOST'];
$shortserver = str_replace(’www.’, ”, $server );
Then you get the current user to test against the vuser list like so:
foreach($vusers as $curruser) {
$curruser = str_replace(’www.’, ”, $curruser );
etc.
Finally you test like so:
$server . \’/\’ . $mbroot == $curruser’
Since you’ve eliminated the www from the user names in the vuser array, I think you should use the $shortserver in your test (as you do in the remainder of the tests in the list).
When I made that change, the program worked great. It is now up and running on http://www.ayso104.org/coachblog and http://www.ayso104.org/homeblog.
(It worked fine on my laptop before the change, because the host name was "localhost", but on the ISP’s site, the host name begins with http://www.)
So, what do you think? Was changing $server to $shortserver in that function the right thing to do, or does that create other problems that I don’t understand?
–Dan
P.S. (I’ve made a change for subdirectory blogs, as we discussed, but I’ve not tested it well enough to put into production yet.)
Stephen–
One more thing…if I go into Wordpress’s Permalink Options and try to change them, Wordpress generates a set of mod_rewrite rules for my .htaccess files. These mod_rewirte rules will try to change a link in one form to the native form.
The problem is that since all of the blogs on my site are symlinked to the same wordpress directory, they all share a common .htaccess file, which means they all share the same mod_rewrite rules.
For example, if you change the Permalinks for http://www.mysite.com/dog the .htaccess file says:
RewriteBase /dog/
Then if you look at the .htaccess file for http://www.mysite.com/cat … what do you know RewriteBase /dog/ Clearly that won’t work.
I don’t really know if this is a problem for subdomain blogs like dog.mysite.com and cat.mysite.com.
I know mod_rewrite is vastly complicated, so there might be a way to craft a .htaccess file that works in this configuration, but I don’t know. For now, I’ll stick with the plain vanilla Permalinks; but if you know a way around the problem, I’d love to hear about it.
Thanks!
–Dan
New version 2.1 is up.
Dan will like this — it now allows for virtual blogs in subdirectories. A few more under-the-hood changes as well.
Also to Dan Meigs — Read the readme file regarding your .htaccess problem
Stephen–
You’re right - I really like it!
I upgraded to the new version, moved my blogs to subdirectories, and everything works great.
(www.ayso104.org/home/blog and http://www.ayso104.org/coach/blog)
Regarding the .htaccess thing - oops…I missed that in the readme.
Thanks!
–Dan
Version 2.1.1 is up. Quick security update — the plugin in 2.1 had a bug that anybody accessing the admin section could see the Multiblog tab. Now you must be an administrator to see it. No other changes.
Swell expansion - makes for much ease of use. A couple of inputs
1. Symlinks.
You should know what you do - but if you have ssh access: Unix command to make symlink:
ln -s [folder where you have your main wordpress] [name of new folder]
Ie - if you are in your web folder called /home/user/www, have your wordpress installed in /home/user/wordpress and want your new installation in /home/user/www/morris then move to the www folder and type:
ln -s ../wordpress morris
2. Symlinks and installation if you want other things under your wordpress folder
First create the morris folder (create the symlink above if you made it) and move into it then give the command:
ln -s ../../wordpress/* .
This will create symlinks to the individual files and folders of the wordpress installation.
My reason for doing this was wanting canonized URLs and a Gallery installation and file storage under some of my wordpresses.
3. Defaults
Stephen, not a big thing, but if you’re able to make it so that the individual config files use default values if a value is empty that would be cool. Eg. when I want to specify a different language for one blog, I still want it to keep the same database settings.
“[M]ake it so that the individual config files use default values if a value is empty that would be cool. Eg. when I want to specify a different language for one blog, I still want it to keep the same database settings.”
I’ve done this to some extent already, but yes, it could use some further functionality.
This will probably see progress in a future version.
What do people do about file uploads? I’d like to have separate uploads per site… but I cannot get it to save those files any other place than under the installation folder.
kjell –
You might have some luck with this comment from this system’s original page:
http://striderweb.com/nerdaphernalia/2006/10/hello-agai...
Thanks Stephen - that’s a good solve. I went a bit more manual and set to use a different subfolder inside each and every blog. Seemed logical since I’ve already setup separate rewrites for almost each blog - as I wanted to do canonical hostnames.
That brings me onto another one, since you seem to be quite experienced with rewrites - would I be able to do a joint .htaccess file for the canonical rewrite?
Say if I want all the subdomain and root domain blogs to rewrite from with www to without www?
Here’s what I use now:
RewriteCond %{HTTP_HOST} !^kjell\.langvass\.org [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://kjell.langvass.org/1 [L,R=301]
no-www.org suggests:
Not sure what you’re asking for precisely, and this is a bit beyond the scope of this page, but if you’re looking to convert
http://www.kjell.langvass.org/tohttp://kjell.langvass.org/, you might try something like…RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.+?)\.domain\.com$ [NC] RewriteRule ^(.*)$ http://%1.domain.com/1 [R=301,L](Not tested!)
I have the issue originally mentioned by Dan, wherein trying to load the 2nd blog just loads the 1st. I’m using 2.1.1 using the advanced instructions and each blog with its own config file.
I have two pre-existing blogs, in the form of user1.mysite.us/blog and user2.mysite.us/blog. The two sub-domains map to top-level directories at mysite.us.
So I uploaded a new Wordpress install at /wordpress. Then I created symlinks to that dir from /user1/blog and /user2/blog. In mb-users.php, I added ‘user1.mysite.us/blog’ and ‘user2.mysite.us/blog’. I have the appropriate mb-config-user1_mysite_us_blog.php and mb-config-user2_mysite_us_blog.php files.
Is this setup not supported, or am I doing something wrong?
JHP–
I’m sure Stephen will have a complete answer for you. In the meantime, if you are familiar with php, you can look at wordpress/wp-content/multiblog/mb-functions.php. The function vmb_get_virtual_user() is where the magic happens that converts a url to a blog directory.
A quick look at it suggests that you might be using an unsupported configuration. You are using both subdomains and subdirectories. My site works with subdirectories, but I’m not using subdomains also.
Anyway, take a look at vmb_get_virtual_user() and you might be able to tell what’s happening.
Good luck!
–Dan
jhp –
The symlinks might be complicating things — you don’t need them at all. Just make a real /blog/ directory and put the WordPress files in that.
Try that first and see if it helps. Off the cuff your vusers[] seem correct.
Dan –
In theory, the combination of subdomain and directory should work.
Stephen, I don’t follow. Where should I put the "blog" dir with the wordpress files?
OK, here’s what I found when debugging the code in vmb_get_virtual_user(): First, with $vusers set as described in my first comment, all of the tests fail, so it defaults to using $vusers[0] (which is the issue I was having). It seems I really want to go down the ‘else’ case, where the server and directory are concatenated. So I commented out the users in mb-users.php and just set $vusers = ”.
After this, both blogs won’t load, with an error that it couldn’t access the database. This is because $mbroot comes in as ‘//blog’. When VUSER is set and the code tries to load the config file, it looks for "mb-config-user2_mysite_us__blog.php" (notice the double underscore before ‘blog’). So I changed my two config files accordingly, and now everything seems to be loading fine.
jhp —
I was suggesting that you make a “blog” directory in your root folder, and put the WordPress install there. I was trying to eliminate the variable produced by the fact that you were putting the install in a location different than _any_ of the WordPress installs. You have two domains, each with a blog at domain.com/blog …you don’t need _any_ symlinks. Install WordPress in /blog and off you go.
Be aware that if anybody goes to the _actual_ install directory (/wordpress), it may be possible for them to create a blog there….
That double-slash thing is weird. I’m curious now. :p
Hi
It took a lot of searching to arrive here and glad I did. Surprising too that things like MU are overkill while for-sale multiblog scripts might have huge shortcomings.
Still getting my brain around the simplicity of V.MBl, but can anyone suggest if Windows Live Writer will handle the system?
I’m wanting to bring a dozen blogs under the same domain and currently use WLW to manage their content, with respective WP logins. Is WLW’s operation by definition incompatible with v.multiblog?
I’ll take your blank looks as ‘well, try it and see’ which I’ll be doing sometime this week. Just appreciate any guesses/confirmation.
Phil
Windows Live Writer probably uses xmlrpc — it has to use _some_ standardized connection to work with so many blog platforms.
I haven’t tried it (being a Mac guy) but I see no reason why it wouldn’t work. The thing to remember about this system is that WordPress never actively notices that it’s running multiple blogs — it’s like running completely separate, but normal, installs of WordPress.
In the time I’ve been running this (over a year), I’ve discovered exactly one plugin that does not work perfectly with VMB, and that’s “WP Super-Cache”. That plugin only has issues because it modifies the .htaccess file, which I’m already modifying separately.
Hey Stephen,
i tried to upgrade to your new 2.# just out of curiosity
the symlink was up and all .. setup seemed very similar to your 1.1 version but when i accessed my website i get a blank page on both directories.
I switched back to 1.1 working again
haha.. what do you think could be the problem :]
thanks for this great tool btw!
Your system works brilliantly, truly excellent job.
THE GREAT NEWS IS:
It works flawlessly with Windows Live Writer including image uploading between all the blogs
Here is my quick and dirty WordPress CMS or MultiBlog help file for those that are battling with blogs under sub directories. (Please note I am no expert it took me 2 days to get this working plus I am a complete idiot plus it’s my first attempt at WordPress). Lets call this my "Idiot’s Guide to Virtual Multiblog for WordPress"
The steps I took:
1. INSTALLED WordPress in the root
1. CREATED SYMLINKS
2. EDITED MB-USERS.PHP
3. EDITED HTACCESS
4. CREATED BLOGS
SYMLINK
1. For Windows Users - Download WINSCP (http://winscp.net/) this utility makes symlinks a snap. For ease of use install if with the "Norton Commander GUI"
2. In WINSCP create your account and log in.
3. Goto your public_html folder.
4. Click on File -> New Link
5. The top option is the virtual directory you want to create, mine was "alberton"
6. Second option is the folder you link to (you will see your directory structure right on top of the screen - right hand side, mine was "/home/cento/public_html/", click ok and your link has been created.
7. Do this for all your zillions of directories
or
Create a PHP and upload to your public_html folder, name it anything and paste this in:
"alberton" needs to be changed to your name you want the symlink to be
MB-USERS.PHP
This file confused me a lot as I had a major problem that the default blog on the root that either defaulted to the second blog or kept on saying that the database was already installed.
It do not know if this is the proper way but trust me it works. To keep it simple I have deleted the comments from the file. What I must mention is this comment from Stephen "//The first blog on the list will be the default"
That means you must have a name for the default blog on the root but and it must have a symlink!! I called mine ‘cento’, this means the root blog will be assigned to this. The other directories are the names you gave your symlinks shown in point 5 above.
[editor's note: you should only fill in $mydomain if using subdomains, e.g. "alberton.centosport.co.za"]
It was convenient for me to have my own single domain as above as I am going to create 50 symlinks/blogs as this will be used as a CMS, as was indicated you then do not have to insert the domain everytime in the vuser section.
HTACCESS
1. Make sure you edit your .htaccess properly and set the permissions properly (mine is 744) after editing it, I am sure someone here will be able to point the correct setting if this is wrong but it works for me.
2. IMPORTANT!! The .htacess includes all the directories except the root blog. which is "cento"
# BEGIN WordPress RewriteEngine On RewriteCond %{REQUEST_URI} (/alberton|/germiston|/vereeniging)?/ RewriteCond %{REQUEST_URI} !wp-content/docs RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . %1/index.php [L] # END WordPressPaste the above in your .htacess file and change the symlinks/folder names in line 4.
Save your .htaccess file and modify the permissions.
CREATE BLOGS
Now go to each individual folder "http://www.centosport.co.za/alberton "germiston", vereeniging" including the root blog etc. and install each blog individually. IMPORTANT try and keep your passwords different for each blog if you are planning to change the passwords when logging in as this might confuse your system. I am not 100% sure of this but let’s be safe.
[editor's note: I have used same username/password on multiple blogs with no problems.]
IMPORTANT!! You must install each blog asap otherwise someone else can log into that directory and pose a security breach.
SOME THOUGHTS
1. Stephen’s multiblog tool allows for a true CMS system with individual sections "blogs" for your users
2. This tool will be even more amazing if you can copy certain sections ie.widgets, users, categories between blogs from one master blog to the other.
Lastly thanks again for making my live a little easier
[You're welcome -- Thanks for the guide! -- ed.]
Pierre –
You should blank out the $mydomain variable if you are not using subdomains. Having it may pose a security risk, as somebody could potentially make a new blog at (for example) alberton.centosport.co.za
To clarify: $mydomain, is simply a shortcut for people making lots of subdomains at the same domain. It allows you to just put the subdomains in the $vusers[] list, and they will be recognized as “$vuser.$mydomain”
mo –
Can you be more specific? Please Email me with details about your site — what $vusers are listed, where is WordPress installed, what are the names of your config files, using symlinks/subdomains, etc…
Let’s see if I can get v2 working for you.
Stephen
I tried that eg:
alberton.centosport.co.za and it just gives me a 404 error
Could it be because of my hosting platform WHM/CPANEL
When I remove the $mydomain = ‘centosport.co.za’; my blogs do not want to install.
Anyway I will leave it like this and just make sure the blogs cannot be re-created going the other way around.
The good old saying "if it works don’t fix it" comes to mind.
Thanks for the headsup though, I appreciate it
Pierre –
Are your blogs in different directories, or are they in subdomains, or both???
If they are all at the root directory but different subdomains, you don’t need the symlinks. If they are in directories on a single domain (no subdomains) you don’t need $mydomain.
That is, if using subdomains, you don’t need the symlinks at all — just point each subdomain to the root directory.
It sounds as though you are using both methods at once!
Hi Stephen
I only use directories on a single domain. The problem is I tried all the scenarios you mention and it did not work, hence this method.
Please bear in mind my noobness but it’s working great. I have not found one pluggin or post not working except WP Super Cache.
I am building the site now and will report on any bugs etc. so it might help anyone.
BTW: I needed a solution like yours to break my ads up using Adserve and letting each branch have it’s own unique account as WP does not allow our weird categories.
I am now attempting WP-o-Matic to see if the blogs will RSS feed articles to the main blog using a "Featured" category.
If that works WP-MU can fly and we can go live in a day or so
Thanks again
Hi Stephen, and thanks Pierre
i just came back to this post
i think Pierre’s note:
2. IMPORTANT!! The .htacess includes all the directories except the root blog. which is "cento"
might have been my problem – i might have felt the need to add both from the v1 install and that probably messed me up xD
I’ll have to try again the next chance i get
thanks a lot !
Strider, I am having difficulty following your instructions for the Easy Setup (no doubt due to my inexperience). Please advise me. Here are the stumbling blocks I am facing:
STEP 1: Install the WordPress files as usual.
Well, I think I have already done STEP 1. That is, my WordPress site is already up and running. Is that what you mean? Or are you saying that I need to do a fresh reinstall of WordPress in order to make Virtual Multiblog work?
STEP 2: Place the multiblog folder in the wp-content/directory.
That’s clear enough. I did it.
STEP 3: Move the wp-config.php file up to the directory in which you installed WordPress.
Here I get a little confused. At this point in the installation, there are two wp-config.php files inside my WordPress folder — the old wp-config.php and the new one.
I assume you are asking me to move the new one (not the old one) into the root directory, where the WordPress folder resides. In other words, I should place it *outside* the WordPress folder, but *inside* the root directory. Correct?
And what about the old wp-config.php? Should I delete it?
STEP 3: Open wp-content/multiblog/config/mb-autoconfig.php in a text editor. Input your database login information:
Clear enough. I have performed this step.
STEP 4: Set up whatever symbolic links, subdomains, or domains you wish so they all point to the directory with WordPress installed.
Here I’m not sure what you mean by saying that my symlinks should "point" to the root directory. I interpreted this to mean that I should create folders and give them names corresponding to the directories I wanted them to represent, then put those folders inside the root directory. Is that correct?
For instance, I created a folder called "blog" to represent a sub-directory and created two folders inside of "blog" to represent sub-sub-directories. Let’s call them sub-blogs.
Then I tried putting "blog" inside my WordPress directory. Didn’t work. So I tried putting it outside my WordPress directory. Still didn’t work.
When I placed the "blog" folder *inside* the WordPress folder, and typed in the URL http://www.example.com/blog/sub-blog, I got an error message that I was denied access.
When I placed the "blog" folder *outside* the WordPress folder, and typed in that same URL, I got an error message saying that the page did not exist.
Again, please pardon the elementary nature of these questions. Any assistance you could give me would be deeply appreciated.
[example URI edited by admin]
Rodrigo –
1) If you’re already running, step one is done.
2) Ok
3) Replace the existing
wp-config.php. To be on the safe side, you might want to rename the original instead of deleting it.3… again) Ok
4) You need to learn a bit about “symbolic links”. Basically it’s a special kind of file that the computer sees as though it were a particular directory — i.e. a second representation of that same directory. If WordPress is installed in
/blog/, you would make a symbolic link, pointed to/blog/and name it something else (e.g. “blog2″). End result: directory/blog/with WordPress installed in it, and “directory”/blog2/with the exact same files as/blog/.There are many ways to make symbolic links, and they differ depending on the OS of the server and other factors. Ask your host about making symbolic links. If you’re not a techie type, you’re probably best off if they can make then for you.
Hi,
This looks like a great project. I’m going to build a network with 20 blogs on all their own domains.
I however need all of them to be hosted on unique IPs.
Will this be a problem or easy to achieve?
Does this solution also use different databases? Because I use a couple of plugins that might collide. I just want to share stuff like user information and some options.
Thanks.
John –
I have no idea about having them all on different IPs. You’re running off of a single install of the WP files, so I assume that’s one server == one IP.
RE databases: You can set it up to use different databases or the same database.
RE Plugins and sharing user info: Allow me to quote the first paragraph of the Readme file…
“Each blog is managed as a complete separate install — separate admin sections, separate users, etc. They will happily co-exist with different themes and plugins activated.”
A future version may allow for sharing of user info, but it will take a lot of work and testing, so don’t hold your breath waiting for it.
Add me to the list of grateful people who think the work you’ve done here is exactly what was needed!
Unfortunately, I’m a noob with regards to a lot of what’s going on with the database stuff, despite a halfhearted half a computer science degree I earned several years back. The only thing I was prepared for in this install was the creation of symbolic links (whew!)
Anyways, somehow I got a little confused, and somehow my database has two sets of entries in it… the stuff that was there before (since I already had a running blog before I tried to add virtual clones) and the new stuff, which is prefixed slightly differently; for example, I have wp_posts that contains my old posts, and wp_qrystal_name_posts that contains that exciting "Hello World" that comes with all new Wordpress installs.
I think my problem was that I was following the directions really literally, and needed to tweak somewhere to do what I wanted instead of what the default install would be. I’ll post back here when I figure out what to do about it ..
(I think I’m only babbling in your comments here because my own blog is on the fritz and I need an outlet! :P)
hi there, great job on this!
I was planning to give away 200 to 300 wp weblogs on subdomains. I would have one or more installations in a subdirectory of my main domain.
Do you think this is doable with your script ?
Should I split into more installations?
thanks
Qrystal — You have tow options to use the previously existing database info:
1) Use a MySQL program of some sort to change the names of the old tables to the new prefix. Note that you will also have to change a couple entries in the xx_options table where the prefix is on an option name.
2) Use a custom config file that tells that blog to use the wp_ prefix
Alex —
As far as I know, the scripts should handle the load. What you might want to do, however, is split it among multiple _databases_. If that is still a problem, you might split it across multiple servers. Splitting it into different installs on _one_ server might actually _increase_ the burden, as you could lose some of the advantages of PHP caching.
Thanks Strider, that was exactly the answer I was hoping for.
I have a small problem though. I cannot seem to make rewrite rules for the subdomains with htaccess, so I decided to add the subdomains with cpanel.
Then I tried placing a php file inside the subdomain’s directory, which Includes the index file of the WP installation (using a relative path to the wp-directory, located in public_html).
this is however generating a blank page.
do you have a tip for me to make this work?
that would be great!
thanks again
“I tried placing a php file inside the subdomain’s directory, which Includes the index file of the WP installation (using a relative path to the wp-directory, located in public_html). this is however generating a blank page.”
I don’t understand what you’re describing here. You’ve made subdomains, and you are pointing them to a directory in public_html. This subdirectory has WordPress installed in it or not? Why are you including from somewhere else?
Alex, it sounds like you’re using actual directories for your subdomains, and you don’t have to. I used cpanel to direct my subdomains to point to symbolic links instead of actual directories, and those symbolic links are like ’shortcuts’ pointing to the wordpress directory.
I think the concept of symbolic links is unique to a unix/linux environment, and I only know how to set them up via command line. I did encounter some instructions on how to use php to set them up though, and there are probably other ways to set them up depending on operating system, etc. I can see why Strider doesn’t include instructions on that part of it, because every system is different!
Anyways, Strider, I did end up just using phpMyAdmin to go through the database and find the things I needed to change. I didn’t realize I could have just changed the prefix in the config file! I was already setting up custom config files for the various domains, so that would’ve been easy.. ah well, the lessons learned in the SQL exploration were worth the effort!
Actually, for subdomains you don’t need symlinks at all.
Symlinks are used if you want blogs in subdirectories. Then you make fake “directories” that are symlinks pointing back to the main install.
For subdomains, you install WP, and point your various subdomains to the same install.
OH — wow, that’s pretty incredible! And I realize now that you have been saying that all along. My mind must’ve just latched onto the symbolic link idea, because those are the search terms I used to find this plugin!
I am currently modifying my wordpress to be a multi domain interface blog management system, the problem is however.. the wordpress code itself. It is so messy and all over the place its turning what should be a simple job into a hard job and tiresome job.
I have basically config’d my httpd.conf file to send all domains to the same documentroot to pull the same wordpress files.
I have made some db modifications to associate posts, categories and comments with specific domains, and also obviously add / edit / delete domains.
Still currently going through some MAJOR issues but will notify and post link to download when complete.
Kind regards,
Chloe Prams.
Chloe –
Are you familiar with WordPress MU? Between that system and this one, I’m not sure what it is you’re attempting that hasn’t been done.
I’m not knocking your effort!
If you’re on the track of something different, I’d love to see it. Just no sense in recreating the wheel.
Check out MU if you haven’t seen it yet. It might already be what you’re trying to create.
Hi, this seems like an interesting plugin, and one I’d very much like to use as I have several WordPress blogs on the same hosting account.
However, after following the simple install steps I cannot login, but get redirected to install.php and the error "Already Installed". I didn’t have problems completing any of the steps and the install did create tables to the database.
I tried it with only one blog, so I can’t figure out why it would not work.
Any ideas?
Feel free to ignore the above!
After purging the database and going the advanced setup route, the problem disappeared.
Ok, so I got your awesome little hack up and running, but I’m not sure how to take advantage of the VUSER constant for theme mods. Here’s my dilemma..
I have the same theme on all the domains, but I’d like to change the header logo depending on the site.
root site –> wp-content/themes/theme/root-site-logo.jpg
virtual site –> wp-content/themes/theme/virtual-site-logo.jpg
etc, etc.. How do I achieve this?
Hello: Grettings for your help.
I have some questions.
How many databases do you need for run this plugin?
about the admin panel…
Have I one admin panel for each blog?
Thanks very much.
Guy — Try something like this (untested off the top o’ me head):
<img src="logo-< ?php echo(VUSER) ?>.jpg”>Leonardo — This is all pretty well covered in the readme, but…
With Easy Setup, it all goes in one database. With Advanced setup you have the choice of same or different databases.
Each blog will have completely separate admin. They act as separate installs.
Hello: I am reading your "readme" archive.
I have a questions, about your website.
You have 2 blogs
http://striderweb.com/nerdaphernalia
http://striderweb.com/blog
they are created usin "Symbolic Links"???
I am trying to learn what are "simbolic links"…Is my first time that I know that word.
Thanks for help me.
Leonardo –
The bulk of this site is run directly off an install of WordPress at the root directory (striderweb.com/). The /blog/ directory is part of that install.
Also in the root directory is a symbolic link named “nerdaphernalia” that points back to the root directory. The symlink acts as a directory in its own right, which means that I effectively have a /nerdaphernalia/ directory, that conveniently contains exactly the same stuff as the root directory (minus a “nerdaphernalia” directory — the symlink does not cause an infinite loop! That is, the nerdaphernalia directory does not contain a nerdaphernalia directory….)
As for what a symbolic link is:
http://en.wikipedia.org/wiki/Symbolic_links
Hi,
I’m using WordPress as CMS to make some different sites. Some of them have more than one domain name (www.mysite.com and http://www.mysite.org). So if I define 2 symlinks I´ll get 2 sites instead just one as I pretend.
Have you some tip to solve this.
Tanks,
PB
PB — Not sure exactly what you’re describing; but if you want the two domains to point to the same blog, you can use the Advanced Setup. Just give the two domain VUSERs custom config files that each define the same table prefix.
Note that WordPress knows what domain it’s supposed to be in, so if you access it through the “other” domain, it will forward to the the one defined in WordPress. That’s WordPress code; not mine.
(though… you _might_ work around that by defining the URL in the config file also, like so:
define('WP_SITEURL', 'http://www.example.com/'); define('WP_HOME','http://www.example.com/');Good luck!)
Hi - awesome plugin here, just awesome. I was able to get this working with a fresh wordpress install in a matter of minutes (using subdomains). However, I tried to connect this to an existing blog and I hit a wall. I was able to create the custom config and it was applied, however when I went to my blog root, I was redirected to /wp-admin/install.php - and there was an error that the tables were already populated and must be cleared in order to install. Interestingly enough, I went to mysite.com/wp-admin and logged into the dashboard of my blog no problem, all of the db info was there. I even tried changing back to the default theme but I got the same install error when going to my blog root.
Any ideas? I would really love to use this with my existing setup so as to drop my redundant wp-installs on the subdomains.
Nick,
I ran into the same problem with one of my sites but eventually managed to work through the problem. I wrote up a little tutorial that might provide some guidance.. Let me know what you think.
http://www.nullamatix.com/howto-run-multiple-poor-mans-...
No, your how-to didn’t help. I am still stuck at the same place doing the same thing. This is something that is unique to connecting to an existing set of data tables that does not happen when i create new tables. Could it be something in the config file itself I wonder? I am going to look if there are any differences between my existing wp-config.php and the multiblog one. also wondering if maybe .htaccess is to blame. I will check and report back.
Nick,
Sorry about that. I recall experiencing the same error and believe the issue was resolved when explicitly defining the table prefix in the mb-config-some_domain_com.php file. phpmyadmin was showing new table prefixes (some_domain_wp_xxxx or something similar). I then deleted the new tables and defined the default WP prefix (wp_) and the site loaded as expected.
Hope you figure out what’s going on. Hang in there, believe me, it’s worth it
I’ve reduced my server’s disk consumption by a significant percentage.
I do appreciate the response though. I am able to connect to the tables when in the dashboard - but when i go to the site, I get redirected to the install and get the error stating that the tables are in use and I cant install. Its really weird - its like there is a setting somewhere telling it to install again even though it doesnt need to be installed because it can see the data in the tables.
Man, that is weird… hhmm. You did replace your wordpress wp-config.php with the one provided in the download, right? Have you checked the DB for additional (newly created) tables?
Yes, I did replace wp-config (after renaming my original of course). Just checked the db and no new tables were created.