开发者

Website Replication using PHP

I would like to know the concept of website replication where when a user sign up a subdomain is created and the user can create his website online. Just the开发者_运维问答 way it is being done in www.empowerkit.com


Lots of ways to structure multi-tenant SaaS.

There is the single site, single database database approach:

Basically you have the website binding listen to * on a dedicated IP Address.

DNS Bind *.yourdomain.com to ip address

Have your signup function create a customer database record containing the subdomain.

Have routing code that can determine what the customer id is for a specific request on a subdomain, then use row-level filtering in your data repository to only return data for that specific customer id.

You could also have your code create a whole separate website on the filesystem, and add the appropriate virtualhosts entries for the new site.

Pros: Less database overheads from multiple database instances, easy to backup and restore (single database) Cons: Bit more working getting the data access, harder to shard

Then there is single-site, multi-database:

Same as above, but the subdomain maps to a specific customer database.

Pros: Easier to shard, Customer database better segregated

Cons: High memory overhead, requires lots of database instances, hard to backup

Finally, multi-site multi-database

You create separate physical sites and add the appropriate virtualhost records for your clients during signup, as well as creating a separate database for that client

Pros: Simple application code, easy to scale, better user segregation, easier to customize "per user" if required.

Cons: Complex "signup code", requires lots of resources, requires your application to have write access to important configuration files, wastes lots of disk space.

It depends on how your application works and what per user customization you offer.


Well, for the subdomain part you could:

  1. Use a database and .htaccess to redirect
  2. Use your control panel API (like DirectAdmin API)

The user can create his website with a WYSIWYG (What You See Is What You Get) editor (as CMS) and save all the content in a SQL database which you can retrieve later on to display the page.


I don't think there's a simple answer to what you are asking. Most effective solutions actually have the concept of dealing with the sub domain built into the product.

It all depends on the environment you are going to deploy in and what runs your site.

Many CMSes can deal with serving different content for the subdomain by nature.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜