【问题标题】:Apache VirtualHost is pointing to wrong directory. (Ubuntu 14.04 LTS)Apache VirtualHost 指向错误的目录。 (Ubuntu 14.04 LTS)
【发布时间】:2015-02-15 06:13:30
【问题描述】:

这是我第一次创建虚拟主机并且遇到问题,因为它指向我的 Apache (/var/www/html) 主目录,而不是我想要的目录(/home/juninho/workspace/vhosts-projects/torpedogratis).

下面是我的 /etc/apache2/sites-available/torpedogratis.work.conf 文件:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /home/juninho/workspace/vhosts-projects/torpedogratis.work
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

下面是我的 /etc/hosts 文件:

127.0.0.1   localhost
127.0.0.1   torpedogratis.work
127.0.1.1   Juninho-Dell

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

当我进入http://torpedogratis.work/ 出现的内容是/var/www/html。 为什么会这样?

-

我以为错误在我的 /etc/hosts 文件中,所以我添加了第二行(127.0.0.1 torpedogratis.work),但仍然没有工作。

【问题讨论】:

  • 您是否启用了虚拟主机?我认为命令类似于sudo a2ensite torpedogratis.work.conf + reboot apache

标签: apache ubuntu virtualhost vps virtual-hosts


【解决方案1】:

如果你使用 /var/www/ 和 home/juninho/workspace/vhosts-projects/torpedogratis

然后

每次需要添加 2 个 DocumentRoot 条目

并且 Check 是 AllowOverRide 选项允许在哪个位置。

如果是 Centos 或 Redhat 则禁用 selinux 。

【讨论】:

    【解决方案2】:

    好像你错过了ServerName torpedogratis.work

    【讨论】:

    • 这并没有提供问题的答案。要批评或要求作者澄清,请在他们的帖子下方发表评论 - 您可以随时评论自己的帖子,一旦您有足够的reputation,您就可以comment on any post
    • 我显然是新来的,但是说“这并不能提供问题的答案。”不能证明它不回答这个问题。我不想批评或要求作者澄清,因为我(认为我)完全理解他。在我看来,他似乎离让他的虚拟主机工作只有一个指令,这是一个正确的ServerName。如果您认为我错了,而这在生活中总是有可能发生,请提供解释。
    • 这是来自审核过程的预制评论。像您这样的单行答案通常是代表没有足够代表的人尝试发表评论。这也不是一个很好的答案。哪个文件缺少这一行?添加这条线有什么作用?它是如何解决问题的? “似乎”听起来像是猜测或评论,而不是答案
    • 罐装 = 自动?对我来说,你似乎是一个普通的 SO 用户。我的回答是在问题的上下文中。由于提出问题的用户显示了两个文件的内容,其中只有一个包含与我提供的那个相似的指令,并且一个现有指令甚至开始相同(ServerAdmin),很明显我指的是什么。对我来说,“似乎”等于“据我所知”。我选择这样表达自己,这样我的回答听起来就不会是万无一失的。它是谦虚、礼貌和不安全感,与评论或猜测无关。
    猜你喜欢
    • 1970-01-01
    • 2017-07-21
    • 2022-12-30
    • 2014-08-12
    • 1970-01-01
    • 1970-01-01
    • 2016-02-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多