I'm currently using name-based virtual host configuration /conf/extra/httpd-vhosts.conf
in apache to serve few different websites from the same IP address, just like in the apache documentation.
<VirtualHost *:80>
ServerName domain1.example.com
DocumentRoot /www/domain1
</VirtualHost>
<VirtualHost *:80>
ServerName domain2.example.com
DocumentRoot /www/domain2
</VirtualHost>
If I try to open a web site, that is configured in /conf/httpd.conf
, defined by directive ServerName
, which is basically FQDN of Linux server, I'm getting the very 1st page defined in /conf/extra/httpd-vhosts.conf
- apache is acting that DNS name does not match any ServerName
defined, therefore I'm getting the 1st one from /conf/extra/httpd-vhosts.conf
.
If I change the directive Listen
in /conf/httpd.conf
to a different port (from that defined in /conf/extra/httpd-vhosts.conf
; I'm using standard port 80) and then try to hit http://ServerName:Port
(Port defined in Listen
- I used 8000 for testing purpose), I'm getting content of web site configured in /conf/httpd.conf
(ServerRoot
), which is what I want.
I tried to change the port defined in /conf/extra/httpd-vhosts.conf
to match it with that one temporary configured in /conf/httpd.conf
e.g.:
<VirtualHost *:8000>
ServerName domain1.example.com
DocumentRoot /www/domain1
</VirtualHost>
<VirtualHost *:8000>
ServerName domain2.example.com
DocumentRoot /www/domain2
</VirtualHost>
Now, when I hit http://ServerName:Port
(port = 8000), apache again gives me 1st web site from /conf/extra/httpd-vhosts.conf
- domain1.example.com
I tried to update directives Listen
(in /conf/httpd.conf
) with server IP, IP:port but it does not work either.
My server has DNS A record, web sites in /conf/extra/httpd-vhosts.conf
are configured in DNS as ALIAS records for server A record.
EDIT:
Adding ouput of apachectl -S
:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server domain1.example.com (/appl/apache24/conf/extra/httpd-vhosts.conf:24)
port 80 namevhost domain1.example.com (/appl/apache24/conf/extra/httpd-vhosts.conf:24)
alias domain1.example.com
port 80 namevhost domain2.example.com (/appl/apache24/conf/extra/httpd-vhosts.conf:38)
alias domain2.example.com
ServerRoot: "/appl/apache24"
Main DocumentRoot: "/appl/apache24/htdocs"
Main ErrorLog: "|/appl/apache24/bin/rotatelogs /appl/apache24/logs/admin-error_log.%Y%m%d 86400"
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/appl/apache24/logs/" mechanism=default
Mutex ssl-stapling-refresh: using_defaults
PidFile: "/appl/apache24/logs/httpd.pid"
EDIT2:
Adding output of apachectl -V
:
Server version: Apache/2.4.23 (Unix)
Server built: Sep 21 2016 11:23:28
Server's Module Magic Number: 20120211:61
Server loaded: APR 1.5.2, APR-UTIL 1.5.4
Compiled using: APR 1.5.2, APR-UTIL 1.5.4
Architecture: 64-bit
Server MPM: event
threaded: yes (fixed thread count)
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/opt/app/workload/apache24"
-D SUEXEC_BIN="/opt/app/workload/apache24/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"