I'm setting up a server with cPanel and would like for apache to listen to port 8080 by default instead of port 80. (This is because I want to setup varnish cache to listen on 80 and direct traffic through it to the 8080 apache). I can probably go in and change the configuration files for apache directly but they will get re-generated whenever something's changed in cPanel. So, is there a way to do this from the cPanel/WHM frontend?
After looking into this a bit further, I can see a better solution is available:
In the tweak settings area of cPanel, look for the Apache non-SSL IP/port, and here you can tell cPanel to change from the default (0.0.0.0:80) to your requirements (0.0.0.0:8080), this should preserve the alteration through an Apache rebuild, although you may still need to disable the service manager (I'm not sure about this, would be worth testing).
To stop cPanel resetting your apache port, You will need to disable monitoring for HTTPD in the WHM interface by going to WHM -> Service Configuration -> Service Manager and unchecking HTTPD from the monitor column. You can then change the port in the httpd.conf and WHM will not go creating a new apache instance on port 80.
It seems disabling monitoring daemons to not interfere with an alternate port was only necessary pre-11.28.
See the WHM/cPanel docs on the subject. If you're running 11.28+, it should work to just change the port in Tweak Settings.
Also note the option in Tweak Settings should map to the config option