【问题标题】:Public IP points to DocumentRoot of vhosts公共 IP 指向 vhosts 的 DocumentRoot
【发布时间】:2012-09-04 16:47:07
【问题描述】:

最近刚刚为一个宠物项目获得了我的 VPS 和域。我设置了 Apache 和 PHP,一切正常,直到我将我的公共 IP 放入 URL。它重定向到我的一组VirtualHost 之一的DocumentRoot

<VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin webmaster@mydomain.com
  ServerName  mydomain.com
  ServerAlias www.mydomain.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/mysite
  <Directory /var/www/mysite>
    AllowOverride All
    Allow from mydomain.com
    Allow from www.mydomain.com
  </Directory>
  # Log file locations
  LogLevel warn
  ErrorLog  /home/me/public/mydomain.com/log/error.log
  CustomLog /home/me/public/mydomain.com/log/access.log combined
</VirtualHost>

我需要进行什么调整,以便每次在 URL 上输入我的公共 IP 时,它都会重定向到默认的 It works! // /var/www/index.html

【问题讨论】:

    标签: php apache virtualhost ubuntu-12.04


    【解决方案1】:

    您只需要更改全局DocumentRoothttpd.conf 中的指向

    #
    # DocumentRoot: The directory out of which you will serve your
    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.
    #
    DocumentRoot "/var/www/"
    

    并更改directory中的值:

    #
    # This should be changed to whatever you set DocumentRoot to.
    #
    <Directory "/var/www">
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    

    【讨论】:

    • 谢谢,顺便说一句 Options -Indexes +FollowSymLinks 这实际上是做什么的?
    • -Indexes 禁用目录列表,+FollowSymLinks 启用 symlinks
    猜你喜欢
    • 1970-01-01
    • 2020-02-19
    • 1970-01-01
    • 1970-01-01
    • 2016-02-16
    • 2013-10-25
    • 1970-01-01
    • 1970-01-01
    • 2017-01-01
    相关资源
    最近更新 更多