Skip to main content

Hosting sub-domains but not main domain

Comments

13 comments

  • webhostuk
    So you want sub1.domain.com as a main Cpanel account other than creating a subdomain under domain.com? is that correct.This can directly be added via WHM. If you are looking for something else can you clarify a bit.
    0
  • verdon
    Well, I don't really care if there is a cPanel account, but I need to create a number of sub1.domain.com, sub2.domain.com, and so on and point them to somewhere on my file system. domain.com will not be on my server though, so creating a cpanel account for domain.com as a place to hold the sub-domains doesn't seem completely appropriate, though I'm guessing no real harm in it. Are you suggesting creating individual cPanel accounts for sub1.domain.com, sub2.domain.com, and so on? That's not really practical as there will be 40 or 50 of them. Individual cpanel accounts seems a little over-kill, especially with account-based licensing/pricing coming!
    0
  • verdon
    I should say as well that all these sub-domains will be pointing to one of two Wordpress multi-site installs, so I do not need individual file-systems for each sub-domain.
    0
  • verdon
    I should say as well that all these sub-domains will be pointing to one of two Wordpress multi-site installs, so I do not need individual file-systems for each sub-domain.

    I am also not worried about DNS... that is hosted elsewhere. All I really need to be able to do is create entires for httpd.conf that can point these subdomains to a location on the filesystem.
    0
  • verdon
    I guess another way to approach this, is that it doesn't really matter where/what cPanel account I use to host the Wordpress files. I just need a way to include a directory of hand-built .conf files into httpd.conf file that won't get nuked by updates and such. So, a way to add a custom include statement to httpd.conf that is officially supported by cPanel.
    0
  • verdon
    I guess another way to approach this, is that it doesn't really matter where/what cPanel account I use to host the Wordpress files. I just need a way to include a directory of hand-built .conf files into httpd.conf file that won't get nuked by updates and such. So, a way to add a custom include statement to httpd.conf that is officially supported by cPanel.

    I think this is what I am looking for. I'll post back to confirm, in case anyone comes across this in the future. Include Editor - Version 82 Documentation - cPanel Documentation
    0
  • verdon
    DOH!!! a bit of a dummy moment here. I have figured out what I was doing wrong. Putting the host container in the post include via the Apache Configuration editor does work... especially when you format it correctly. I was mistakenly copying something from an old server that only had one IP address. On this server, where I have several IP addresses, I had to start the vhost container with and not Sorry, rookie mistake ;-) The concept works
    0
  • cPanelMichael
    Hello @verdon, I'm glad to see you were able to get this sorted out. Thanks for sharing the outcome!
    0
  • verdon
    I've also verified that just putting an include in the include does work and perhaps more convenient, though you have to run a configtest manually before restarting httpd when adding new virtual hosts. For instance, using the WHM Apache Config editor, I can include this to the httpd.conf file # Load config files from the config directory "/home/serviceaccount/vhosts.d" # Include /home/serviceaccount/vhosts.d/*.conf
    and then any subdomain.conf files I put in that directory will get read into the httpd configuration when Apache is restarted. Note: it is a really good idea if doing something like this to run # service httpd configtest
    before restarting Apache. The WHM Apache Config editor does this for you when you use it. Otherwise, you're on your own. I'll see if I can tie these subdomains into AutoSSL now and note that. I was using certbot and letsencrypt on the old server they are coming from, but that was not a cPanel server.
    0
  • verdon
    @cPanelMichael The tricky part at this moment seems to be php-fpm. Am I correct in guessing that if I create a file at /var/cpanel/userdata/serviceaccount/subdomain.serviceaccount.com.php-fpm.yaml
    and then run /usr/local/cpanel/scripts/php_fpm_config --rebuild --domain=subdomain.serviceaccount.com
    that the plumbing will be done for me and the socket/pool built for php-fpm? I realize that I will have to look for the result and manually add that to my virtual host container. Ps. I'm beginning to think it might be a lot easier just to 'fake' having the parent domain on my server with it's own account, even though that would not be entirely true.
    0
  • verdon
    In the end, it's a LOT easier to create a cpanel account for the top-level domain (even though I'm not hosting it) and then just proceed as normal from there. I set the name servers for the cpanel account to use the existing, set the mail exchange to remote, excluded the top-level from auto-ssl, and everything seems to be ok. It certainly a lot simpler than what I was trying to do.
    0
  • cPanelMichael
    In the end, it's a LOT easier to create a cpanel account for the top-level domain (even though I'm not hosting it) and then just proceed as normal from there. I set the name servers for the cpanel account to use the existing, set the mail exchange to remote, excluded the top-level from auto-ssl, and everything seems to be ok. It certainly a lot simpler than what I was trying to do.

    Hello @verdon, Thanks for sharing the outcome and steps you used to accomplish this. I concur with you that using the quoted method is preferred because the configuration files are setup automatically and any future changes to the configuration requirements won't require additional customization on your part. Thank you.
    0

Please sign in to leave a comment.