logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache 2.4/Windows Svr 2016 - Setting up for multiple hosts
Author
bazianm



Joined: 01 Jul 2014
Posts: 11
Location: Passaic, NJ

PostPosted: Thu 14 Feb '19 1:12    Post subject: Apache 2.4/Windows Svr 2016 - Setting up for multiple hosts Reply with quote

I am running Apache 2.4/64bit on Windows 2016 Server. I did not setup the server or install Apache... the network company did. (I asked for Linux but I was shouted down).

Anyway, I setup a virtual host in the conf file but not matter what I do I cannot seem to get it to load the site from its DocumentRoot; it only loads the default website even for the virtual host I added.

Here's my httpd-vhosts.conf:

Code:
# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "${SRVROOT}/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error.log"
    CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "${SRVROOT}/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin me@mydomain.org
    DocumentRoot "${SRVROOT}/htdocs/xmldef"
    ServerName xmldef.ntts.local
    ErrorLog "logs/xmldef-error.log"
    CustomLog "logs/xmldef-access.log" common
</VirtualHost>


Can anyone tell me what I am missing? I did google this but could not find anything related to this issue...

Thanks in advance.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7294
Location: Germany, Next to Hamburg

PostPosted: Thu 14 Feb '19 16:19    Post subject: Reply with quote

The default vhost should start with <VirtualHost _default_:80>

example vhost
Code:

<VirtualHost *:80>
   ServerName test.local

   DirectoryIndex index.php

   CustomLog "C:\nul" common

   DocumentRoot "C:/public"
   <Directory "C:/public">
      Options Indexes FollowSymLinks
      AllowOverride None
      Require all granted
      
      RewriteEngine on
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php [QSA]
   </Directory>
</VirtualHost>
Back to top
bazianm



Joined: 01 Jul 2014
Posts: 11
Location: Passaic, NJ

PostPosted: Wed 20 Feb '19 21:59    Post subject: Reply with quote

I tried that. It did not work. Is there something in another configuration file that I have to change for it to recognize multiple virtual hosts?
Back to top
mraddi



Joined: 27 Jun 2016
Posts: 149
Location: Schömberg, Baden-Württemberg, Germany

PostPosted: Thu 21 Feb '19 0:09    Post subject: Reply with quote

Have you already verified with "httpd -S" (tested on Windows) or "apachectl -S" (on Linux) that your Apache reads all config-files without errors and lists all vhosts you want to have?
Back to top


Reply to topic   Topic: Apache 2.4/Windows Svr 2016 - Setting up for multiple hosts View previous topic :: View next topic
Post new topic   Forum Index -> Apache