apachewampvirtualhostweb-hostingnetwork-share

How do you create a virtualhost using a network share?


So, I installed WAMP on Windows to run Apache and PHP and I need to create virtualhosts that go to the network share \\10.0.0.177\FMS Studios\Websites. When I go to the domain I get a 403 error. This is what I have in my httpd-vhosts.conf file:

<VirtualHost *:80>
    ServerName tree.fmsds.xyz
    DocumentRoot "\\10.0.0.177\FMS Studios\Websites"
    <Directory  "\\10.0.0.177\FMS Studios\Websites">
        AllowOverride All
        Require all granted
        Order deny,allow
    </Directory>
</VirtualHost>

It does not even register as a virtualhost in WAMP's server manager..

WAMP does not see my virtualhost.

403 Error


Solution

  • First of all its easier to use forward slashes OR you have to escape all the slashes if you use backslashes

    Second you should not mix Apache 2.2 and 2.4 syntax so if you are using an Apache 2.4.x remove the old syntax

    <VirtualHost *:80>
        ServerName tree.fmsds.xyz
        DocumentRoot "//10.0.0.177/FMS Studios/Websites"
        <Directory  "//10.0.0.177/FMS Studios/Websites">
            AllowOverride All
            Require all granted
            # remove this as its Apache 2.2 syntax
            #Order deny,allow
        </Directory>
    </VirtualHost>
    

    Alternatively using backslashes would look like this

    <VirtualHost *:80>
        ServerName tree.fmsds.xyz
        DocumentRoot "\\\\10.0.0.177\\FMS Studios\\Websites"
        <Directory  "\\\\10.0.0.177\\FMS Studios\\Websites">
            AllowOverride All
            Require all granted
            # remove this as its Apache 2.2 syntax
            #Order deny,allow
        </Directory>
    </VirtualHost>
    

    Now as its Apache that will require access to the network share you need to be sure that the account that Apache starts under has permissions to access that network share, and that the share is available when the machine is booted and does not need any human intervension.