How to configure multiple apache virtual hosts on multiple ports

Posted: 1p in Apache

How to configure multiple apache virtual hosts on multiple ports

I have a server with one IP address. I want to run several virtual hosts in an Apache 2.4. And I want all virtual hosts to be accessible on port 80,8000 and 443 (ssl).

The Listen directive tells the server to accept incoming requests only on the specified ports or address-and-port combinations. If only a port number is specified in the Listen directive, the server listens to the given port on all interfaces. If an IP address is given as well as a port, the server will listen on the given port and interface. Multiple Listen directives may be used to specify a number of addresses and ports to listen on. The server will respond to requests from any of the listed addresses and ports.

=-==–=
Listen *:80
Listen *:8080

NameVirtualHost *:80
NameVirtualHost *:8080

VirtualHost *:80
ServerName a.foo.com
DocumentRoot /www/a
/VirtualHost

VirtualHost *:8080
ServerName b.foo.com
DocumentRoot /www/ab
VirtualHost

=-=-=-

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s