Issue

Deploying a new name-based virtual host using Zend Deployment on the IBM i makes it very easy to specify the new virtual host.  However, if the new virtual host uses a port other than the default application port of 10100 (10090 for Zend Server 9.1.x, 2018.x and 2019.x or 10080 for Zend Server 6 - 8.5.x), there are a couple of directives that need to be manually added to the Apache configuration.

Environment

Zend Server for IBM i  running on any supported version of IBM i.

Vhost With Custom Port Does Not Add "Listen" Directive

Resolution

When setting up a new Virtual Host using deployment (Applications -> Virtual Hosts tab in Zend Server UI), you can specify a new port.  You need to add the Listen and NameVirtualHost directives to support the new port in the /www/zendphp74/httpd.conf configuration file.

Never use port 10101 or 10103 (10091 or 10093 for Zend Server 9.1.x, 2018.x and 2019.x , 10081 or 10083 for Zend Server 6 - 8).  These ports are reserved for internal Zend Server use.

Perhaps the easiest way to edit the Apache configuration file is in the IBM Web Administration for i utility .  The HTTP Server to select is ZENDPHP74 (or ZENDPHP7 for Zend Server 9.1.x, 2018.x and 2019.x or ZENDSVR6 for Zend Server 6 - 8.5.x).  You can also edit file /www/zendphp74/httpd.conf (or /www/zendphp7/http.conf or /www/zendsrv6/httpd.conf) in a text editor like Zend Studio.

A common use for adding a different port is to use port 80, the standard port for web pages, or 443, the standard port for web pages using SSL.  In this example we will add port 443 to the Apache configuration.  This can be done either before or after the new virtual host is added.  It is better to add the port to the Apache configuration first, so that the virtual host will be available as soon as it is added.

For Zend Server 2020.x and 2021.x 

In the ZENDPHP74 Apache configuration, find the existing directives for 10100 and 10101

Listen *:10101
NameVirtualHost *:10101
Listen *:10100
NameVirtualHost *:10100

Add the two new directives just below the existing ones, so now the section will look like this:

Listen *:10101
NameVirtualHost *:1010101
Listen *:10100
NameVirtualHost *:10100
# Add port 443
Listen *:443
NameVirtualHost *:443

Restart the ZENDPHP74 instance of Apache for this change to take effect.


For Zend Server 9.1.x and higher (including  2018.0.x)

In the ZENDPHP7 Apache configuration, find the existing directives for 10091 and 10090:

Listen *:10091
NameVirtualHost *:10091
Listen *:10090
NameVirtualHost *:10090

Add the two new directives just below the existing ones, so now the section will look like this:

Listen *:10091
NameVirtualHost *:10091
Listen *:10090
NameVirtualHost *:10090
# Add port 443
Listen *:443
NameVirtualHost *:443

Restart the ZENDPHP7 instance of Apache for this change to take effect.

For Zend Server 6 - 8.5.x:

In the ZENDSRV6 Apache configuration, find the existing directives for 10081 and 10080:

Listen *:10081
NameVirtualHost *:10081
Listen *:10080
NameVirtualHost *:10080

Add the two new directives just below the existing ones, so now the section will look like this:

Listen *:10081
NameVirtualHost *:10081
Listen *:10080
NameVirtualHost *:10080
# Add port 443
Listen *:443
NameVirtualHost *:443

Restart the ZENDSRV6 instance of Apache for this change to take effect.

Something else you might need to do

If you are adding a port that is also used by another Apache or other TCP server, you might need to specify an IP address as well as the port, to make the Listen unique.  This might be true if you want to add something like 80 or 443 (the standard http and https ports), and those ports are used on other servers.  It is possible to have two Apache instances listening on the same port.  the trick is that your IBM i needs to have two different IP addresses assigned, and each server must listen on a unique ip address.  This article will not go into the details on how to set this up.  Your Network Administrator should set this up for you, and then tell you which IP address to use for your new virtual host.

In this example, the Network Administrator has asked us to use IP address 192.168.19.203 and port 443.

Then you would make it look like this (example IP and port 192.168.19.203:443):

#Add port 443
Listen 192.168.19.203:443
NameVirtualHost 192.168.19.203:443

You also have to fix the template for the virtual host to show the IP address, which you will be able to do during the Virtual Host Deployment, or afterwards using the editor.  Change this:

<VirtualHost *:${port}>

to this:

<VirtualHost 192.168.19.203:${port}>

Of course, the other Apache instance will also need to be set up to listen to its own IP address.