公共IP指向vhosts的DocumentRoot

时间:2012-09-04 16:47:07

标签: php apache virtualhost ubuntu-12.04

刚刚获得了宠物项目的VPS和域名。我设置Apache和PHP,一切正常,直到我把我的公共IP放到URL。它会重定向到我的DocumentRoot集之一的VirtualHost

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

我需要调整哪些内容,以便每当我的公共IP是在URL上输入的IP时,它只会重定向到默认的It works! // /var/www/index.html

1 个答案:

答案 0 :(得分:0)

您只需要更改DocumentRoot

中全局httpd.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>