How to change cPanel/WHM port using command line

WHM/cPanel is the most popular web hosting panel used globally by website hosts. Standard port numbers for cPanel and WHM are 2082/2083 and 2086/2087 respectively.
We already discussed about the cPanel installation on server and many other cPanel/WHM related topics. The installation steps are quite easy for cpanel. You can check this link for step by step guideInstall Cpanel on centos“.

Default ports for cPanel and WHM

To access the WHM, cPanel, webmail etc cPanel has default port numbers. The default port numbers for cPanel and WHM are given below:

cPanel : 2082/2083(ssl)
WHM : 2086/2087(ssl)

How to change cpanel port using Command line option?

You can change the default port number to nay value. The cpanel ports basically defined in the configuration file ‘/var/cpanel/cpanel.config’. We can edit the value from here.

Follow the steps given below:

  1.  SSH into server as root user.
  2.  Open the configuration file by using your favorite editor and change the default port number.
nano /var/cpanel/cpanel.config

----------
port=2082
----------

After changing the default port value with your desired one, run the following commands to take it effect:

/usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings
/etc/init.d/httpd restart

That’s all you have to do, Please check and give your opinion below if you experience any issues or to discuss your ideas and experiences.