Jump to content

Recommended Posts

Posted

It would be great if Processwire could handle a multi-site setup just like Drupal.

At the moment the site structure is like:

-site

-wire

A multi-site setup could be:

-processwire.com

-talk.processwire.com

-any-other-site.com

-wire

Depending on the entry-domain, the config from the domain gets loaded. So http://processwire.com would load processwire.com/config.php and http://talk.processwire.com would load talk.proceswire.com/config.php.

If you need a module for just one site, stick it in the domain/modules folder, same for the templates and assets.

Any thoughts about this?

Posted

For that type of multi-site setup, the way that I do it, and I think others are, is to just use symbolic links. So all the sites share the same /wire/ directory, but each have their own /site/ directory.

But lets say you've got just one hosting account and want to run multiple sites at the same web root. In that case you need to adjust the config according to the hostname. This is easy to do. Edit your /index.php file and locate this line:

$siteDir = "site";

...and add this after it:

if(strpos($_SERVER['HTTP_HOST'], 'other-site.com') !== false) $siteDir = 'other-site';

Admittedly I haven't had a need to try it just yet, but that's the way it's meant to work. So in the above scenario, if someone access your site at 'other-site.com', then it uses the 'other-site' directory rather than the 'site' directory.

Posted

Processwire finds ways to amaze me every time. I will experiment with the second option, because I don't have shell access to my shared hosting account.

Thanks!!

Posted

For that type of multi-site setup, the way that I do it, and I think others are, is to just use symbolic links. So all the sites share the same /wire/ directory, but each have their own /site/ directory.

I'm intrigued by this - can you go into more detail? It sounds great, but I can't quite visualise how it works from a domain name point of view or a technical point of view.

Posted

You probably need to have all websites on one physical server, with directory structure like this [simplified example]:

/
 /www/
/www/web.com/
  ./index.php
  ./site/
  ./wire/ - symlinked
/www/example.com/
  ./index.php
  ./site/
  ./wire/ - symlinked
/www/another-domain.com/
  ./index.php
  ./site/
  ./wire/ - symlinked
 /non-accessible/ (or any other server dir, possibly out of your publicly accessible directories)
  ./wire/ - physical directory, for all domains
Posted

Yep. What Adam wrote is pretty close what we have done. But we have different branches also covered:

/non-accessible/
./P21dev/wire/
./P21stable/wire/
./P21latest/wire/
   ./modules/modulename/

how it works from a domain name point of view

We took the "automagic" little further: we have used Apache virtualdocumentroot (http://httpd.apache....hosts/mass.html) and some simple mod_rewrite to automatically serve sites from right directory. So no need to manage vhosts etc when adding new sites. We also use our dev domain (pwire.fi) to serve sites before dns-changes have been made. When I create site www.domain.com then it is right away accessible from www.domain.com.pwire.fi.

Posted

Nice - I like these setups because it's obviously far less updating to deal with in terms of the core code, and they are indeed mostly on the same server in my case as well.

Thanks guys :)

Posted

I added core support (in the dev branch) for directing to different /site/ directories based on domain or subdomain. I don't like telling people to make changes to the /index.php file since that's something that should be overwritten on updates. So figured I needed to provide an alternate approach here. If you have the /dev/ branch, take a look at the file /wire/index.config.php. Copy or move that file to your web root (or dir where PW is installed). Edit it and there are instructions on how to configure it.

Each alternate /site-domain/ directory should be configured to use a different database. So the best bet is to do one of the following:

1. Copy the entire /site/ directory to a new /site-domain/ directory. Edit /site/config.php and supply new database information (seen at the bottom). Export your main PW site database, and import it to the new DB used by your alternate domain.

2. OR: install more copies of PW on your server (like in directories). After running through the installer, move their site/ directory to the /site-domain/ directory in the main PW install, and then delete any other installed copies as you don't need them anymore.

Posted

Ryan, I tried this, but must be doing something wrong.

For testing purposes I copied all the contents of the /site/ directory from a working PW install on the same server to /site-testing/ on the root of my main PW at mydomain.com. Then I moved the index.config.php file to the same place, and replaced the examples by:

'www.mydomain.com' => 'site-testing'

I'm still getting my main website when I access www.mydomain.com, shouldn't it be already the other site?

Posted

Diogo, a couple things to check:

Make sure that your /index.php and /.htaccess files are both brand new from PW 2.2.

Next, I suggesting adding both 'www.mydomain.com' and 'mydomain.com' to both go to /site-testing/.

Lastly, if /site-testing/ is just a copy of your /site/ dir, then make sure you've updated something in your /site/templates/ to reflect that, so that you can tell the difference. For instance, have /site-testing/home.php have something like "echo "<h1>Site-testing</h1>";

Posted

Ryan, it's not a copy of the site at mydomain.com, it's a copy of a different site. Also, I used www because I know it's pointing to the same directory, the idea was just testing quickly if it would work. I assume that the server has to point all the sites that I want in the same installation, to this same directory.

Posted

Looks like I forgot to remove a line in the code. You are right, it wasn't working. Sorry about that. Grab the latest /index.php and try again and it should work.

Thanks,

Ryan

Posted

It's working perfectly now, thanks! It's great to have all the sites in the same folder ;)

edit: is it possible that the website gets slower with the new process? I have a ubuntu server with each site in a virtual server, I pointed the domain to the new folder on index.config.php, and removed it from "sites enabled" in apache.

edit2: and restarted the server

Posted
is it possible that the website gets slower with the new process?

There shouldn't be any overhead with using the multisite feature. All it's doing is checking $_SERVER['HTTP_HOST'] to determine what /site/ directory it should use, and that doesn't represent any overhead.

I have a ubuntu server with each site in a virtual server, I pointed the domain to the new folder on index.config.php, and removed it from "sites enabled" in apache. edit2: and restarted the server

I'm not sure I understand. Are you saying that something is not working how it should, or that restarting the server fixed it? B)

Posted

Sorry, that edit2 just messed my post :)

I restarted right after all the other things, the problem came after that.

Anyway, I did some test and I don't notice any difference now, maybe it happened because the images were already cached in the browser when I tried the second time.

  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...