How to run multiple Sites off one install
From Textbook
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:
Contents |
The Process
- 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).
Keep this 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.
Additional 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.
Resources
Credits
- This Example has been provided by Glen Wilson




