简体   繁体   中英

apache virtualhost (windows) not changing DocumentRoot

When setting up a vHost on apache (windows 10), everything works fine - instead of the DocumentRoot. It's still the htdocs-directory instead of the one I set in httpd-vhosts.conf:

Listen 80
<VirtualHost *:80>
    ServerAdmin your@email.com
    DocumentRoot "C:\Test"
    ServerName www.test.test
    <Directory "C:\Test">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

I also added the domain to the hosts folder at C:\\Windows\\System32\\drivers\\etc> to. So that part works fine:

# localhost name resolution is handled within DNS itself.
    127.0.0.1       localhost
#   ::1             localhost
    127.0.0.1       www.test.test

Just when changing the documentRoot in the httpd.conf file like:

#DocumentRoot "${SRVROOT}/htdocs"
DocumentRoot "C:\Test"
<Directory "C:\Test">
...

it seems to work. But that can't be a proper solution...

Apache doesn't load automatically every file it founds under the conf directory. You need to use the Include directive to load explicitly those you need, as in:

Include conf/extra/httpd-vhosts.conf

It's also possible to load complete directories, eg:

Include "C:/Data/vhosts/*.conf"

You can verify what files are being loaded with this command:

httpd -t -D DUMP_INCLUDES

... and what virtual hosts are being defined with:

httpd -t -D DUMP_VHOSTS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM