Multiple sites with one db

Post here for help with installing or upgrading mojoPortal pre-compiled release packages. When posting in this forum, please provide all relevant details. You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

Post here for help with installation of mojoPortal pre-compiled release packages

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.

You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

This thread is closed to new posts. You must sign in to post in the forums.
1/3/2007 4:12:00 AM
Gravatar
Total Posts 41

Multiple sites with one db

Hi!

Is it possible to have multiple sites with one database? What do I need to do to make this work?

I'm using a web provider. Can only have one database but several web sites.

Thanks.

1/4/2007 2:49:31 AM
Gravatar
Total Posts 18439

Re: Multiple sites with one db

Hi Emil,

Yes that should work fine.
1. Use the same connection string in all sites.
2. in the first site set the Web.config "AllowMultipleSites" = true
3. Now both sites are the same content, to make the new site have its own content go to the first site in Admin > Site Settings. You'll see a dropown next to the site name, choose "New Site", give the new site a name and click save.
4. Now more controls show up at the bottom of the page to configure the host name for the new site and which features to include. Add a host name that points to the second site and now it is independent, it no longer shares data with the first site.

I just updated the documentation for this here:
http://www.mojoportal.com/muliplesites.aspx

Please let me know if the documentation is unclear or any feedback to improve it.

Thanks,

Joe
1/5/2007 3:01:10 AM
Gravatar
Total Posts 18439

Re: Multiple sites with one db

Oh, I thought of something else you will need to do to make this work. When you create the second (or nth) site using the Admin > Site Settings of the first site, it will create a folder in the first site at Data/Sites/[new site id], so the second site will be Data/Sites/2 and the 3rd site will be Data/Sites/3 and so on. Since the additional sites are using their own web installation you will need to copy these folders to the correct location in the additional sites because by default there is only 1 folder at Data/Sites/1.

Hope it helps,

Joe
2/3/2007 4:20:58 PM
Gravatar
Total Posts 21

Re: Multiple sites with one db

I'm doing something simular..

but have a question about how to do it with medium trust set :P

from the docs.. its saying not to use the same code base..

but when I tried to create a second mojo directory, for a second site. but using the same DB.. it shows the content of my first site.

Thanks for any assist :)

2/3/2007 5:09:33 PM
Gravatar
Total Posts 18439

Re: Multiple sites with one db

Multiple sites using 1 installation is not supported under medium trust. It won't work because the VirtualPathProvider which is needed to provide each site its skins theme file doesn't work and because the search index is fixed to a single folder not a site specific folder, and maybe other reasons as well.

Joe
2/3/2007 5:21:18 PM
Gravatar
Total Posts 21

Re: Multiple sites with one db

so I can't use 2 seperate installations and only 1 DB?

I knew that it didn't work with one installation of the code base, so I tried to make it work with 2 code bases, but using the same DB.

2/3/2007 5:26:42 PM
Gravatar
Total Posts 18439

Re: Multiple sites with one db

No it should work with one db as long as you specify a host for the second site. It does require 2 web sites though each with its own web.config.

Joe
2/3/2007 5:30:34 PM
Gravatar
Total Posts 21

Re: Multiple sites with one db

that's what I have configured at the moment..

1 DB..

2 Seperate directorys

  • mojo
  • mojoRT

but when I hit the URL for the second one, which is pointed at the mojoRT directory it's still displaying all the content for the first site.

I created a new siteID and all, but I'm just not seeing how to associate that new id to the URL

and thanks for the quick replies.. I thought I was the only one demented enough to do this stuff on the weekends :)

2/3/2007 5:46:03 PM
Gravatar
Total Posts 18439

Re: Multiple sites with one db

No it doesn't work with localhost/mojo and localhost/mojoRT because it requires separate host names and in this case the host name is localhost.

It will work with localhost/mojo and someotherhost/mojoRT

If you have control of the server you can add a host name in Windows\System32\drivers\etc\hosts file
You will see in there

localhost 127.0.0.1

just add

someotherhost 127.0.0.1

Joe
2/3/2007 5:50:22 PM
Gravatar
Total Posts 21

Re: Multiple sites with one db

actually what I have is to unique domain names one going to each directory.

so not using localhost at all

when I try to send the domain directly to the mojoRT directory, I get an error saying default.aspx not found.. (or something simular to that)

so what I have to do, is in the root of the web site on the providor use a ASP script to redirect to the appropriate directory depending on the domain url in the request object.

2/3/2007 5:56:31 PM
Gravatar
Total Posts 18439

Re: Multiple sites with one db

If the domains actually point to the separate directories you shouldn't need any redirecting. This sounds like the same issue you had with the first site. Are you sure all the files made it to the 2nd site?

Joe
2/3/2007 6:04:44 PM
Gravatar
Total Posts 21

Re: Multiple sites with one db

oh the both sites come up fine

but even though they are in seperate directories, they both want to use the data related to SiteID 1, which should only be going to http://www.gamedruid.net

I need to some how tell my second URL Http://www.rtgc.org to use a new SiteID 2

just seems like I'm missing that relationship for some odd reason

 

2/3/2007 6:11:07 PM
Gravatar
Total Posts 18439

Re: Multiple sites with one db

One site has to be the master site. In the master site make sure the AllowMultipleSites setting in Web.config is set to true.

Then go to Admin > Site Settings in the master site and you will see a dropdown next to site name. Chosse create new site and then name and save the site. Now you will see more options below to add a host name for the site this will make it use a different siteid.

In the second site you will have to manually copy the Data/Sites/1 folder and name it Data/Sites/2

Joe
2/3/2007 6:30:52 PM
Gravatar
Total Posts 21

Re: Multiple sites with one db

Getting closer now :)

I had created teh New site.. but not from the master..so yeah.. it screwed it all up,

but I did copy 1 over to 2 but now get the following error:

The file '/mojoRT/Data/Sites/2/skins/layout.Master' does not exist.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The file '/mojoRT/Data/Sites/2/skins/layout.Master' does not exist.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[HttpException (0x80004005): The file '/mojoRT/Data/Sites/2/skins/layout.Master' does not exist.]
System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath) +3366759
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +109
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +93
System.Web.Compilation.BuildManager.GetVPathBuildResultWithAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +51
System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +90
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +103
System.Web.UI.Page.get_Master() +48
mojoPortal.Web.mojoBasePage.OnPreInit(EventArgs e) +157
mojoPortal.Web.UI.Pages.SiteHome.OnPreInit(EventArgs e) +5
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +521


2/3/2007 6:46:27 PM
Gravatar
Total Posts 18439

Re: Multiple sites with one db

The path /mojoRT/Data/Sites/2/skins/layout.Master is incorrect, there should be a skin name in there like:

/mojoRT/Data/Sites/2/skins/[skinname]/layout.Master

Check the mp_Sites table and make sure the site with siteid 2 has a skins name that corresponds to a skin folder.

The other thing is it could just be a cache issue. Maybe type a space in web.config and save it and upload it again to make the application recycle. This will clear the cache.

Joe
2/3/2007 7:11:35 PM
Gravatar
Total Posts 21

Re: Multiple sites with one db

Ok, got it going..

the error was actually caused because no skin was actually selected at the time..

mainly caused by my lack of understanding :)

having the 2 paths.. ment I needed to have basicly the SiteID 2 directory listed on both paths.

makes sense now lol... thanks again for all the input and time.

hopefully I'll get my skins going and be ready to think about some of the moduals/features I might try to build :)

You must sign in to post in the forums. This thread is closed to new posts.