Hi all, currently I have a few sites all with their own drupal installation, but installed on one server and i would like to change it into a single multisite installation and need some advice. I wasn't sure which category to put this post in as its a post-install upgrade re-install conversion or something... but anyways...
My setup is:
/public_html - this has my main site with drupal 5
/public_html/sub1 - this is a subdomain running its own installation of drupal 5 which is accessible via sub1.mymainsite.com
/public_html/sub2 - same as above
/public_html/sub3 - same as above
/public_html/addon1 - this is an addon domain and is accessible directly via www.addon1.com (i have a hosting account which allows multiple domains per account)
/public_html/addon2 - same as above
more addons and subdomains will be added in the near future I guess
to make matters slightly more complicated all domains are drupal 5 but different versions, and one site is drupal 4.7.
Firstly, I'm guessing I should upgrade all installations to the same version? (I wanted to avoid this step as the whole reason I want a multi-site is cos I'm fed up of maintaining each installation separately! but I'll do it one last time if need be)
And then what do I do! i have no idea how to approach this problem, each installation obviously has its own mysql database (but stored on the same account), do i need to merge these? is what I want to do even possible!?
Any suggestions welcome.
Comments
Yes, this is perfectly doable
In fact I've done it myself.
Assuming that your server is running on Linux/Unix, Here's what you need to do :-
sitesfor each site, with the same name as that site's domainsettings.phpto the appropriate subdirectory under sites.Once you have verified that this is working, you can delete the Drupal folders for all but the main site.
Happy to help further if you need it, but that's the basics.
Pete.
Pete.
http://adaptive.co.uk
Hi, thanks for your quick
Hi, thanks for your quick response. You've broken it down pretty well and it even looks quite easy, giving me an overwhelming sense of hope!
Steps 1, 2, 4 & 5 are no problem, but step 3 doesn't mean much to me I'm afraid! don't have a clue what symlink is. I've had a quick look through google and it seems to be some kind of alias/shortcut, and the sites were listing unix commands (I dunno much unix). So regarding this I have a few more questions I'm afraid:
1. How do i create these symlinks? My host is running linux (its hostmonster.com) and cPanel 11. I don't know if i can do symlinks via the interface, i can do redirects and stuff but don't think I can do the symlinks. If i send a scan of my photoID etc they can enable SSH/Shell access which I guess would allow me to create these symlinks? alternatively I could probably send a request to the support team saying what symlinks I want and they could do it - though everytime I wanna add a new site I would need to create a new symlink?
2. (Assuming I create the symlinks using the shell and the syntax 'ln -s target_filename symlink_filename') So for sub1.mydomain.com I create a symlink pointing to my drupal installation. I also create one for sub2.mydomain.com and addon1.com etc. Does it matter what I call the symlinks or where I place them? (or maybe if it doesn't matter do you have advice for a convention to follow? e.g. can I place each one in the respective site folder? or place them all in a single folder called symlinks in the root?)
3. If I understand correctly you are saying that I shouldn't have my subdomain1 setup as /public_html/sub1 (where all my files for that subdomain is) but should have it setup as /public_html/symlink_for_sub1? in my cPanel I cannot edit the path of a sub or addon domain so I guess I will need to remove it first, and the re-add it pointing to the symlink (I hope it doesnt delete the data when I remove the sub or addon!, maybe best to rename the folder to something else first).
4. I was planning on keeping the drupal installation in the root (/public_html) simply cos I thought thats how it needed to be. But it seems I could have it in a /public_html/drupal folder which I would prefer. Would this complicate matters in any way?
I think the above questions pretty much covers what I need to know in order to complete this setup, but I would also like to actually understand what is going on.
So if someone types sub1.mydomain.com/mypage then the server magically knows through my cPanel config to load the appropiate symlink, which is actually the drupal installation so ends up going to drupal/mypage. The drupal installation knows what url we are coming from and loads the appropiate settings.php file and thus the database etc. That all makes sense, except for a few more points :S
- what happens to the files folder? Each domain has its own files folder or all files are in the drupal folder? and when I need to type in a relative URL for a file (e.g. videos in video module) I still do it relative to my site NOT drupal or the root?
- does the www confuse anything? when creating the subfolder in the drupal/sites, do I add sites/www.addon1.com or sites/addon.com or does it not matter and it always works whether people use the www or not?
- what happens to the main domain? There is no symlink for that (this is if I place my drupal in a subfolder).
- why do we even need a symlinks per site? can we not point all addons and subdomains directly to same symlink or even the drupal folder?
Many thanks in advance, hope thats not too many questions :S
Memo.
Me too
I'm about to embark on this same journey, except I'm changing hosts at the same time. And I want to deliberately support two releases: 5.x and 6.x. (However, I am actually right now on 3 different releases of 5.x, but that shouldn't be a problem.)
What I want to accomplish is the ability to upgrade one site at a time by switching the pointer to the code base. Just to complicate this a bit, the first site I want to put up will probably be the first one to go to D6 too, but the rest can't go at the same time.
This is very simple on my PC.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
Me Three
See: http://drupal.org/node/202577
Suggestion
I posted a response in your other thread. But instead of having a thread for one person, why not post a link to this one in that one?
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
To Answer Your Question...
If you will notice, I started my thread a week and a half before this thread was created (but only after searching unsuccessfully for three nights solid). Since mine went unanswered and this thread was getting responses, I didn't see any harm in expressing my interest in the subject as well. The reason I added the link was merely to avoid retyping my particulars here. I'm more interested in learning how to do this--not which thread gets an answer. If I've broken some Drupal best practice policy or something, my apologies.
Sorry
I didn't mean to upset you, I was merely suggesting that you point to the post that is getting answers (sort of). I've done the same in the past. It's not a matter of "best practices," it's a matter of getting answers. Sometimes it can be frustrating to have posted something and then see a later, similar, post get the answers. Another "trick" you can use is to go back to you post once a day or so and edit it (add a blank, for example) so it jumps back to the top.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
Apology Not Necessary
I wasn't upset. Just attempting to clarify was all. It would be a good idea to link to this thread from mine if this one ends up providing the desired information. I did 'bump' my thread up periodically, but I didn't feel it appropriate to continue doing so after three times. Besides, I wasn't in a panic; it wasn't something I *had* to know or do right then and there. So I just put it on the back-burner and focused on something else...being fairly new to Drupal I have no shortage of other things to learn.
Multisite configuration
Hi!
A symlink is, as you've correctly surmised, a symbolic link.
I created my multisite setup using the control panel provided by http://webfaction.com which allowed me to create a site as a symbolic link; if your control panel doesn't allow that, secure shell access is the best bet.
The way it actually works, as I understand it, is that the domain or subdomain is set up as a virtual host in the Apache configuration such that requests for the domain are sent to a directory which is a symbolic link to the multisite directory.
It doesn't matter what the symbolic link is called, so long as it points to the multisite installation directory, i.e. the DNS entry for the domain or subdomain resolves to that link.
The Drupal installation can tell which domain it's being asked to serve up; it will serve up whatever is in sites/default if there isn't a sites/domain-requested folder.
Would elaborate further, but it's very late :-)
More tomorrow.
Pete.
Pete.
http://adaptive.co.uk
Thanks
I don't see anything like "Symlink" in my cPanel, but I do see "Manage redirects." Is that the same thing?
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
No
At least not according to my understanding. Re: http://drupal.org/node/107347#comment-284124
There is good info on symlinks in the 'Drupal for Dummies' thread you might want to read. I used the php script mentioned therein to create mine and if you are using cPanel, when you create your subdomain the very next field below it (with the little house in front) is where you can specify the document root the subdomain is to point to--if I'm not mistaken. As obvious as this now appears, the first time I tried setting up a multisite I completely missed it--a clear cut case of being so intently focused that I couldn't see the forest for the trees! I believe the same thing also applies to adding add on domains; there's a field above the password field where you'd specify the document root for the new domain to point to. (And if I'm wrong about this, someone set me straight--I'd hate to be giving out misinformation!)
Symlinks
@Peculiar_One - Could you try setting the document root for a domain or subdomain directly to the Drupal installation rather than via the symlink and see if it still picks up the right settings.php?
I'm almost wondering if the symlink tissue isn't a red herring after getting it to work without...
Thanks!
Pete.
Pete.
http://adaptive.co.uk
Sure, I'm Game--I'll Try It :)
Let me just list the steps I took in case I didn't do exactly what you had in mind.
(I already had a database named "test" created, just in case)
1. Via cPanel, I created a new subdomain named "test" and listed the document root as public_html (this is the install location for mydomain.com)
2. There was no directory created by cPanel named "test" for me to delete (as per multisite instructions elsewhere).
3. In public_html/sites/all I created a directory named test.mydomain.com
4. Uploaded a blank settings.php file to public_html/sites/all/test.mydomain.com
5. Accessed test.mydomain.com in my browser and it took me to mydomain.com
Have I overlooked something?
Children, Do Not Try This At Home!
I was just about to comment that I re-read Pete's post and noticed that he put his blank settings.php file in sites/default and say that a settings.php file already existed in my sites/default directory (which I assume is the needed settings.php file for my Drupal install in public_html) when it was brought to my attention that all my sites were down. Not 100% sure that this was caused by my afore mentioned experiment, but the odds are in its favor--hence the warning.
No 'eureka' moment here, unfortunately. But, hey, at least I can be happy for Pete. :)
Close, but no cigar ;-)
The subdirectory needed to be in public_html/sites/test.mydomain.com, and the settings.php file should be either a valid settings file from an installation on the same server to use an existing database or the original and unmodified one from the Drupal installation package to create a new site.
Pete.
Pete.
http://adaptive.co.uk
error step 3
HI step 3 should be [sites/test.mydomain.com] not [sites/all/test...] Other than that those steps were successful for my multisite install.
Good Luck.
You can do it without symlinks if you can set home directories
I have my setup now perfectly working without creating any symlinks because my control panel (cPanel) lets me set home directories for any domains or subdomains.
I just installed drupal straight to my root (public_html) and pointed all my subdomains and domains there via the cPanel. So whatever you type in the url bar that is parked to that domain (e.g. mydomain1.com, mydomain2.com, sub1.mydomain.com, sub2.mydomain.com etc.) it always loads the same /public_html/index.php. This then parses the urlbar and loads the appropriate settings.php (e.g. sites/mydomain1.com/settings.php, sites/sub1.mydomain.com/settings.php etc.) and thus the correct database.
This is almost identical to the steps that Particular_One has followed, except the settings.php needs to be in public_html/sites/test.mydomain.com not public_html/sites/ALL/test.mydomain.com as pete has pointed out. And I placed my existing settings.php from my previous installation as my database was already setup.
If you cannot set the home directory for each subdomain (my old host control panel didnt let me, it automatically created /www/subdomain1) then you probably would need to create a symlink to the drupal folder. A redirect will NOT work as it will just REDIRECT the site to the drupal folder and the url will change to drupal (so the correct settings.php will not load)
I also have /public_html/files/mydomain1, /public/files/sub1, etc. and set the appropiate folder (files/sub1, files/mydomain1) in the admin/filesystem settings for each site for the appropriate folder. (This step is optional, it just helps keep the data for each site in seperate folder for easy backing up/restoring/transfering etc. The folders can be called whatever you like as long as they are referred to with the same name in the settings.)
When I get a chance I wanna try and summarize what I've learnt during this time and post it somewhere...
Ready for Round II
With a fresh back up in hand--or, on hard drive rather--I'm ready for round two! Thanks to Pete's and high1memo's clarifications, I've repeated the same steps from yesterday...
(Quick rehash)
1. Database in existence
2. Created subdomain with document root of public_html
3. Created public_html/sites/test.mydomain.com
4. Uploaded unmodified settings.php to test.mydomain.com
5. Accessed test.mydomain.com via browser
...and it *almost* worked. I'm getting this error message:
This is what I don't get. The settings.php file is fresh out of the Drupal 5.5 tar file (same as I did yesterday). And in the past when I've tried this, I've tried using a copy of a settings.php file from one of my existing sites (which is what I believe you were saying to do, high1memo?) that I'd like to migrate to a single code base and I always got this message. That's why, like I was saying in the thread I started, I thought I could get a multisite set up set up but I couldn't figure out how to migrate the data and configurations from the existing sites.
Help me out here, guys--I'm so close and the prospect of doing this without symlinks is thrilling! :)
When first getting my head
When first getting my head around this, I made use of the site settings array found in the bottom of the settings.php to add notes-to-self (eg by hard-coding the site name) to absolutely ensure that the right settings file was being found and used
"This is the default/settings.php site - do not use!"
You may also add debug output in that file if the process is (as it seems) stalling before even that point.
I've seen the message before, but can't recall exactly which fix was needed. I suspect it's option 3, as it implies that a valid connection string WAS found, but the database it's pointing to is not the shape that was expected.
Could also be DB authentication was OK - but the target DB is empty.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Thanks for Trying to Explain
But I'm afraid most of what you said went right over my head at Mach 2. Well, maybe not *quite* that fast, but you get the idea.
'Add debug output'--this sounds like PHP-speak? I haven't learned PHP yet. 'Valid connection string'--not a clue, unfortunately. :(
I haven't tried doing anything one way or the other; in other words, I still have the tab with the error message open, just sitting there waiting for me to make my next dumb move. So maybe you could advise the path I should take at this point to cause the least bit of damage...should I:
1. Let everything hang, go delete the test database and make a new one so I'm sure it's empty?
2. Close the tab and delete the subdomain and the test.mydomain.com directory?
3. Change something in the settings.php file?
Or none of, or a combination of, the above?
Thanks again.
sooo close
Yup, I got that message too. I can't remember exactly what it means now (cos I've seen SOO many messages)... but I'll try and remember... I think its a good thing though.
To recap:
1. if you want to create a NEW drupal site on a shared installation then you put a FRESH settings.php in public_html/sites/test.mydomain.com
2. if you already have the database setup (from previous installation) then you should use your old settings.php in public_html/sites/test.mydomain.com - actually this isn't vital, more info below.
If you put a fresh settings.php, and enter the name of a blank database, it fills it up ready for drupal and you're site is ready to be used.
if you put a fresh settings.php and enter the name of a used database (from prev install), you will get this message that you're gettig 'drupal already installed'. What its saying is that the database is already full, but as far as I remember it still sets up your settings.php as necessary and your site is ready to go! If it isn't, try running update.php, can't remember if I did that. If it still doesnt work just edit the settings.php manually, there's only one line to change where you enter your databasename, username and password.
One other thing maybe worth noting is the permissions. a blank settings.php should be 644, and the settings.php with the username, database etc already in it should be 444.
P.S. What I've done now is add a public_html/sites/__CLEAN/settings.php which has the settings.php from a clean install. When I want to add a new site I just copy that one.
Hope you get it sorted soon!
Thanks~
On first read, that seemed a little clearer. I'll go back over it again nice and slow so it all sinks in. Trial and error is my signature modis operandi so I guess I'll quit stalling and just go have at it. After all, that is why the restore button was invented wasn't it? ;)
Congratulations
When you document this, I think there is a section for multisites in the handbook. If not, there is definitely a "How To" section. You might also want tp ost it on the multisite group on groups.drupal.org.
Would you mind pointing out which cPanel items you used, please?
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
Here's the instructions I followed
http://drupal.org/node/107347
Pete.
http://adaptive.co.uk
I got it to work without using symlinks
Hi All.
I tried redirecting one of my multisite domains directly to my Drupal installation instead of to a symlink, and it still picked up the settings.php in the domain's directory in sites.
So it would seem that Drupal will serve up a site based on the settings.php file in the sites/default folder if and only if the sites folder doesn't contain a directory whose name matches the domain.
Pete.
Pete.
http://adaptive.co.uk
You've probably already seen
You've probably already seen it, but for reference, there is a large section in INSTALL.txt under the heading "MULTISITE CONFIGURATION" that explains the naming system for subdirectories within sites.
Definitive answer on multisite configuration
From includes/bootstrap.inc :-
/**
* Find the appropriate configuration directory.
*
* Try finding a matching configuration directory by stripping the website's
* hostname from left to right and pathname from right to left. The first
* configuration file found will be used; the remaining will ignored. If no
* configuration file is found, return a default value '$confdir/default'.
*
* Example for a fictitious site installed at
* http://www.drupal.org:8080/mysite/test/ the 'settings.php' is searched in
* the following directories:
*
* 1. $confdir/8080.www.drupal.org.mysite.test
* 2. $confdir/www.drupal.org.mysite.test
* 3. $confdir/drupal.org.mysite.test
* 4. $confdir/org.mysite.test
*
* 5. $confdir/8080.www.drupal.org.mysite
* 6. $confdir/www.drupal.org.mysite
* 7. $confdir/drupal.org.mysite
* 8. $confdir/org.mysite
*
* 9. $confdir/8080.www.drupal.org
* 10. $confdir/www.drupal.org
* 11. $confdir/drupal.org
* 12. $confdir/org
*
* 13. $confdir/default
*/
As the conf_path() function sets $confdir to 'sites', that pretty much explains it!
A small 'Eureka' moment... it was as if I heard a voice telling me to 'Use the power of the source...' ;-)
Pete.
Pete.
http://adaptive.co.uk
Also
This is also in the settings.php.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
Well I got mine working, thanks to everyone...
well almost. After reading through every single post on every single thread mentioned here i've got my setup working perfectly (almost, more on that later).
I think the key confusion (at least for me) is that there are two very distinct phases to getting it to work. One is setting up drupal for multi-site, which is the /sites folder with the subfolders for each additional site with the settings.php (e.g. /sites/sub1.mydomain.com/settings.php etc.). And that is unchanging, there are rules for it in the handbook which you follow and its actually very straight forward.
Then there is configuring your host with the subdomains and addons to read and serve the right stuff - this is actually nothing in particular to drupal, and can vary from host to host, depending on what your software config is or what control panel you have etc.
I currently have all my subdomains and addons working perfectly off a single codebase. I installed drupal in a new folder public_html/drupal, removed all my existing subdomains and addons via cPanel, and then re-added them this time setting all of their home folders to public_html/drupal and hey presto... works like a beaut.
So i also didn't need to create any symlinks, as some people did. I guess it depends on your control panel. The post here http://drupal.org/node/125539 is probably a bit misleading as in my experience with cPanel i didn't need to go through all that complicated stuff.
Now I am down to 2 slight problems:
1. My homepage!! when you type the url of the main site, it goes directly to public_html. I cannot set the root folder of my main site, but I need it to point to public_html/drupal (thats where my install is). i could just move the install to the root, that would definitely simplify things for now, but it will probably make upgrading to a new version later a bit more complex. So i think I need to setup a redirect to public_html/drupal via the htaccess or something.
2. the files!!! Obviously I don't want all of the files of all sites in the same folder. In the admin/filesystem you can specify where the files should go, but then there is also where the logo of the theme goes and the favicon... so its not just one thing to change but a few. Also I wanna give relative paths, but I can't get out of where i am. I can say files/vdmx for vdmx.memo.tv or files/abc for abc.memo.tv etc. But then all the files are in public_html/drupal/files, which I don't want, i don't want any data in there. I would like a structure public_html/drupal, public_html/vdmxdata, public_html/ but I can't find the relative path to do that... I do .../vdmxdata which I think would have worked but of course it looks for vdmx.memo.tv/vdmxdata, which doesnt exist cos vdmx.memo.tv is public_html/drupal. And strangle enough for attached files it looks for vdmx.memo.tv/vdmxdata/files!! (dunno where that last files comes from!). So the only solution I found is to put the data in public_html/drupal/files/vdmx/files (and put vdmx in the filesystem settings). strange..
P.S. many thanks to all those who patiently posted all their solutions and suggestions to get this thing working...
A redirect file (in
A redirect file (in .htaccess, or a small asp or php file) in your public_html directory will fix your first problem.
But, if you're going to be redirecting from public_html to public_html/drupal anyway, why not just make public_html your drupal install directory? That way, your drupal root will be public_html, and you won't actually have to do a redirect to public_html/drupal? Plus, you could then set your files storage path to drupal, vdmxdata, etc., and those would be directories within public_html.
Thanks for your help!
You've explained it very clearly, and clarified the issue regarding redirects and filesystem settings for me.
There seems to be so much fuss about multisite when it's what Drupal does by default... the rest is a host configuration issue.
Pete.
Pete.
http://adaptive.co.uk
regarding the first issue I
regarding the first issue I found this post which pretty much answers it
http://helpdesk.hostmonster.com/kb/index.php?x=&mod_id=2&id=308
but I think i may just scrap it and install drupal in the root. I just wanted to keep it clean so if i need to delete drupal and reinstall (e.g. v6) I can just delete the folder... but it may be too much of a headache.
Regarding the files problem that is really turning out to be a pain. It seems that when you upload files, images etc, the path is hardcoded into the database! kind of, i dont understand it really.
e.g. In the mysql database all the entries are currently files/doc1.doc, files/doc2.doc etc. So if change my filesystem path to just 'vdmx' it doesnt find them cos I placed them in 'vdmx', but it looks for those files at vdmx/files/doc1.doc, vdmx/files/doc2.doc - BUT when i upload a file after that change it adds it to vdmx not vdmx/files! BLOODY ANNOYING.
Yes, that is true. The
Yes, that is true. The "path" to the file relative from the files storage directory is stored in the database, and changing the directory setting on an existing site will break the paths to files. This is why the form field description for that setting says "Changing this location will modify all download paths and may cause unexpected problems on an existing site."
I feel your pain, and certainly this is a known issue and there's been talk about modifying this behavior to make it easier to change locations for existing sites. Unfortunately, Drupal 6 is in a feature freeze, features like this are not backported to past versions, and Drupal 7 has not opened up for development yet. So, this behavior won't change until at least Drupal 7, and only then if someone writes a patch (and it is committed). I've seen discussions about major file handling revisions in Drupal 7, however, so I think it likely that this will be changed then.
In the interim, though, one option that you have is to modify the table manually using phpAdmin or other sql tool, to correct the existing entries.
yea I kinda learnt that the
yea I kinda learnt that the hard way! the text could have been a bit more explanatory than just 'unexpected behaviour' ... i.e. WONT WORK
my favorite line of sql right now is (typed in phpmyadmin):
update files set filepath = REPLACE(filepath, "files/", "")
that removes the path alltogether (unless it was in files/images/xxx, so just images/xxx remains) - but it still works cos that path is then relative to the new filesystem path... e.g. files/vdmx/images/xxxx
videos was a bit trickier, cos they aren't relative to the site files path, they are relative to the drupal install so you can't use the same sql for all databases but need to actually put something like:
update video set vidfile = REPLACE(vidfile, "files/", "files/vdmx")
etc.
but actually in the end its still a quick n easy batch process fix... its just the time spent hair-pulling trying to figure out what exactly to do. Theres a helluva lot of info on these forums, but theres just tooo much info, so it can be hard to find what you're looking for, especially when you don't know specifically what your problem is so you can't be too precise with the words you use to describe your problem - ending up with inaccurate search results (i.e. hundreds of pages with hundreds of posts with people having problems kinda similar to yours but quite different).
but hey, i'm not bitchin.. it is free after all!!
:) I'm glad that you got it
:) I'm glad that you got it working. Please consider leaving some comments on the handbook pages that you found (un)helpful, detailing any additional comments that you think would help clarify things. Or, choose Create content and author a new book page altogether, if you think that would be easier or more appropriate.
Thanks Keith!
Perhaps we should compose a book page concerning what to do when moving a pre-existing Drupal site to a multisite configuration; the documentation seems a little sparse, and it seems to be something that people want to do now...
Pete.
Pete.
http://adaptive.co.uk
Amen
I can guarantee if it is the Cookbook, it will get updated. I'd even be willing to be a "clearing house" for this.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
Good going!
Sounds like you got there!
The files rewrite was always going to be a little bit of a hair-puller. But you got your hands dirty and saw what needed to be done, so that's great.
At that point, a lot comes down to exactly what you had before and exactly what you want to transform it to, so precise migration instructions may be hard to write ;-)
In special circumstances, it would have been possible to patch the issue with changing 'files' directory on-the-fly via apache redirects or something, although all that would really do is put off the real problem. Your text replace in the DB is the needed best fix. I too wish it could be a little more 'relative' and there is discussion ongoing about how best to preset the multisite 'files' directories (I unfortunately go for /sites/mysite.host/files/* nowadays - but that's not perfect either)
Anyway, if you can doc the exact php snippet that will repair all your file links following a files/ dir change in the handbook, that would be magic!
I'm imagining that that code could even be woven into the admin/file-settings page ! Changing this path will have unexpected results - to attempt to rewrite and correct all filepaths when changing this value, click here!
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
I Did It!
Happy, happy! Joy, joy! I took the plunge and moved my 'dev' site over to run off the existing install in public_html and son-of-a-gun if it didn't work--without symlinks! It was so painless it's almost unbelievable (maybe I had better pinch myself!) ;) Pete, you're a genius! Thank you very, very much!
Now all I need to know to polish off my newly acquired skill and proceed to moving the rest of my sites is how to edit the database? I copied my old files/ folder over to the new instance of my 'dev' site as well as the old sites/all and sites/default, but the modules aren't showing up in the admin/build/modules list; images aren't showing up and the color scheme has reverted to the default Garland blue. I take it all these things are correctable by editing the database using phpMyAdmin, but I've never done anything in there before so I'm wondering if I have to start at page one of some phpMyAdmin manual that will probably read like Greek to me or if someone can give me a quick run down in English of what I need to do (pretty please with sugar on top!)?
Well...
The modules should be in sites/sitename/modules (not /default/) and the theme in sites/sitename/themes to start with. At that point they should show up.
Your Garland settings are in the files directory, usually in a folder called "color." Check your files settings. This would affect your images as well.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
I'm glad it is working. You
I'm glad it is working. You created a directory inside sites named something like mydevsite.example.com (but with your own domain name), right? Did you copy your old
settings.php(from the sites/default directory from the "old" site) to this new directory? That file should contain the dburl string in settings.php that tells Drupal how to access the database that matches your site url.(In other words, inside sites/ should be directories corresponding to each url that will access your site, and also a "default" and an "all" directory. In each of the directories named for a specific site, you need a settings.php that contains the database parameters for that site's database. The settings.php in the default directory defines the database connection parameters that are used when a directory inside /sites does not match the URL. You can make a "modules" and "themes" directory in the "all" directory, and put contributed and custom themes and modules there that you would like to enable on all sites. Or, you can make a "modules" or "themes" directory in a specific directory that matches a URL under /sites and put contributed or custom modules and themes there as well, and they will only be available to that specific site.)
One Down, Two to Go!
@Nancy: Thanks for the info. I thought I was supposed to replicate the same file structure of the old 'dev' site:
public_html > dev > files
public_html > dev > sites > all > modules
public_html > dev > sites > all > themes
public_html > dev > sites > default
That's why I copied the 'files' and 'sites' directories into:
public_html > sites > all > dev.domain.com
As per your instructions, I've changed this to:
public_html > sites > dev.domain.com > modules
public_html > sites > dev.domain.com > themes
The modules are now showing up in the module list. The color directory is in the 'files' folder, but nothing changed there. So this means my path isn't correct in Administer > Site configuration > File System, right? Should it be 'sites/dev.domain.com/files'? I hope so because I didn't heed the warning that says, "only change this setting on an existing site if you know what you are doing" and that's what I changed it to. Must not be right yet as there's still no images either (although I know the 'images' directory is located in sites/dev.domain.com/files and permissions are good.)
@Keith: First, thank you. Second, yes--I created sites/dev.domain.com and copied the 'old' settings.php file from public_html/dev/sites/default into dev.domain.com.
Ok, now I'm clear (I think) on the contributed modules and themes directory thing. If I have a module or theme I want accessible only to dev.domain.com then it needs to go in sites/dev.domain.com/modules and sites/dev.domain.com/themes respectively. But if I intend to share a contributed module or theme among all my sites I would put it in sites/all/modules or sites/all/themes--yes?
My apologies if I'm overlooking the obvious or being exceptionally thick...I got up *way* too early this morning and can hardly keep my eyes open. I'm sure all you all's advice will be crystal clear to me tomorrow over a cup of fresh coffee, so I'm signing off for the night. Thanks again for the help; it's greatly appreciated.
Hmm...
I'm up too early too. It looks like you've got the modules under control.
Garland is kind of finicky about being moved from one site to another. I usually just regenerate it as the easy way out. You might want to look at this for your next project: http://drupal.org/node/196007. That's how I do it and find that redoing Garland is a piece of cake and I just don't worry about any other problems.
Images: About all I can think of is to go through and make sure all the directory pointers are what you think they are. The other thing I've seen is what one of the others posted above about having to go in and fix the paths in the database. I have had that problem in moving a site before, and will probably have it again as I go through my current moves.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
Files
Hi!
@Peculiar_One : The general consensus seems to be that you should create a folder in the files directory like files > dev or whatever and set the file system to point to that.
Pete.
Pete.
http://adaptive.co.uk
Excellent :-)
Really pleased that you got it working; it's a steep learning curve but you learn so much along the way...
You can create directories for themes and modules in a domain's directory under /sites. Files would have been nice, but that's an issue that can be pursued.
Modules and themes that should be available to all multisite should go in sites/all/modules and sites/all/themes; any site-specific modules and themes should be in sites/your_site/modules and sites/your_site/themes.
Hope this helps,
Pete.
Pete.
http://adaptive.co.uk
Files questions
I am not a proponent of the files in the sites directory. I much prefer it separate. I put another directory structure in files that matches my sites, but with much shorter names so I don't have to type really long names to reach a file.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
OK, I agree.
Hi, nancyw.
files/sitename makes much more sense, on reflection.
On a *nix server, you can make sites/sitename/files a symbolic link to files/sitename anyway, so as Larry Wall would say, "There's more than one way to do it". :-)
Much of this discussion seems to be about "How do I get a Drupal multisite installation working on my particular host", but much light has been shed on how it actually works.
The points raised regarding the ability to set (or not) the home directory for a domain, and a PHP solution for creating symbolic links when the domain's home directory is set by the host are worth noting.
I'll make a start on the documentation, but I could use some help from fellow voyagers, particularly Peculiar_One and high1memo ...
Pete.
Pete.
http://adaptive.co.uk
Great
If I get a little time tomorrow I might start my voyage too. If you need help with documentation, I can definitely help there.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
congrats
glad you got there in the end. You are totally right about "How do I get a Drupal multisite installation working on my particular host". Like I've mentioned before I've realized the drupal side of things is actually pretty easy (just setting up a sites/mydomain.com folder!), its the host/unix stuff which is tricky if you don't have a clue about vhosts and parked domains and symlinks etc. In retrospect though I can't believe how straightforward the setup actually is once you know what you are doing!
I've started putting together what I've learned (so far just copy pastes from this thread and the dummies one), I'll probably make it a fresh page (or multiple pages to cover the different aspects) somewhere as I find it sometimes hard to follow all the comments on existing book pages sometimes.
P.S. I went for the /files/sitename route for my data. Remember that if you use a custom site logo or favicon these are independent to the filesystem setting, so you need to change them too (they're relative to the drupal folder I think). And the video module also ignores the filesystem setting (again relative to the drupal folder). And to complicate matters more theres that problem of the absolute path (relative to drupal, NOT the filesystem setting) being stored for all uploaded files, images etc. So if you are changing the location of an existing drupal installation (like what we have done) then you need to edit all the paths of all existing uploads - best done directly in the database. The sql queries mentioned at http://drupal.org/node/205000#comment-675077 cover images, file attachments and the video module. But other modules may need to be treated separately. But if you are starting a new site then none of this is of any concern.
P.P.S. I placed nearly all my themes and modules in the sites/all folder (e.g. a few standard good looking themes, and modules which I use a lot, image, cck, captcha, video, views, panels etc.). That way creating a new site is simply a case of doing a new settings.php. I can then just enable whatever module(s) I want, and also updating the modules is easy... just need to update it in one place. Custom modules and themes of course which are site specific are in the sites/relevantdomain.com
Ahem!
Hi, high1memo!
Glad I got there in the end? I've had multisite working since 2006 :-)
Thanks for doing the documentation; I look forward to seeing it!
Pete.
Pete.
http://adaptive.co.uk
whoops
Pete, actually that post was aimed at peculiar_one!... I know you had it working... you were the one who started me out! - I guess after scrolling up and down frantically to read the 'new' posts, I clicked 'reply' at the wrong level :S
Thats one negative criticism I would have of drupal - and thats the way all the comments etc are layed out, I find it quite hard to follow sometimes, and when theres lots of branching replies its really hard to keep track of and thus a bit harder to learn. E.g. that multi-site for dummies thread was really useful, but needed quite a bit of concentration to read through and follow. A collapsable tree style comment browser could make it easier to go through... and avoid mistakes like this :P
anyways, alls well that ends well...
Catching Up
I'm just going to type as I read down through the latest posts and reply to all as needed in this one post. Hopefully that will simplify things rather than hopping around all over the place. Half the time I don't get my replies under the right comment anyway, so here goes...
@Nancy: You wrote, "Garland is kind of finicky about being moved from one site to another. I usually just regenerate it as the easy way out." What do you mean by 'regenerate'--that's the first I've come across that terminology here?
Thanks for the link to the other thread. I glanced over it; looks like some good info. The Garland theme issue isn't really a big deal for me, my 'dev' site is just my havoc wrecking grounds (at least in theory, anyway) so I don't really care what color it is. I've only got two other sites using Garland presently and they're both in their development stage and will likely be changed to something else anyhow. Just the same, I'll try following the instructions in the thread you linked to if and when those two sites come up for migration.
Re: images: I think I'm totally lost on this. Retaining or getting the images to show up again is critical for me because several of the sites are image-centric (artist's gallery, etc.) If I can't overcome this hurdle, I can't move all the other sites.
You recommend making sure all the directory pointers are what I think they are. Looking at one of the nodes in the dev site which should be displaying an image, the file attachment path reads: http://dev.domain.net/files/images/laura001_SOLD.JPG
If I look in cPanel's File Manager the path is: /public_html/sites/dev.domain.net/files/images/laura001_SOLD.JPG
Checking the File Settings via Administer > Site Configuration, it shows--"File System Path: files" ...So I changed that to "sites/dev.domain.net/files and checked the node again. Now it says http://dev.domain.net/sites/dev.domain.net/files/files/images/laura001_S..., which is obviously totally wrong. So I've deduced from this that Drupal is automatically going to public_html/sites/dev.domain.net and therefore the next directory it should come to is 'files'. If that's correct, then in the File Settings is *should* say 'files' (as it did originally...but the image isn't showing up even though it literally does exist at that path.
This is where/why I'm confused. Does this mean I have to edit something in the database to make the image show up again? If that's the case, where do I go in there and what do I change?
@Pete: You wrote, "The general consensus seems to be that you should create a folder in the files directory like files > dev". Ahh! I have it backwards again; you're saying that instead of public_html/sites/dev.domain.net/files I should be using public_html/files/dev.domain.net (or just 'dev' for short, as Nancy mentioned)? Ok, that's all starting to make sense now.
Still, I just tried doing that (created a directory named 'dev' in public_html/files; copied the contents of the dev.domain-files folder to it and changed the File Settings to files/dev and I still don't have images. Man, this is frustrating! Here I was all psyched and raring to go and I can't get out of first gear. :(
Hey, I'd be happy to help--almost honored even...except that 1) I wouldn't have the foggiest how to go about it and 2) I really feel that before I go about attempting to document a success I should achieve a complete one myself. I'm close, but I still haven't earned that cigar. ;)
@high1memo: Now you're getting to the meat of the matter as far as my particular situation goes. I saw your mention of the SQL stuff earlier, but I'm afraid I need a more simplified explanation. Where in phpMyAdmin do I type "update files set filepath = REPLACE(filepath, "files/", "")"? That's a spooky looking place, you know? Like, it looks to me like I could do some serious damage if I just breathe wrong while in there! =8-o
I intend to do that too with the modules as most of my sites will be using the same ones anyhow. One thing I've been wondering about (although at this stage I'm putting the cart before the horse) is what, if any, the difference in upgrade steps will be with a multisite set up like this. For example, the instructions I followed said to set your theme to Garland and disable all contributed modules, so if you have 6 sites you would still have to repeat these steps 6 times on each site, right? The 'saving of work' comes when updating modules, as you were saying, because if they are shared among six sites you only have to update one module once. Is that correct?
Hi Peculiar, "What do you
Hi Peculiar,
"What do you mean by 'regenerate'--that's the first I've come across that terminology here?"
When you change the colors of the garland theme (or any theme which supports the color module), drupal creates a new css file and places it in your files folder. Thus when you move your files folder it may not be found again.
Regarding where you put your files folder, thats totally upto you. You can put it in public_html/sites/dev.domain.net/files or you can put it in public_html/files/whateveryouwannacallit. But doing either will NOT make your images appear. This is what you gotta do to make your images appear:
1. create your files folder and move all your data there. e.g. public_html/files/dev. so your attachments will be in public_html/files/dev and images will be in public_html/files/dev/images (if you havent changed the default for the image module).
2. set your file path to point there in admin/filesystem (enter files/dev or whatever you called it).
This will ensure that all FUTURE images, attachments etc will go in the relevant folder. Unfortunately the old path is already hardcoded in the database so needs to be fixed directly in the database (make a backup of the database first!):
1. start phpMyAdmin (if you are using cPanel press the icon)
2. in the dropdown on the left (under 'Database') select the database your site is using (whatever you said during installation)
3. On the right side of the window, there will be an SQL tab at the top (the 2nd one on my version - 2.9.1.1), click that.
4. A big textarea appears, thats where you type in the queries to batch update the paths.
For file attachments and images type:
update files set filepath = REPLACE(filepath, "files/", "")
and press GO (this scans through the table called 'files' and for every item it looks at the field called 'filepath' and if it contains the string 'files/' it deletes that bit. So 'files/images/myimage.jpg' is reduced to 'images/myimage.jpg'. Then when drupal loads that item it prefixes whatever you set in the config and loads 'files/dev/images/myimage.jpg' )
it should come back with 'Affected rows: ####', thats good news.
Also for user profile pictures you can type in the same place:
update users set picture = REPLACE(picture, "files/", "")
The same tactic (of removing the file/ altogether), didn't work for videos in the video module. So for them you need to put in your new path instead:
update video set vidfile = REPLACE(vidfile, "files/", "files/dev_or_whatever_you_called_it")
Any other modules may need to be updated accordingly (I think most use the standard file module so should be covered by the first query). In the SEARCH tab (next to SQL), type in 'files/' and select All the tables in the listbox underneath. This will tell you what tables have that string in it, then you can browse those tables and see what fields need to be modified if any (when you click on a table name, by default it enters the table in STRUCTURE mode, you wanna select the BROWSE tab to see the data). There will be many tables with 'files/' in it, like cache, watchdog etc. You can ignore those.
And thats about it... good luck!!
P.S. all of this could be put in a simple php file but I'm not sure if it will ALWAYS work for everyone, so I'm too scared to try and screwup everyones sites. One situation where it most definitly won't work is if you have multiple sites using the same database. Then you'd have to modify the query to include the table prefix - unless you do want to fix ALL sites in one go...
Regenerate
What you mention is what I mean by "regenerate" - based on what the color module does.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
I Kind of Figured it Out
By accident. *grin* Every site that had Garland as the theme reverted to the default color scheme, but whenever I went into themes/configure the custom color scheme I had been using was still displayed--all I had to do was hit 'Save Configuration' and bingo! When I saw that this was the case, I figured it was what you were talking about.
Then, since I was apparently having a 'smart cookie moment', I went into cPanel's File Manager, navigated to the color folder and found out that by viewing the file named 'screenshot' I could easily enough determine which was the most recently created directory (if there was a color difference in the screenshots), and if not, I simply moved one of the folders into the tmp directory, refreshed the site to see if the theme stuck or not, then deleted the appropriate folder.
...Always a learning experience with Drupal. :)
Hi Memo
Thanks very, very much for explaining what to do in phpMyAdmin--it was a big help to me to have those step-by-step instructions and I'm sure many other neophytes will benefit from the info, too.
Unfortunately, it didn't make my images appear again. I suspect that this might be due to me changing the Admin/File System paths around several times before you posted the proper way to handle it. I got the "Affected Rows: 10" message, so I'm pretty sure I did that part right. Beats me what it is. *shrug*
The only sites I have left to migrate are the live, image-centric ones and since I had such great success moving all the others, I got brave last night and tried one of them (because I wanted to try the phpMyAdmin thing again). I'm not sure what happened (because I have the migration steps written down and have already followed them successfully several times), but this site took me to mydomain.com. I tried everything I could think of to correct it, but ended up having to do a restore. I thought I'd try again this morning while wide awake; carefully followed the exact same steps and still it wouldn't go right. I ended up getting locked out of the site. Adding 'user' at the end of the URL didn't help because the theme was gone; all I got was an "Access Denied" error or a white background with text, but no log in box or administrative navigation links. Needless to say, I had to restore again.
I think I'm going to take a break from trying this, but I do want to thank you all again for your help in getting me at least half set up how I wanted. If I have to leave the set up as it is now I can live with it--so thanks again all! :)
One step forwards, two steps back...
Hi, Peculiar_One.
Yeah, take a break. You can get to the point where you can't see the wood for the trees. Happens to me all the time.
There's a logic behind all this, and it's all still achievable...
Pete.
Pete.
http://adaptive.co.uk
Change the focus
I often find at a time like this that it's good to start typing my notes to document the process. Occasionally I find mistakes in my notes or in what I did. So then not only do you fix that problem, but you have your documentation in better shape.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
Good Idea, Nancy
When I get frustrated with my newest Drupal project (which is fast starting off that way), I think I just might come back to this and give it one last try and do the documentation thing...while I can still read the chicken-scratch-for-notes I have scrawled on scrap paper, that is! :)
@Pete: Thanks for the kindly words of advice. I agree completely. I also happen to love logic...except when it eludes me! ;)
Be careful with the sites/all folder
Remember, even if a module isn't enabled, it takes up resources on your site. I agree that if a module is on 50% or more of the sites, it's probably better to use sites/all, but less than that, it's probably better to use sites/sitename...
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
Ya think?
Hang on, What?
That is not, and cannot be the case.
The only time the amount of unused dross in sites/all would even be noticed by a running Drupal process is when you visit admin-modules and it rebuilds the inventory.
For normal page loads, extra disabled stuff in sites/all is totally un-noticed, and never invoked. You could check out the entirety of drupal.org/contrib into there without affecting the operations of a normal site instance.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
I'm not entirely sure that's right either
Visiting admin/modules seems to be the only time the directory gets scanned; I've got all the contrib modules that I'm experimenting with in sites/all/modules and haven't seen a performance hit on any of the sites that don't have the modules enabled.
I noticed that visiting admin/modules does make Drupal parse all the modules; I don't think that it parses, let alone loads, the modules that aren't enabled.
In all fairness, the modules *do* take up space on the site, but not a great deal given current hosting packages.
If it wasn't so late, I'd read the source code.
Pete.
Pete.
http://adaptive.co.uk
Looks like the file settings in the database will need to change
This whole absolute/relative path thing is a bit of a an issue with Drupal, as is the fact that changes to the database aren't retroactive; even things like teaser lengths.
Don't panic, It's fixable.
Pete.
Pete.
http://adaptive.co.uk
There are ways
There are ways to correct all of that. And, trust me, you want everything corrected BEFORE attempting the D6 upgrade.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
Just Subscribing
Just Subscribing :)
I'm planning to make mi Drupal into a multisite in the future and all this information is really interesting and useful!
Drawbacks?
The only "drawback" I have found so far to making a multisite is that you have to remember to visit every site in the group and run update.php after every core or module update. But that is still less work than uploading all the files to every site.
NancyDru
If I have 3 URL like xxx.com,
If I have 3 URL like xxx.com, xxx.com.nz and www.xxx.com, do I need to create 3 sub-folders in sites?
Well, xxx.com will cover both
Well, xxx.com will cover both that URL and www.xxx.com. So that means you will still need xxx.com.nz. Unless, of course Apache ReWrite rules have intervened, which is often more convenient. But, even with two sites defined, they can point to the same database, so they are the same site.
NancyDru