Domain Mapping on VPS

There are does of domains that need to be mapped to network subsite and everything is hosted on same server.
Parking a domain works but it causes loss of email boxes and SSL certificate for multisite is not working, it requires additional payment for each domain.

When standalone domain is used it fails to point to multisite root folder.

Multisite does have dedicated IP.

  • Adam Czajczyk

    Hello, Gary!

    I hope you're well today and I hope you don't mind me jumping in.

    I read your conversation with Predrag and saw the Second Line Support ticket that he issues for you and I'm thinking about a bit different solution.

    I understand that:

    - "spamaster.co.za" is the main domain of your Multisite
    - "spamassage.co.za" is one of the domains that you wish to map to one of sub-sites
    - those domains "to be mapped" are hosted on Afrihost where you can configure them

    Is that correct?

    I'll use "spamassage" as an example as all the steps would be the same for every "domain to be mapped", so here's what I would do:

    1. remove all redirects/forwards for "spamassage"
    2. bring back it's default ("clean") DNS configuration so it was set like you have just purchased it :slight_smile:
    3. in your "spamaster" cPanel use Addon Domain to add "spamassage" to the server - just put the domain name into "New Domain Name" field, do not create subdomain and select "Document Root" to be exactly the same as the Document Root for "spamaster"
    4. At Afrihost change name servers' to point to your server (where "spamaster") is; you should be able to find name servers' hostnames in cPanel or in account information
    5. Wait until DNS propagates.

    At this point you'll have fully functional "spamassage" domain on your cPanel, you can set e-mail boxes there and you should be able to use SSL for it. Please note: you'd be using "addon" domain, not "parked" domain.

    When you now type in "spamassage" domain into the browser bar it should load the main site of your network and redirect to "create new site" page.

    All you need to do now is to map the domain in Domain Mapping and it should be fine.

    Best regards,
    Adam

  • Gary

    Hi Adam,

    Thanx for the reply, your assumptions are correct, http://www.spamaster.co.za being the site that hosts WordPress Multisite, http://www.spamassage.co.za needs to be mapped to it (as would another 8 other sites eventually).

    So I tried what you suggested above, but ran into some issues:

    1.) I reset http://www.spamassage.co.za DNS as suggested
    2.) I tried to add spamassage as an Addon domain to http://www.spamaster.co.za but it did not accept that (says "That is not a valid domain)
    3.) So I added http://www.spamassage.co.za as an Addon Domain
    4.) Subdomain field can't be left blank (if left blank it says "That is not a valid Subdomain)
    5.) So I added 'sub1' just for the sake of having something in there
    6.) I added the document root for http://www.spamassage.co.za (/home/wwwspamassageco)

    Then when I clicked I got this message:
    (XID 3g6rej) The domain “spamassage.co.za” already exists in the Apache configuration.

    Which is correct, since the domain (www.spamassage.co.za) exists on the same WHM as the one that my multisite (www.spamaster.co.za) exists on.

    I realise I could delete http://www.spamassage.co.za add it as an Addon domain, but then I would loose existing mail accounts?

    I'm beginning to think I need to forgot using Multisite and all the related benefits, for these sites? :disappointed:

  • Dimitris

    Hey there Gary,

    hope you're doing good and don't mind chiming in! :slight_smile:

    I think this is true, making this change will let you map the domain successfully into a subsite of the multisite installation but email accounts should be re-build for the add-on domains this time.
    This will require some extra work to preserve old emails (most probably by forwarding them to a dummy account and then back to the updated inbox).

    I really can't tell if there's another workaround here so I've already pinged our awesome SLS team to provide any other feedback, if any.

    Warm regards,
    Dimitris

  • Lindeni Mahlalela

    Hi Gary.

    I hope you are doing well today. I hope you don't mind me jumping in here.

    If I read it right, you said you are on a VPS running WHM/CPanel. If this is the case and you are comfortable playing with the command line interface. You can login to your VPS using SSH and edit the apache vhost file which you can use to point the mapped domains to the root folder of the main website. You can also get someone to do it for you, I thing it is better option than migrating all those email accounts.

    Here is how to do it.

    SSH to your server and run the following command as root
    Note: I use 'vi' as I am using "Vim Nox" editor, you can use 'nano' or other editor of your choice

    vi /usr/local/apache/conf/httpd.conf

    Scroll and find the <vhost> entry for the 'master' domain that will host the multi site. Not down its DocumentRoot. Find the <vhost> entry for the domain you were trying to add as an addon domain, change its document root to be exactly that of the master domain hosting the multis ite.

    You should have something that looks like this:

    <VirtualHost *:80>
        ServerAdmin admin@spamaster.co.za
        ServerName spamaster.co.za
        ServerAlias http://www.spamaster.co.za
        DocumentRoot /home/user/spamaster/public_html
    </VirtualHost>
    
    <VirtualHost *:80>
        ServerAdmin admin@spamassage.co.za
        ServerName spamassage.co.za
        ServerAlias http://www.spamassage.co.za
        DocumentRoot /home/user/spamaster/public_html
    </VirtualHost>

    I have used the example
    DocumentRoot /home/user/spamaster/public_html

    Just make sure you get the correct document root from the vhost entry of the master domain and use that for all the domains you want to map.

    Also change the 'UserDir enabled' to be that of the user who owns the 'master' domain. And replace all occurrences of the username of the mapped domain with that of the master domain.

    Once you have done that run the command to save your changes. With Vim editor I press 'Esc" the write

    :wq
    then press 'Enter' on keyboard to save and exit the editor.

    Now the following part is very important. As cPanel is designed to rebuild its vhosts file each time a domain is added or removed, you will have to make sure it remembers your custom edits and keep them during its next build of the vhosts file you just edited.

    To make sure cpanel keeps your edits/customizations, run the command'

    /usr/local/cpanel/bin/apache_conf_distiller --update
    That will copy your customizations to cPanel's templates and make sure they stay intact when cPanel rebuilds the vhosts file.

    After that, if all done correctly, if you visit the domain that should be an addon, it should load the multisite website and should load the create new site page. If that is the case, just add a new site or go to the dashboard of an existing site and go to "Tools > Domain" mapping and map the domain. That will do it.

    In summary:

    Edit /usr/local/apache/conf/httpd.conf file
    a. Change document root to that of the network site
    e.g. change from "/home/userdirectory/public_html" to "/home/userdirectory/public_html"

    b. Change "UserDir enabled" to that of the root site user: Reference main site vhost entry for the correct 'UserDir enabled'
    c. Replace all occurrences of the username who owns the virtual host with that of the one who owns the virtual host of the primary site
    d. Restart apache server
    e. Run distiller command '/usr/local/cpanel/bin/apache_conf_distiller --update'

    If you have done all that correctly, then you have a healthier multisite without the trouble of migrating the emails. The only thing you have to keep in mind is that you have to run the distiller command after making changes to the vhosts file otherwise those changes will be lost.

    I thought I should share this as an option if all your options are not possible or have too much to do. I hope this helps.

    Cheers,
    Mahlamusa

  • Lindeni Mahlalela

    Hello Garry,

    I hope you are doing great today. I have noticed that we haven't had a response from you with regards to this. Do you still need help with this issue or not? Please let us know and we will be happy to help in any way possible.

    Di you get a chance to go through my suggestion above or you are considering other options? Please let us know your final decision and whether you still need help or not.

    I hope you enjoy the rest of your day.

    Cheers,
    Mahlamusa