Apache multiple name based virtual hosts on different ports on single apache instance

apache-2.2virtual-hosting

Is there a way to host apache multiple name based virtual hosts on different ports on single apache instance ?

Say for example default instance listen on port 80

Listen 80
<VirtualHost *:80>
    ServerAdmin alert@example.com
    DocumentRoot /usr/local/apache/htdocs/example
    ServerName example.com
    ServerAlias www.example.com
    Redirect permanent / http://www.example.com/
    ErrorLog logs/error_log
    CustomLog logs/access_log combined
</VirtualHost>

now I would like to have on the same instance of apache

<VirtualHost *:8088>
    ServerAdmin alert@example.com
    DocumentRoot /usr/local/apache/htdocs/example1
    ServerName example1.com
    ServerAlias www.example1.com
    Redirect permanent / http://www.example1.com/
    ErrorLog logs/error_log
    CustomLog logs/access_log combined
</VirtualHost>

Best Answer

You will also need to tell Apache itself to listen on the extra ports in /etc/apache2/ports.conf (if you're on a RedHat-based distro, it'll be in /etc/httpd/)

...
NameVirtualHost *:81
NameVirtualHost *:85
Listen 81
Listen 85
...
Related Topic