How move sites from Multi-site Setup to Single site setup?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
pamreed's picture

I started with multi-site configuration for my sites. Now I decided I really want to have them as single site setup.

Currently, I have the standard mutli-site setup with my sites separate like following and each sites has own database.
www/drupal/
/core directories and files
/default
/sites
/sites/all/modules
/sites/all/libraries
/site1/
/site1/files
/site1/modules
/site1/themes
/site2/settings.php
/site2/
/site2/files
/site2/modules
/site2/themes
/site2/settings.php

Now I want to change to the either having the sites using the default or even willing to stay with multi-site setup but only have one site per drupal core install.

I have tried both ways for a site and can not get it to work. Do I need to be login and disable all module before moving everything? I keep getting not found on all the pages, it gets the themes and the home page. I checked the database, clear the cache table manually. I can not get logged in, will not event let me to the user login page. Note this is a development environment so I just trying to figure out how to do it and have the correct steps before actually doing it on the live sites. I feel I am missing a step that has to do with path.

Any help would be great, for I am stuck.

Thank you,
Pam

Comments

It should be as easy

Garrett Albright's picture

It should be as easy as:

  1. Download and unpack a new Drupal installation
  2. cp -r /path/to/old/drupal/sites/site1/* /path/to/new/drupal/sites/default/
  3. Configure your server to serve site1's domain name using the new Drupal installation directory as the webroot
  4. PROFIT!

Could you give more information on what you've tired that didn't work?

That is what I thought

pamreed's picture

Thanks for replying so quickly. I was typing up the what I did (step by step) when I realize that I bet the .htaccess did get copied. It did not get copied once I copied it the sites there started working. Thank you. I had not thought of it until I start type the exact steps I did, then light bulb time. This was a life saver, it I have been trying to figures this out for days. I just need to take a step back and step through it again. Thank you, thank you. Now I need starting reading about this .htaccess file to understand more and why it is necessary. It was on my to do list, now it at the top.

Thank you again.

Need Help

cmckay's picture

I'm trying to accomplish this very task also, but am still stumped

Yes - same issue - any ideas >> Multisite 2 SingleSite

brett1's picture

I thought it would be as follows:

Copy multisite root installation to newsite
Copy multiste/site1 database to newsite database
Copy multisite themes and modules and files to newsite sites/all
change newsite default settings.php to point to new database.

Well - i think i did that - I couldn't really tell because I moved from a live site to a local site
and (I'm new to local sites) I think I had the wrong theme on and did not know how to get into
the themes on a local site.
It appeared that some of my menus came across - but only 1st level, and I couldn't check find content.

what is the goal?

scothiam's picture

Depends on what you are trying to accomplish? Is this a case of just moving all the code (modules) into one location (sites/all vs. sites/site2, sites/site3, etc), are you merging sites, or are you promoting a secondary site to default?

The only reason I can think

Mile23's picture

The only reason I can think of why you'd want to split out a mulitsite setup is administrative. That is, so you can put them on different machines for load balancing or what-have-you, or give different admins access to different Drupal installations.

Otherwise there's really not much to gain by splitting up the multisites.

ok - the logic for splitting

brett1's picture

ok - the logic for splitting up the multisite - is moving it to another server as I developed the site for someone else and they can't mirror the subdomain that the multisite is stored on -( I'm not sure if theres a work around on this )
Also - multisite kind of freaks me out - I have maybe 30 subdomain sites on one multisite. I am concerned of updating drupal core or any of the modules.

so . . . I want to move multisite to single site and migrate (all content, modules, included.)

Brett, Can't speak to the

Lakeside's picture

Brett,

Can't speak to the upper limit of the number of domains that can function with a Drupal multisite.

You're more likely to have an issue with your hosting provider than with Drupal. You might want to take a look at this about hosting company gottcha's. http://www.blogtooltips.com/virtual-host-gottcha

hi

brett1's picture

thanx for the quick response but i don't think you read the issue -

its not that I'm having problems with the multi site -

I am just interested in migrating it

Aegir?

scothiam's picture

This is an old thread... Did you try Garretts suggestion? If you are simply breaking off sites from a multisite, that should do it... I think it wouldn't hurt to run update.php to be on the safe side... Would love to hear what worked, what did not.

If you're going to be doing this a lot, check out aegir. I hear you loud and clear- imagine updating some modules shared by 30 sites and getting all the way to site 29 and getting a wsod. Apparently, aegir has methods of dealing with that (abort and revert on problem with update). http://drupal.org/project/hostmaster

Doubt that is helpful for splitting off from an excisting multisite...

Brett, Weren't you talking

Lakeside's picture

Brett,

Weren't you talking about migrating 30 sites to a Drupal multisite?

Like I said, Drupal may not be the problem if you are at all concerned about organic SEO. If you have 30 Drupal independent sites there's info that you should still be concerned about.

As for migrating to Drupal 7 multisite there's an article regarding that too on the site.

more on this ....

brett1's picture

Hi,
Lakeside --- no the otherway round, 1 multisite with 30 subdomains to have their own domains.
I'm only interested in moving one though.

I know this is an old post , but its the best description that i could find on search ---

I think I'm getting somewhere but I'm going to document it here.

Let me define the sites:
Root_Site
Root_Site/Domain
Domain_Site.

So... I'm moving root_site/domain to domain_site

So far ...
I copied root_site (except the sites all folder) and moved it to domain_site
I then copied the database for root_site/domain and duplicated it for domain_db
so far I think I'm on the right track

This is where I think it goes wrong
I then copied root_site/domain and placed it in the sites folder ***??? not sure about this move
and changed the settings.php to point to domain_db

so .... I have the root installation for the multisite duplicated with a /sites/ folder structured as follows:

/files
/modules
/themes
/temp
default.settings.php
settings.php (modified)

Next I was expecting to maybe run an update ---- but a strange thing happened.
when i went to my domain.com it has a drupal installation page???
i was not expecting that --- well I think this is an issue I need to solve sooner or later,
right now I'm not sure what my next step is, I was thinking of structuring my
domain sites folder differently by putting the files in subfolders

sites/all/files
sites/all/modules
sites/all/themes
sites/all/tmp

sites/default/files
sites/default/settings.php
sites/default/default.settings.php

I'm not sure if this will make any difference though --- will keep yous posted.
Any advice is appreciated

ok, tried the steps and site

brett1's picture

ok, tried the steps and site crashed --- got the following

Fatal error: Call to undefined function webform_menu_load() in /home/USERNAME/DOMAIN.MULTISITEROOT.com/includes/menu.inc on line 577

surely if theres a way to go to a multisite there should be a way to go back ???

Lakeside's picture

Brett,

You don't mention your hosting company. This is an article specific to installing Drupal 7 on a GreenGeek server: http://www.blogtooltips.com/drupal-7-multisite-greengeeks

Don't know why, but have found with some hosting companies that you can use an auto install of Drupal, but not with all. Best to do your own install of Drupal of each site first to get the DB built. The multisites need to be built at the root level; it avoids a lot of problems doing it the 'old fashion way'.

If you want to do the reverse, meaning you have a multisite and want to run it with independent core code, then simply change your domain from parked to assigned in the CPanel. Then do an install of the domain you want to move in the root directory with a new database. Once complete, all you need to do is move the settings.php file from the multisite to replace the one newly created for the single core site. If you want you can remove the DB created for the new site.

Of course, this is assuming that you are using a virtual hosting company.

got it

brett1's picture

holy #@%$%$^ got it !!!! :>

ummm , now to remember what I did,
I ran the installation - it then asked for my settings file - so i got an old settings.php (and example.settings.php) file and dropped it in the sites/default/
drupal then asked for the database - so put that in and it said - yes theres data in there already, run update or view site
so i did both - the site appeared blank - so I /user to sign in - after refreshing the page a few times i got in.
sth site looked ok but wrong theme - I also had the admin bar avaliable now - so I installed the theme ---

in short ---- the solution was to put the files up one directory as far as i can tell into the /default directory.

sites/default/files
sites/default/themes
sites/default/default.settings
sites/default/settings.php

I still have sites/
default
files
modules
tmp
default.settings (from original multisite
settings.php (from original multisite)

-- the site still is not correct but at least its there - its missing images and a few things but I think thats got todo with having
the folders in the wrong place. so the next step is to play around with settings and perhaps run the update

but I feel that its achievable now I'm going to compare the 2 settings.php files and see how they differ and move around the folders in the sites folder

Cheers

If you are comfortable with

Lakeside's picture

If you are comfortable with working in MySQL you can go in and edit the links to the photos. (I should have thought of that before...sorry.)

update - fyi

brett1's picture

ok - i compared the 2 settings files and pretty much identical except different random keys in the drupal hash salt

$drupal_hash_salt = "random key generated here" (not sure exactly what this is or how its generated)

I am now in my Status report and there are a few folders in the wrong place that I'm plugin in.

It feels a bit piece meal - if I run an update I get an error

So .. I'm going to put the folders in the correct places and I hope it all runs ok -
still missing the images, just have the broken image thumb
I'll see if the folder moving sorts this out

Not straightforward???

greta_drupal's picture

Okay, what am I missing. I am starting to break apart a dev multisite (the beginnings of one)*, and it seems straight forward.

  1. Changed subdomain to point to its own folder. public_html ---> childsite1.com
  2. Copied all folders/files (except child sites) from parent site @ public_html ---> childsite1.com
  3. Copied/Replaced that parent settings.php file with the childsite1.com settings.php file (same one used for multisite) and add Base URL childsite1.com.
  4. Edited childsite1.com database Files table to correct file paths.
  5. In 'new' standalone childsite1.com, changed File System to "files".
  6. Ran update.php

So, far not seeing any problems with the installation, and I took a few shortcuts. Is this a problematic approach?

straight fwd once when you know how :>

brett1's picture

straight forward when you know what you doing - or when it works :>

my sites working except some of the module - in particular the images arn't connecting

how did you do stage 4?
Edited childsite1.com database Files table to correct file paths. - is this with sql or some other way??

and what did you mean in stage 5 ?

I have moved my files into newsite/..

sites/all/files
sites/all/libraries
sites/all/modules
sites/all/tmp

Thanx

4. Using PHPMyAdmin (GUI

greta_drupal's picture

4. Using PHPMyAdmin (GUI interface) to open the childsite1 database, and edit the table called "files". Click the PHPMyAdmin edit icon next to the row that you want to edit. Then, on the row/record edit form, literally just change the part of the path necessary, then click GO to save that record.

5. In Drupal: Admin --> Site Configuration --> File System (http://yoursite.com/admin/settings/file-system) Change the directory where files are stored to "sites/default/files" [no quotes] or wherever you are storing them. Change temp directory as well, if necessary.

Since mine was just the beginning of a multisite, I didn't have many file references to change. Else, it would be laborious.

You can alter paths all at

Garrett Albright's picture

You can alter paths all at once using a MySQL REPLACE() statement.

UPDATE files SET filepath = REPLACE(filepath, 'sites/domain.xyz/files', 'sites/default/files');

Just be careful to back up your data first - it's easy to hose your data running commands like this.

Or, of course, you could just continue to use sites/domain.xyz for your files and custom modules and such - in effect creating a multi-site Drupal installation with only one subsite. It will work.

Thanks!

no2e's picture

Thanks Garrett Albright, this SQL statement worked like a charm.

In addition, you'd have to change the imagecache paths, too. Don't know if it can be done in the database – I just flushed all presets (at /admin/build/imagecache/list for Drupal 6).

Very helpful

Elijah Lynn's picture

This thread was very helpful, including this comment.

If a person has imagecache and does file uploading then they will need to run the above query to get it all working properly.

One downside of keeping a single site in multisite mode is that drush won't run without specifying an alias' or giving it options. I think it is best to take it back to single site and keep it clean.

drush is context sensitive

eporama's picture

If drush doesn't have options passed for --root and --uri or have them defined in an alias, it is context sensitive. If you are cd'd into the specific multisite directory

drupalroot/sites/myothersite.com/

Just running drush will act on that specific multisite.

And if you need to replace the file paths in the files table, you can either use a module like File Maintenance or a sql statement like:

UPDATE files SET filepath = replace(filepath, "sites/default/files/","sites/mydomain.com/files/");

You'll need to do that on node revisions or other textareas where you have directly input links or srcs to files.

not just the files directory

rajmataj's picture

This is an old thread but I just had the fun task of reorganizing a butchered Drupal 6 site and making it a multisite install. When viewing the source code, any imagecache urls had a 'sites/default/files' suffix to all the image paths even though the files path was set correctly.

Clearing the cache didn't recreate any files/imagecache images - it was completely empty. So, following what @eporama mentioned, these are the tables I had to affect:

UPDATE files SET filepath = replace(filepath, "sites/default/files/","sites/mydomain.com/files/");

UPDATE node_revisions SET body = replace(body,  "sites/default/files/","sites/mydomain.com/files/");

UPDATE node_revisions SET teaser = replace(teaser, "sites/default/files/","sites/mydomain.com/files/");

After doing this, when I cleared the cache, all images were properly resolving on the site, and the imagecache directory was once again full of the images it needed. Time to get outside now.

Struggling with this on Drupal 7

mackm's picture

Not any more...

Multisite

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week