【问题标题】:How to Vagrant scotchbox subdomain virtualhost如何流浪 scotchbox 子域虚拟主机
【发布时间】:2016-08-10 19:59:03
【问题描述】:

我已经安装了来自 scotch.io 的 vagrant 和 scotchbox 来进行本地开发,并且运行起来就像一个魅力。 现在我需要使用子域作为变量,我已经用谷歌搜索了,但仍然没有工作。 我已经更改了主机文件并添加了

192.168.33.10  scotch.box

是否需要为通配符子域主机添加一行? 我还在我的 conf 文件中添加了下一行

<VirtualHost *:80>
    DocumentRoot /var/www/public
    ServerName tenant.scotch.box
    ServerAlias *.scotch.box
</VirtualHost>

对不起,我的英语不好。

【问题讨论】:

    标签: vagrant apache2 localhost subdomain virtual-hosts


    【解决方案1】:

    只需添加 192.168.33.10 租户.scotch.box 给主机。

    【讨论】:

      【解决方案2】:

      几个月前我遇到了同样的问题。在托管操作系统上,您必须编辑主机文件。 在 Windows 上

      C:\Windows\System32\drivers\etc\hosts
      

      在 Linux 上

      sudo nano /etc/hosts
      

      然后您必须使用所需的主机名添加您的苏格兰威士忌盒的 IP 地址

      192.168.33.10 tenant.scotch.box
      

      如果您有多个子域,或者您正在同一个苏格兰威士忌盒上开发多个 Web 应用程序,您甚至可以在主机文件中添加多行。例如:

      192.168.33.10 sub1.scotch.box
      192.168.33.10 sub2.scotch.box
      192.168.33.10 sub3.scotch.box
      

      但不要忘记编辑位于 /etc/apache2/sites-available/YOUR_CONFIG.conf 的 Scotch Box 中的虚拟主机文件

      每个子域都需要一个&lt;VirtualHost *:80&gt; &lt;/VirtualHost&gt;。示例:

      <VirtualHost *:80>
        DocumentRoot /var/www/public
        ServerName sub1.scotch.box
        ServerAlias *.scotch.box
      </VirtualHost>
      

      【讨论】:

        猜你喜欢
        • 2013-04-26
        • 2015-06-24
        • 1970-01-01
        • 2019-09-12
        • 2013-10-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多