-4

I want know how blogging systems works, what will happen when a user create a blog? I know every blogging system has a main site that user register on it , but how main site create sub-domain and source code for each user? how about database? is blog source code copied to every user folder? are all blogs use single core?

Question
  • 87
  • 6
  • I can help you for database structure. I think for the database you should add sub-domain URL(server name) in the user table as domain column. – Nikhil Parmar Sep 19 '17 at 09:53
  • Questions asking for general help like this are off topic. Please review [What topics can I ask about here?](https://stackoverflow.com/help/on-topic). – FluffyKitten Sep 19 '17 at 10:05

1 Answers1

1

Your question is way too broad, but as an example of one possible approach, you could use the server name to choose an appropriate configuration for your app, and share source code.

<?php

$domain_map = 
[
    'foo.example.com' => 'foo',
    'bar.example.com' => 'bar'
];

$domain = $_SERVER['SERVER_NAME'];

if(isset($domain_map[$domain])) {
    $config = require __DIR__ . '/' . $domain_map[$domain] . '.config';
    $app    = new App($config);
    // etc.
}
Progrock
  • 7,373
  • 1
  • 19
  • 25