How to change the Apache port number on a cPanel WHM Server
How to change the Apache port number on a cPanel WHM Server
Default apache port number is 80 and you can change this port to a different one. You can change apache port either through WHM or from server backend
Steps to change the Apache port number through WHM
1. Open a new browser and type https://YourServerIP:2087 to access WHM
Enter username and password to login.
2. Search for Tweak settings in WHM search box like shown in the below picture
3. Click on “Tweak Settings” under “Server Configuration”
WHM Home » Server Configuration » Tweak Settings
4. In tweak settings click on the last tab “System”
Here you can change the Apache SSL port and Apache non-SSL IP/port. You can see that default port number is 80 and 433. You can select the radio button under the “default” port to change the port to a new one.
In the above picture you can see that I have changed the Apache port number to 8080.
5. Click on ‘Save’ to save the changes you have made in tweak settings.
Steps to change the Apache port number from server Backend
1. Log into linux server via SSH as ‘root’ user
2. Take a backup of cpanel.config file because we are going to edit it.
[root@server ~]# cp -a /var/cpanel/cpanel.config /var/cpanel/cpanel.config.backup
[root@server ~]#
3. Open tweak settings backend file /var/cpanel/cpanel.config using vi editor and change the below line.
apache_port=0.0.0.0:80
To
apache_port=0.0.0.0:8080
Save the file and exit
4. You have made changes in tweak settings so you must update Tweak settings using the below command
/usr/local/cpanel/whostmgr/bin/whostmgr2 –updatetweaksettings
5. Dont forget to rebuild Apache configuration after changing the port number
/scripts/rebuildhttpdconf
6. Restart cPanel and httpd service.
Command : Service httpd restart
Command : Service cPanel restart
Don’t forget to open the new Apache port in the server firewall.