如何使用网络共享创建虚拟主机?

How do you create a virtualhost using a network share?

因此,我在 Windows 上将 WAMP 安装到 运行 Apache 和 PHP 并且我需要创建转到网络共享 \\10.0.0.[=21 的虚拟主机=] Studios\Websites。当我访问该域时,出现 403 错误。这是我的 httpd-vhosts.conf 文件中的内容:

<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>

它甚至没有在 WAMP 的服务器管理器中注册为虚拟主机..

WAMP does not see my virtualhost.

403 Error

首先,使用正斜杠更容易,或者如果使用反斜杠,则必须转义所有斜杠

其次,如果您使用的是 Apache 2,则不应混合使用 Apache 2.2 和 2.4 语法。4.x 删除旧语法

<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>

或者使用反斜杠看起来像这样

<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>

现在,作为需要访问网络共享的 Apache,您需要确保启动 Apache 的帐户具有访问该网络共享的权限,并且该共享在机器启动时可用并且执行不需要任何人为干预。