How to change the apache port via command line in cpanel?

The default port number for Apache web server is port 80. The secure port is 443. In some strange situations, we need to change the default port number from 80 to a different one.

In this article I’m going to explain the steps to change the default port from the Linux command line.

How to change the Apache port via command line in cPanel?

In a cPanel server the port value for the web server Apache is defined in the configuration file ‘/var/cpanel/cpanel.config‘. You can change the default value from this configuration file.

Please do follow the steps below to change it from command line interface:

Step 1: Open the configuration file by using your favorite text editor and find the directive ‘apache_port’

# vim /var/cpanel/cpanel.config


Step 2 : Change the port number

Here, 80 is the default port value. You can change it to your own custom value.

Step 3 : Run this script for it to take effect

# /usr/local/cpanel/whostmgr/bin/whostmgr2 –updatetweaksettings

Check the httpd conf file ‘/usr/local/apache/conf/httpd.conf‘ for finding any occurrences of default port (80) and run the following script to make httpd conf is up to date.

# /scripts/rebuildhttpdconf

That’s it!!

Similar topic : How to change cpanel port through command line

, ,

Post navigation

Arunlal Ashok

DevOps Engineer at Zeta Suite. Linux lover. Traveller. Father of two princesses.

Always happy for an open discussion! Write to arun ((@)) crybit ((dot)) com.

9 thoughts on “How to change the apache port via command line in cpanel?

  1. Thanks there, I made all process but do not work .

    I changed the port 80 to 8080 but when i run the command( /usr/local/cpanel/whostmgr/bin/whostmgr2 –updatetweaksettings ) said: “You haven’t licence cpanel “.

    Okay, I know, but is possible make this without license cpanel ?

    thanks !

  2. I followed your tutorial, and when run this command, “/usr/local/cpanel/whostmgr/bin/whostmgr2 –updatetweaksettings”, I got,
    “Unauthorized copying is prohibited”,

    I also tried to change port using tweak settings but after updating site is not working.

Leave a Reply

Your email address will not be published.