How to change Apache Port Number on a cPanel Server
Posted on February 27th, 2017
In this tutorial we can learn how to change Apache Port Number on a cPanel Server.
Apache is a widely-used web server that is distributed under “open source” license. By default, Apache uses port 80 and secure port 443. You can change the port through WHM or from the cli.
Follow the below Steps to change Apache port number through WHM.
1) Login to WHM through https://yourserverIP:2087
2) Go to ‘Tweak Settings’.
3) Click on ‘System’ under ‘Tweak settings’.
4) In system menu, we can change both Apache and SSL port number. By default, the port number will be 80 and 443 respectively. You can select the radio button under the default port to change the port number. Now you can change the port number.
5) Click on ‘Save’ button to make the changes.
Change the port number from the cli
1) Before altering the cPanel configuration file just take a backup for it. Use the following command to take the backup of cPanel configuration file.
# cp -a /var/cpanel/cpanel.config /var/cpanel/cpanel.config-backup
2) Open cPanel configuration file.
# vi /var/cpanel/cpanel.config
change the below line
apache_port=0.0.0.80
to
apache_port=0.0.0.8080
3) Rebuild the Apache configuration after changing the port number.
# /scripts/rebuildhttpdconf
4) Restart both cPanel and apache
# service httpd restart
# service cpanel restart
5) Open the new port in server firewall.
# vi /etc/csf/csf.allow
You need to add the new port number in ‘Allow incoming TCP port’ and ‘Allow outgoing TCP port’.
6) Restart csf.
# csf -r
If you need any further assistance please contact our support department.