Example: Changing Default Apache Ports

Changing the default HTTP and HTTPS ports of a web server is useful when employing an additional web server for caching purposes. For example, nginx web server listens on the default ports (80 HTTP, 443 HTTPS), serves static content (for example, all requests but PHP), and redirects PHP requests to Apache. In turn, Apache web server listens on custom ports (for example, 8888 and 8999) and serves dynamic content - PHP requests.

To change the Apache HTTP port:

Find all occurrences of the string $VAR->server->webserver->httpPort and replace them with the required port number enclosed in quotation marks, for example: "3456".

To change the Apache HTTPS port:

Find all occurrences of the string $VAR->server->webserver->httpsPort and replace them with the required port number enclosed in quotation marks, for example: "4567".

Example

To make Apache listen to HTTP requests on port 3456, and HTTPS on 4567, make the changes described above in all templates.

For example, in domain/domainVirtualHost.php:

<VirtualHost <?php echo $VAR->domain->physicalHosting->ipAddress->address ?>:<?php echo $OPT['ssl'] ? $VAR->server->webserver->httpsPort : $VAR->server->webserver->httpPort ?>>
    ServerName "<?php echo $VAR->domain->asciiName ?>:<?php echo $OPT['ssl'] ? $VAR->server->webserver->httpsPort : $VAR->server->webserver->httpPort ?>"

change to

<VirtualHost <?php echo $VAR->domain->physicalHosting->ipAddress->address ?>:<?php echo $OPT['ssl'] ? "4567" : "3456" ?>>
    ServerName "<?php echo $VAR->domain->asciiName ?>:<?php echo $OPT['ssl'] ? "4567" : "3456" ?>"
 

Leave your comments on this page

Leave your feedback or question on this documentation topic below. For technical assistance, contact your hosting service provider or submit a request to Plesk support. Suggest new features for Plesk here. Discuss general questions on the Plesk forum. All offtopic comments will be removed.