【问题标题】:how to create multiple sub domain in local host? [closed]如何在本地主机中创建多个子域? [关闭]
【发布时间】:2015-02-05 18:52:47
【问题描述】:

使用 nginx 和 php 我需要在本地主机中创建多个子域。我怎样才能做到这一点?

我使用ubuntu 12.04php5nginx 作为网络服务器。

我已经在我的配置文件中尝试了*.servername.com。但是它不起作用。

【问题讨论】:

  • 这个问题不是程序问题...
  • @Marta Fernandeaz 非常感谢您的回复。我知道这不是程序相关的疑问。我是这个领域的新手,需要找到解决方案。我已经搜索了很多。但是
  • @thomashacko 尝试我的答案,如果发现任何困难,请告诉我。

标签: php nginx dns subdomain ubuntu-12.04


【解决方案1】:

在 localhost 中,您可以在 C:\Windows\System32\Drivers\etc 目录下的“hosts”文件中输入子域(它可能位于 linux 的 /etc)

127.0.0.1       maindomain.com
127.0.0.1       one.maindomain.com
127.0.0.1       two.maindomain.com

之后你必须在 httpd.conf 文件中进行输入

<VirtualHost 127.0.0.1:80>

DocumentRoot pathToMainDomain
ServerName maindomain.com
</VirtualHost>



<VirtualHost 127.0.0.1:80>

DocumentRoot pathToMainDomain

ServerName one.maindomain.com
</VirtualHost>



<VirtualHost 127.0.0.1:80>

DocumentRoot pathToMainDomain
ServerName two.maindomain.com
</VirtualHost>

【讨论】:

  • 嗨@prashant M 非常感谢您的回复。我这是创建多个虚拟主机。但在我的情况下,这不是我正在寻找的确切东西。 Dynamically creating sub domain 这就是我需要的。无论如何非常感谢。
  • 总是欢迎..我会检查动态创建子域并更新你..谢谢
  • 希望尽快收到您的来信。
  • 请查看我发现的与您的查询相关的这篇文章。它可能对您有所帮助.. stackoverflow.com/questions/5822117/… stackoverflow.com/questions/183928/…
  • 我正在努力为您的查询找到准确而清晰的解决方案..将让您保持更新。
猜你喜欢
  • 2013-09-18
  • 1970-01-01
  • 1970-01-01
  • 2012-03-28
  • 2011-03-09
  • 2011-02-14
  • 2017-12-24
  • 2011-11-12
  • 1970-01-01
相关资源
最近更新 更多