-2

Im making some sort of CMS with server side PHP,

1.How do i with PHPadd the user's domain to the NS records and direct it to they'r folder in the server?

2.what this operation is called? i been Googleing this for 2 days now with no success due to the high advertisement on "domains" keywords.

EDIT: from what i understand now i need to API interface with CPanel, so i got my starting point, does anyone have a simple example on how to add a domain successfully with cpanel, none of what i tried work and thats after reading in the documentation and trying theyr examples.

Mike
  • 741
  • 13
  • 40
  • do you mean create subdomain? like user.domain.com redirect to folder user ?? – egig Apr 10 '13 at 06:32
  • What does that mean exactly? I guess you're asking about *subdomains*? I.e. `user.example.com`? – deceze Apr 10 '13 at 06:32
  • 1
    That's because PHP isn't a server. You want to look into Apache for creating virtual hosts. If you can get cPanel on your server, it would help create vhosts. – Emery King Apr 10 '13 at 06:32
  • the users want to build theyr own site and attach theyr own domains, USER.COM – Mike Apr 10 '13 at 06:33
  • cPanel then. Definitely. – Emery King Apr 10 '13 at 06:33
  • i have cpanel, i tried integrating with it but the documentation there is hurrible and i asked questions and no one answares, but is that the right way to do that? and can somone give a simple example if you know, how to just add a domain, i'll keep rolling from there. – Mike Apr 10 '13 at 06:34
  • 1
    Trust me, it's your only option. Otherwise you will be writing virtual hosts in your Apache config manually. It's not going to be easy, seeing how configurable a virtual host can be. – Emery King Apr 10 '13 at 06:37
  • is basicly CPanel just managing the apache virtual hosts? – Mike Apr 10 '13 at 06:37
  • 1
    And other things. But yes, basically. It does FTP, Email, Databases and all that junk too. – Emery King Apr 10 '13 at 06:38
  • nice. so i got my starting point, does anyone have a simple example on how to add a domain successfully with cpanel, none of what i tried work and thats after reading in the documentation – Mike Apr 10 '13 at 06:39
  • @user I'd advice to stay away from cPanel as far as you can. It does nothing you can't do yourself. You just need to know a little about the system you're working on and you need to have concrete requirements for what you're trying to do. – deceze Apr 10 '13 at 06:42
  • Yeah, you could just make a pseudo server like @deceze is saying if it's some small time thing. I'm saying for dependability and enterprise level deployment i suppose. – Emery King Apr 10 '13 at 06:44
  • @Marshall "Enterprise level deployment"? If you know what you're doing a proper Linux/Apache setup is much more "enterprisey" than cPanel. Or does "enterprisey" mean "tie yourself to a 3rd party vendor which holds your system hostage when you stop paying"? – deceze Apr 10 '13 at 06:46
  • I'm saying though practical, it's not conventional to build some shotty application to handle what something can do better and offer more for your future when it comes to expandability and modules. cPanel solves a problem, I won't get into the licensing of it but if you are going enterprise, shouldn't be a question. Go conventional. – Emery King Apr 10 '13 at 06:54
  • @Marshall This really depends on what exactly the OP wants to do. Sounds like he needs a tiny fraction of the stuff cPanel does, and maybe not even in the way that it does it. This problem can be easily solved with some custom Apache configuration and rewrite rules or a custom routing script as part of the custom app he needs to custom develop anyway. Better invest some time in understanding DNS and Apache request handling than to dump money into a package you don't really need. If cPanel was free, okay... but we're talking serious bucks here. – deceze Apr 10 '13 at 07:08

2 Answers2

1

It's pretty simple if you get away from the idea of "pointing to folders" or configuring Apache individually for each site. Just configure Apache to direct all requests to a specific application/PHP file/folder/whathaveyou. In that application, check the HTTP Host request header to get the requested domain. Then do anything with it you want. This can even be done using simple rewrite rules in Apache instead of some full-blown application, depends on your needs.

You'll just have to instruct your users to configure their DNS server for their domain to point to your IP address.

deceze
  • 510,633
  • 85
  • 743
  • 889
  • and for that i need my own server not a shared hosting am i right? – Mike Apr 10 '13 at 06:43
  • Yeah, shared hosting won't cut it here. This is a pretty custom setup no shared host will offer you. – deceze Apr 10 '13 at 06:44
  • from the comment of @Marshall, if the server is going to have lots of users each with theyr own domain and all directed to the same php file that checks the HTTP Host request header, wont it slow things down dramatically?, think as if you were giving advice to wix.com at theyr starting point on how to manage theyr domains for users. – Mike Apr 10 '13 at 06:50
  • 1
    Not any more than cPanel would. Each request is a request. If your server can't handle it with a custom solution, it won't be able to handle it with a cPanel running on top either. cPanel is not magic! If you are getting so many users that performance becomes a problem, a bespoke solution has a much better chance of being able to scale exactly to your needs. That of course assumes you learn enough about what you're doing and you're doing it right. – deceze Apr 10 '13 at 06:52
  • very well, i will start looking for a dedicated server and try handling my own requests and domains, and when things will get out of hands later on with too many users i hope i'de be able to move to a different solution without effecting the users. Thank you! :) – Mike Apr 10 '13 at 07:02
  • It's old question, but can you explain pls how this modification could be done ? I mean the configuration on apache or the rewrite rules ? – Sinf Jan 20 '17 at 13:57
0

look into WHMCS - they have modules that interface with WHM/cPanel that would let your users select the options themselves potentially. Like a hosting company.

Emery King
  • 3,550
  • 23
  • 34
  • 1
    No point in paying for a system which is simply a frontend for things you can do yourself on any *NIX system. – deceze Apr 10 '13 at 06:43
  • The point would be major contrast in functionality and documentation. I've really come to know the benefits of using framework instead of creating my own stuff and then having to come back to it a year later. – Emery King Apr 10 '13 at 06:48
  • I've really known the downside of entrusting your system to a bloated frontend which doesn't really let you do exactly what you want and stops working because somebody decided it was not worth paying for anymore. If you know what you're doing you can easily build an equally well documented system which exactly suits your needs, you just need to have the discipline for it. "Better documentation" is no excuse. – deceze Apr 10 '13 at 06:50
  • I agree somewhat. it really just depends on the situation. – Emery King Apr 10 '13 at 06:56