14 Nov

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

apache_port:0.0.0.0:80

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!!

Share this

Leave a reply