Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; SPOSTARBUST_Widget_Class has a deprecated constructor in /home2/cptech/public_html/wp-content/plugins/spostarbust/index.php on line 386

Deprecated: Function create_function() is deprecated in /home2/cptech/public_html/wp-content/plugins/spostarbust/index.php on line 611

Notice: The called constructor method for WP_Widget in SPOSTARBUST_Widget_Class is deprecated since version 4.3.0! Use
__construct()
instead. in /home2/cptech/public_html/wp-includes/functions.php on line 4514
Assign Multiple IP Addresses to a cPanel Account - A cPanel Tech

Assign Multiple IP Addresses to a cPanel Account

This article will help you to assign Multiple IP Addresses to a cPanel Account so that your subdomains and addon domains can have dedicated IPs. You will need it when you install SSL for such domains. Initially, this cannot be done via WHM. We need to edit some of the cPanel configuration files. So, you have to login to the server as root using SSH.

Please be aware that assigning a dedicated IP for a reason other than to install SSL will be a violation of ICANN terms.  For more details about ICANN policies, you can visit their website.

Editing the UserData Files

To assign Multiple IP Addresses to a cPanel Account, we basically need to edit the Apache configuration file, change the vhost to use the new IP, then save and restart the Apache HTTP Server. Next, edit the DNS zone so that the subdomain or the addon domain will point to the new IP. Take note that you should never edit the Apache configuration files directly as they are generated automatically by cPanel. The configuration files can be regenerated by issuing this command:

/scripts/rebuildhttpconf

So the user data have various files that help the Apache configuration builder to build the virtual host entry. You basically need to navigate to the user folder under /var/cpanel/userdata, and edit the corresponding files for the addon doman or subdomain and replace the IP entry with the new IP for the subdomain or addon domain.

cd /var/cpanel/userdata

Next, you’ll need to locate the user who requires that each subdomain use a dedicated IP address. We’ll call this user  username. To open username’s userdata folder:

cd username

Inside of the user’s userdata directory, you’ll find the following files:

  • example.com
  • example.com.cache
  • sub1.example.com
  • sub1.example.com.cache
  • main
  • main.cache

Next, you’ll need to change the IP addresses for the  subdomain sub1.example.com. You can do this using your preferred text editor (vi, vim, pico, nano, etc.). When you open the file to edit it, you should see entries that resemble the following:

customlog:
format: combined
target: /usr/local/apache/domlogs/sub1.example.com
  -
format: ""%{%s}t %I .\n%{%s}t %O .""
  target: /usr/local/apache/domlogs/sub1.example.com-bytes_log
  documentroot: /home/username/public_html/sub1
  group: Group1
  hascgi: 1
  homedir: /home/username
  ip: 192.168.0.1
  owner: username
  phpopenbasedirprotect: 1
  port: 80
  scriptalias:
  path: /home/username/public_html/sub1/cgi-bin
  url: /cgi-bin/
  -
  path: /home/username/public_html/sub1/cgi-bin/
  url: /cgi-bin/
  serveradmin: webmaster@example.com
  serveralias: www.sub1.example.com
  servername: sub1.example.com
  usecanonicalname: 'Off'
  user: username
  userdirprotect: ''

Within the subdomains’ files, you’ll need to edit the ip entry to reflect the dedicated IP address that should hold the user’s subdomains. For sub1.example.com, you would need to edit the file to reflect the following information:

customlog:
-
format: combined
target: /usr/local/apache/domlogs/sub1.example.com
  -
format: ""%{%s}t %I .\n%{%s}t %O .""
target: /usr/local/apache/domlogs/sub1.example.com-bytes_log
documentroot: /home/username/public_html/sub1
group: Group1
hascgi: 1
homedir: /home/username
ip: 192.168.0.2
owner: username
phpopenbasedirprotect: 1
port: 80
scriptalias:
  -
path: /home/username/public_html/sub1/cgi-bin
url: /cgi-bin/
  -
path: /home/username/public_html/sub1/cgi-bin/
url: /cgi-bin/
serveradmin: webmaster@example.com
serveralias: www.sub1.example.com
servername: sub1.example.com
usecanonicalname: 'Off'
user: username
userdirprotect: ''

Rebuilding and Restarting Apache

When you are finished modifying your userdata files, you will need to rebuild and restart Apache. To rebuild Apache, issue the following command:

/usr/local/cpanel/scripts/rebuildhttpdconf

Now, you will need to restart Apache. You can accomplish this by issuing the following command:

/usr/local/cpanel/scripts/restartsrv_apache

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu