How to deal with several sites that access the "brain"?

As a rule, my development covers only small and medium-sized companies and e-commerce sites.

My next project will include 30 sites, however they will have about 95% in common with each other. I want them to have a "brain", which means that I can deploy changes, updates for the framework, etc. Only once.

I wonder if this makes the site collection of Stack Overflow (superuser, stackoverflow, serverfault, etc.).

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

The brain must have

  • 1 admin system that can process each site
  • all patterns exist in the brain - however, they have placeholders, for example, name, logo, etc.
  • The way that I can perform any update for global templates is automatically filtered out on all other sites.

I understand that this will greatly affect the brain, so I will have to cache a lot on the server side.

How would I get access to every domain in the brain, for example:

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

access to silence http://www.mothership.com/mysite2/products/something

And is this the best way to do this? Do you have any tips? Am I on the right track?

Feel free to ask me more.

+6
php mysql kohana
source share
2 answers

The easiest way to do this is shared hosting. Basically you run all sites on one machine. On one machine, there is an Apache configuration that serves all sites.

If the sites are more similar to each other, then simply list all the sites in one directory. PHP files can determine which site they serve. You can provide different headers and footers for each site to handle the look. You can also restrict specific pages this way.

If the sites are more different than similar ones, list them in a different directory and indicate the pages related to these sites in each directory.

For general functionality, you can use something like mod_rewrite to map URLs on different sites with the same script, or you can have PHP scripts in every place that include / require common functions.

Basically there are many options. Your goal should be to make the site easy to maintain and provide absolute minimal code duplication.

As requested, the following is proposed:

+3
source share

You can achieve this in Apache using <VirtualHost> Directive . To do this in Apache 2.x, edit httpd.conf and uncomment this line (usually at the end of the file): Include conf/extra/httpd-vhosts.conf . Then find the httpd-vhosts.conf and enter 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> 
0
source share

All Articles