To change a website’s port in Apache, you need to change the configuration in two places.
- The ports.conf file: This is where you tell Apache which ports to listen on for traffic. You need to add a Listen directive for the new port you want to use. For example, Listen 20000.
- Your site’s configuration file (Virtual Host): In your site’s configuration file (such as default-ssl.conf), you need to change the Virtual Host directive to match the new port. For example, instead of VirtualHost *:443, you would use VirtualHost *:20000.


Both changes are necessary so that Apache can properly listen for traffic on the new port and know what to do with it.
To apply the changes, you must restart Apache
sudo systemctl restart apache2