How to deal with mutliple sites that access one 'brain'?
Asked Answered
T

2

6

Generally, my development has only covered small to medium size companies and e commerce sites.

My next project will encompass say 30 sites - however, they'll have about 95% in common with each other. I want them to have 1 'brain' that means I can roll out changes, updates to the framework etc only once.

I wonder if the Stack Overflow family of sites do this (superuser, stackoverflow, serverfault etc).

My languages/platforms of choice are PHP 5.3, MySQL 5 and the Kohana Framework.

The brain should have

  • 1 admin system that can handle every site
  • all templates exist in the brain - however they have placeholders, for example, title, logo, etc
  • A way so I can roll out any update to the global templates will automatically filter out to all the other sites.

I realise this would put a lot of stress on the brain, so I'd have to use server side caching a lot.

How would I have each domain access the brain, so for example:

http://www.mysite2.com/products/something

silently accessed http://www.mothership.com/mysite2/products/something

And would that be the best way to do it? Do you have any tips? Am I on the right track?

Feel free to ask me any more specifics.

Thetis answered 25/8, 2009 at 4:49 Comment(2)
Are all of the sites on a shared server, ie have the same IP address?Cantata
They could be - however I have limited experience with doing it this way.Thetis
T
3

The easiest way to do this is with virtual hosting. Basically you run all the sites on one machine. The one machine has an Apache config that serves all the sites.

If the sites are more similar than different then just point all the sites to the one directory. The PHP files can detect what site they're serving. You can provide a different header and footer for each site to handle the look and feel. You can also restrict certain pages this way.

If the sites are more different than similar then point each to a different directory and have pages relevant to those sites in each directory.

For common functionality you could use something like mod_rewrite to map URLs on the different sites to the same script or you could have PHP scripts at each location that include/require common functionality.

Basically there are lots of options. Your goal should be make the site easy to maintain and keep code duplication to an absolute minimum.

As requested, suggested reading:

Trowel answered 25/8, 2009 at 5:2 Comment(1)
Your last sentence describes exactly what I'm trying to achieve. I don;t have too much knowledge which configuring Apache outside of .htaccess files. I'll have to do some research - any recommended reading Cletus? And thanks for your answer.Thetis
C
0

You can achieve this in Apache using the <VirtualHost> Directive. To do this under Apache 2.x, edit httpd.conf and uncomment this line (usually found near the end of file): Include conf/extra/httpd-vhosts.conf. Then locate the file httpd-vhosts.conf and entry the VirtualHosts in this format:

<VirtualHost 10.1.2.3>
DocumentRoot /home/site1
ServerName site1.com
</VirtualHost>

<VirtualHost 10.1.2.3>
DocumentRoot /home/site2
ServerName site2.com
</VirtualHost>

<VirtualHost 10.1.2.3>
DocumentRoot /home/site2
ServerName site3.com
</VirtualHost>
Chicory answered 25/8, 2009 at 5:16 Comment(2)
Do you know of any hosts which let you modify this ?Thetis
You'll need root access to modify system files. You're best bet is to sign up for a VPS hosting solution, which generally starts at $25 a month. webhostingtalk.com/web-hosting-providers/vps-hostingChicory

© 2022 - 2024 — McMap. All rights reserved.