The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Multiple ip addresses for one site?

Discussion in 'General Discussion' started by Sillysoft, Mar 16, 2011.

  1. Sillysoft

    Sillysoft Member

    Joined:
    Jun 5, 2009
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    In cpanel from what I understand you need to create a seperate account for each ip address you want to assign a site. We currently have an application that has multiple sites point to the same directory to load the pages. So all the sites are on the same cpanel account under the same ip address. Is there a way in cpanel to have different sites have different ip addressess assigned to them and still have them all point to the same folder where the pages reside?
     
  2. MattLee

    MattLee BANNED

    Joined:
    Aug 26, 2009
    Messages:
    83
    Likes Received:
    0
    Trophy Points:
    0
    Hello,

    While this wouldn't be possible within the cPanel interface, you could do this through custom modifications to your httpd configuration file located at: /usr/local/apache/conf/httpd.conf

    Each domain that is hosted on the server will have it's own virtual host entry that contains a document root path such as the entry I've pasted below.

    <VirtualHost 10.1.100.136:80>
    ServerName cptest.local
    ServerAlias www.cptest.local
    DocumentRoot /home/cptest/public_html
    ServerAdmin webmaster@cptest.local
    UseCanonicalName Off

    Simply change the document root for this entry to your desired location, save and then distill the configuration file with: /usr/local/cpanel/bin/apache_conf_distiller --update
     
  3. Sillysoft

    Sillysoft Member

    Joined:
    Jun 5, 2009
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Thank you for the answer! My next question then would be, if I did this how would it affect me needing to setup an SSL certificate on different sites? Would I follow the normal process of adding an SSL certificate via cpanel/WHM or would I need to do something else?
     
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You cannot directly edit httpd.conf files in this way. While the distiller will retain the changes, once you run /scripts/rebuildhttpdconf or recompile Apache via EasyApache, it will wipe those changes. It even has this above each VirtualHost entry to warn against doing this method of editing the VirtualHost directly in httpd.conf file:

    As such, to change the document root for individual domains, you need to instead for this in the userdata files at /var/cpanel/userdata/username/domain.com location. It will be listed like the following in that file:

    Code:
    documentroot: /home/username/public_html
    You can change the path to whatever path you prefer, then run the following to save the prior Apache configuration, rebuild with the new changes, and restart Apache:

    Code:
    cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak110329
    /scripts/rebuildhttpdconf
    /etc/init.d/httpd restart
    Using this method will retain the changes made to the document root path unlike the previously mentioned method.

    For the SSL question, you will need to manually edit the document root for any SSLs you install for these sites if they are also going to point to that same different directory, because the SSL is going to pick up the existing user and try to use that path not the changed path that you used. The SSL files are also in /var/cpanel/userdata/username/ location and called domain.com_SSL for those entries.
     
  5. Sillysoft

    Sillysoft Member

    Joined:
    Jun 5, 2009
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Thank you very much for the info! One other question, so do you recommend I create a seperate account in cpanel for each domain then edit the file per your instructions above so they all point to the same directory?
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    I wouldn't recommend creating new cPanel accounts but to have all of these on the same account. That way, you are only editing them within the same account to change the IP address. If you are using suPHP, you cannot point sites to another document root and have files function for that site because the user will not own the correct document root unless you are also going to change ownership for that account to the other user as well. A whole slew of issues will crop up for showing the files. If all you really need happens to be different IP addresses for different domains all with the same content, then you should put the domains all onto the same account, make them addon domains, change the document root to the public_html location of the main account, and change the IP address in that same userdata file. After that, you can also change the IP address in the DNS zone in /var/named/domain.com.db location.
     
  7. Sillysoft

    Sillysoft Member

    Joined:
    Jun 5, 2009
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    For the dns zone, do I edit it directly from command line? Like vim /var/named/domain.com.db and if so once the changes are made is there any additional steps to make sure the changes stick going forward? I really appreciate all the help!
     
  8. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You can edit it from the command line to change the IP. If you do not use WHM > Edit DNS Zone to make the change and use command line, you will need to update the SOA as well as change the IP address. Upon saving the file in command line, you'd need to run:

    Code:
    rndc reload
    If you process this via WHM > Edit DNS Zone area, it will update the SOA record and run a reload for the zone automatically on saving the zone.
     
  9. Sillysoft

    Sillysoft Member

    Joined:
    Jun 5, 2009
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Sorry for being a newb, but when editing the zone file for a specific domain in whm Im editing the A record for that domain correct? That is the only field I see that has an ip address associated with it.
     
  10. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Correct, you would be editing the A record for that domain.
     
  11. Sillysoft

    Sillysoft Member

    Joined:
    Jun 5, 2009
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Great! And should be last question, again very much appreciate the help, the example code you gave below:

    cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak110329
    /scripts/rebuildhttpdconf
    /etc/init.d/httpd restart

    That is all being done at command line correct? I just ask because of the dns editing question, just want to make sure I dont fudge things up.
     
  12. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Correct, the commands previously provided would be done via command line to back up the Apache configuration, rebuild the configuration and restart Apache after editing the /var/cpanel/userdata/username/ files.
     
  13. rinogo

    rinogo Member

    Joined:
    Dec 6, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Please forgive me for resurrecting an old thread; I normally wouldn't do so, but I believe what is described above is exactly what I need to do. I need to have multiple domains showing the same content via SSL. Since SSL only allows one cert per IP address, this means I need multiple IP's, each assigned to one specific domain, and all pointing to the same content. Would the solution you've posted above work for this SSL-specific situation?

    In other words, would this approach allow me to have multiple SSL certificates for different domains on one account, provided that I had an IP for each domain?

    Thank you so much! :)
    -Rich
     
  14. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hello Rich,

    If you need all to show the exact same content under suPHP, you'd have no choice but to do it this way. I would highly suggest getting a UCC certificate so you have the same certificate being used for all the domains, though. Otherwise, certificate install is going to be a bit of a nightmare.

    For the SSL, you won't just be changing the /var/cpanel/userdata/username/domain.com but for the path, you'll also be changing the /var/cpanel/userdata/username/domain.com_SSL file for the path. In all files, you'd likewise have to change the IP.

    You'll need to revise the DNS zones for each domain, too. This could be done in WHM > DNS Functions > Edit a DNS Zone area.

    Thanks!
     
Loading...

Share This Page