views:

37

answers:

2

I've built a white label website in PHP that uses templates. Each white label will have it's own set of templates and possibly a few extra folders. All the white label sites are on the same LAMP server.

What I would like to do is keep one centralised copy of the main code on the server and then have every site point to these files. Then each white label site directory will have a physical directory for it's templates and any other extra files and directories.

The idea is to completely remove the logic from the presentation and share the logic across all the white label sites. This way I can make changes to the shared logic and all the sites will update.

Also I need a similar structure in the SVN repositories. Currently each white label site has it's own repository.

What's the best way to achive this? Can I use something like mod_rewrite to forward all requests apart from templates to shared folder?

  1. What I need to make sure is that it's easy to set up a new white label site
  2. Users that checkout a white label from the SVN repro to work on it's templates don't have access to the shared code
A: 

In Apache you can setup an alias directory which can be accessed from several different web sites

Here I have called it common_files

<VirtualHost 100.100.100.100>
  ServerName example.com
  DocumentRoot "/usr/example/html_docs"
  <Directory "/usr/example/html_docs">
    AllowOverride All
    Allow from All
    DirectoryIndex index.htm, index.php
  </Directory>
  Alias /sf "/usr/common_files"
  <Directory "/usr/common_files">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>
Jon Winstanley
The shared directory is actually the entire site code including all the php files and index.php. Could all of the be aliased in to each white label? Also I really want to avoid having to edit Apache config files as it needs to be really easy to set up.
Camsoft
A: 

In the end I decided to use Symbolic Links to link to the shared files. I then created a interactive bash script to automatically set-up the symlinks for new white labels.

Camsoft