如何创建像37Signals这样的账户系统?
如何创建像37signals这样的帐户系统,即:
每个用户获得一个独立的URL。 user.domain.com 每个用户都可以添加一定数量的用户:
当他们为帐户分配资源时,您认为这一切都在一个数据库中,还是为每个帐户创建一个单独的数据库?
How can I create an account system like 37signals, which is:
Each user gets an independent URL. user.domain.com
Each user gets to add a certain amount of users:
And when they allocate resources for accounts, do you think its all in one database or they create a separate database for each account?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以对用户子域使用两种方法之一 - 您可以使用 HTAccess 重写规则将子域转移回加载其帐户的 .php?sub=user 页面 - htaccess 将子域重定向到域
或者(假设您在 CPanel 托管上)有有关如何仅使用 PHP 和 cURL 自动创建和指向子域的示例 - http://www.zubrag.com/scripts/cpanel-subdomains-creator.php
虽然我不确定 37signals DB 是如何工作的,但我怀疑他们是否创建了一个新的每个用户的数据库 - 更像是他们简单地链接索引上的多个表。如果以前不知道这些字段,那么您可以使用简单的 EAV 方案来允许用户定义自己的数据字段。
you could use one of two methods for the user sub domains - you could either use an HTAccess rewrite rule to divert the subdomain back into a .php?sub=user page that loads their account - htaccess redirect subdomain to domain
or (providing you are on CPanel Hosting) there are examples around of how to automatically create and point sub domains using just PHP and cURL - http://www.zubrag.com/scripts/cpanel-subdomains-creator.php
Although I am unsure of how the 37signals DB works I doubt that they create a new DB for every user - more like they simply link multiple tables on indexes. If the fields are not going to be previously known then you use a simple EAV scheme to allow users to define their own data fields.
我知道使用 nginx,您可以设置一个默认的“服务器”(所有子域都重定向到一个文档根目录,如果它们实际上不存在)。然后,由 PHP 脚本解析主机标头。通过这种虚拟主机设置,您将使用现有的数据库。
NginX 服务器和 Server_Name 参考
I know that with nginx, you can set a default 'server' (All subdomains redirect to one document root if they don't actually exist). Then, it's up to the PHP script to parse the host header. With this kind of virtual host setup, you would use the databases already in existence.
NginX Server and Server_Name Reference