Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-03-05 19:27:17

Tinshack
Member
From: South Africa
Registered: 2005-12-04
Posts: 18
Website

How to run multiple sites off one install

I have a Txp site at eaa.org.za. I’ve got the following directories (real directories – not thingies made by mod_rewrite or htaccess that don’t really exist):

www.eaa.org.za
www.eaa.org.za/airweek2006

airweek2006 is a separate website for an airshow that my organisation runs annually. I wanted the airweek2006 website to run from the same installation files that my main site runs from (i.e. www.example.com/textpattern/…), but still have its own sections, admin interface, users etc.

The main reason for wanting this is so that I only have to update one set of files each time a new version of Txp comes out. I wanted the airweek site separate from the main one because the airshow site is only active for a part of the year and I prefer keeping its users and content completely separate from the main site.

The following instructions assume you’re familiar with installing Textpattern. Don’t try this on a live site and be sure to read the notes at the bottom:

To get this right I did the following:
  • Set up a full install of Textpattern in the airweek2006 directory. This will allow you to set up the tables required. You won’t be able to set up tables with the small copy of Txp that I’ve set up here.
  • Once you’ve run a full install then edit airweek2006/textpattern/config.php:
    • change the txpath option to point to your main site’s Textpattern directory (e.g. /usr/www/example.com/textpattern instead of /usr/www/example.com/airweek2006).
  • Now go and edit airweek2006/textpattern/index.php:
    • There’s a define() on ± line 20 that says define("txpath", dirname(__FILE__));
    • Change this to say define("txpath", $txpcfg['txpath']);
    • Move this define to ± line 32 after the code that include()’s config.php
    • This will allow the Textpattern admin interface to work from your sub-site (so that it uses the files from the txpath directory configured in config.php).
  • Now you can delete everything from airweek2006 except the following:
    • airweek2006/index.php
    • airweek2006/textpattern/index.php
    • airweek2006/textpattern/css.php
    • airweek2006/textpattern/config.php
    • airweek2006/textpattern/textpattern.css
    • airweek2006/textpattern/textpattern,js
    • airweek2006/textpattern/txp_img/*.*
    • airweek2006/files/*.* (if it exists).
When trying this out keep the following in mind:
  • I only figured this out tonight and decided to document something for the world to comment on. I’m pretty excited about my findings
  • There might be negative effects on Textpattern that I haven’t found. It might even have some security-related effects that could ruin your day.
  • It won’t work if you’re using clean urls and you’ve got two sections with the same name on your main and sub-sites (e.g. example.com/news and example.com/airweek2006/news). Having a copy of .htaccess in the airweek2006 directory might help but I haven’t tried that out yet.
Some more notes:
  • I would like to see the changes that I made to textpattern/index.php made a little more permanent by having it integrated into future releases of Txp but I’ll leave that for the developers to decide.
  • I’m going to try my best to keep up with this thread but I’m only on the Internet twice a week – keeping up might be a little difficult.
  • I’m sorry if something similar has been posted before – I did try looking for similar topics both here and other places like Textbook.
  • Eventually multiple instances of Txp from one install might not be such a problem. I quite like the idea of doing so but there might be good reasons why not to do so (I really can’t think of any). I’d like to hear your thoughts.

I’ll stop yakking now…

Later

Glen

Edit: Added a link to the sub-site. The link is different than “advertised” because the URL I did finally use fits in better my URL scheme.

Last edited by Tinshack (2006-07-02 09:07:29)

Offline

#2 2006-03-22 01:11:07

greno
New Member
Registered: 2006-03-18
Posts: 4

Re: How to run multiple sites off one install

Great idea! I tried this on my subdomains and it worked except some plugins didn’t work. So exploring the problem the plugins were looking for things in the lib or include directories which weren’t there so I made a symlink (on Linux) to the main version and then they began working. This inspired me to write a bash shell script to automate the process. Be forewarned that this script is provided without warranty. Use it at your own risk. It uses ‘rm -r’ so be careful to make sure you are positioned at the subdomains textpattern-n.n.n directory prior to running it.

Gerry

Script is here: <a href=“http://txpsubdomain.pastebin.com/617544”>textpattern-subdomain-setup.sh</a>

Last edited by greno (2006-03-23 05:12:44)

Offline

#3 2006-03-24 01:42:30

greno
New Member
Registered: 2006-03-18
Posts: 4

Re: How to run multiple sites off one install

This is working very nicely and I have started thinking about what features would make multisite capability great.

<ul>
<li>Concept of global plugins (SUBDOMAINS inherit common plugin set from MAIN install but also could install more locally.)
<br /> (side note: would really help if all plugin files were installed under a plugins/ subdirectory.)<br />
<li>Concept of restricted/allowable plugin selection list for SUBDOMAIN installation.

<li>Concept of global templates and styles (skins)

<li>Concept of global preferences (inheritable and able to be overridden in SUBDOMAINS)
<br /> (define your default set and all SUBDOMAINS automatically inherit – time saver)<br />
</ul>Gerry

Offline

#4 2006-03-24 17:33:26

Tinshack
Member
From: South Africa
Registered: 2005-12-04
Posts: 18
Website

Re: How to run multiple sites off one install

To be honest I haven’t fiddled much with the idea, but I thought it would be useful.

I wasn’t thinking very global. In my case all that’s shared between my installations are the files. Even images and file downloads are seperate. I’d like to find some way of synchronising users between sites.

Gerry: Some of this stuff can be done with some kind of script that executes an sql query. Writing a plugin to synchronise sites would help a lot (whenever user updates subdomain1, the script propogates the changes to the other domains). Are all the sub-domains using the same database or are they each using their own?

Glen

Last edited by Tinshack (2006-03-24 17:38:12)

Offline

#5 2006-03-24 20:00:41

KurtRaschke
Plugin Author
Registered: 2004-05-16
Posts: 275

Re: How to run multiple sites off one install

greno wrote:

This is working very nicely and I have started thinking about what features would make multisite capability great.
<ul>
<li>Concept of global plugins (SUBDOMAINS inherit common plugin set from MAIN install but also could install more locally.)
<br /> (side note: would really help if all plugin files were installed under a plugins/ subdirectory.)</li></ul>

Take a look at the plugin_cache_dir setting in the advanced preferences—you can point it to a directory of uncompiled plugin files, and TXP will make them available (although they won’t show up under the ‘plugins’ tab). It’s mainly a feature for developers, but it could certainly be used to allow multiple instances of TXP to run a common plugin set.

-Kurt


kurt@kurtraschke.com

Offline

#6 2006-03-26 22:53:55

greno
New Member
Registered: 2006-03-18
Posts: 4

Re: How to run multiple sites off one install

Tinshack wrote:

Are all the sub-domains using the same database or are they each using their own?
Glen

Each subdomain uses it’s own database.

Gerry

Offline

#7 2006-03-26 23:01:23

greno
New Member
Registered: 2006-03-18
Posts: 4

Re: How to run multiple sites off one install

KurtRaschke wrote:

greno wrote:

This is working very nicely and I have started thinking about what features would make multisite capability great.
<ul>
<li>Concept of global plugins (SUBDOMAINS inherit common plugin set from MAIN install but also could install more locally.)
<br /> (side note: would really help if all plugin files were installed under a plugins/ subdirectory.)</li></ul>

Take a look at the plugin_cache_dir setting in the advanced preferences—you can point it to a directory of uncompiled plugin files, and TXP will make them available (although they won’t show up under the ‘plugins’ tab). It’s mainly a feature for developers, but it could certainly be used to allow multiple instances of TXP to run a common plugin set.
-Kurt

Interesting. Wouldn’t allow for any control by subdomains (in case they wanted to disable) but might be the start of a way to implement this concept.

Gerry

Offline

#8 2006-06-16 01:22:33

aldo
New Member
Registered: 2006-04-12
Posts: 5

Re: How to run multiple sites off one install

This is not working for me. I followed the insturctions to the T, and poof – nothing. I think the newer versions of Texpattern have mad this obsolete.

Can this be run on sep. database or does it have to run on the root DB?

Offline

#9 2006-06-18 08:55:59

Tinshack
Member
From: South Africa
Registered: 2005-12-04
Posts: 18
Website

Re: How to run multiple sites off one install

I’m using 4.0.3. I’m not sure if this will work in any other version (subversion, or previous releases). Future versions may make this obselete.

You can use another database. You can also put multiple installations into 1 database provided each TxP installation has a unique table prefix (that you set up during installation).

Remember that you have to run a complete install for each copy of TxP that you want to run. It’s only once you’ve run the installation that you can delete the extra files. Your subdir/textpattern/config.php file needs to point to a full copy of TxP.

What exactly do you mean that “nothing” happens. Is there a just a blank page, do you see a whole bunch of errors, are you able to run the admin interface, and do aliens exist?

Offline

#10 2006-11-16 07:43:49

t0ma
Member
From: On the edge of arctic circle
Registered: 2005-04-28
Posts: 24
Website

Re: How to run multiple sites off one install

Just tried with 4.0.4 and everything works fine, so far. Thanks for tip, made my life a lot easier.

Haven´t tried with plugins but we´ll see.


“The role of art is to make a world which can be inhabited.”

Offline

#11 2007-07-01 19:22:20

guitarman
Member
Registered: 2006-09-04
Posts: 14

Re: How to run multiple sites off one install

This sounds interesting. I’ve tried separate installs on a single database, but never a single install.

Will this work with my setup?

www.domain.com
&
www.domain2.com which is actually an add-on domain to to domain.com at www.domain.com/domain2

It sounds rather pointless, but I’m curious?

Offline

Board footer

Powered by FluxBB