spoetnik Posted January 10, 2012 Posted January 10, 2012 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?
ryan Posted January 10, 2012 Posted January 10, 2012 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.
spoetnik Posted January 11, 2012 Author Posted January 11, 2012 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!!
Pete Posted January 11, 2012 Posted January 11, 2012 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.
Adam Kiss Posted January 11, 2012 Posted January 11, 2012 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
apeisa Posted January 11, 2012 Posted January 11, 2012 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.
Pete Posted January 11, 2012 Posted January 11, 2012 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
ryan Posted January 12, 2012 Posted January 12, 2012 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.
Pete Posted January 12, 2012 Posted January 12, 2012 Thanks ryan, I'll have a look at that when (if) I get some free time
diogo Posted January 17, 2012 Posted January 17, 2012 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?
ryan Posted January 17, 2012 Posted January 17, 2012 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>";
diogo Posted January 17, 2012 Posted January 17, 2012 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.
ryan Posted January 17, 2012 Posted January 17, 2012 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
diogo Posted January 17, 2012 Posted January 17, 2012 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
ryan Posted January 17, 2012 Posted January 17, 2012 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)
diogo Posted January 17, 2012 Posted January 17, 2012 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.
diogo Posted May 14, 2012 Posted May 14, 2012 Ryan, I made a question on this thread that belongs better to this one.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now