【发布时间】:2013-12-16 08:47:22
【问题描述】:
我的服务器上有两个站点。我通过我的 IP 访问的一个,x.x.x.x/site1。另一个是注册域名,www.mysite.com。
最初,我只有 /etc/apache/sites-available/default 文件可用,但当我尝试加载上述任一站点时,我只得到了 /var/www/index.html 输出。
我为 mysite.com 添加了一个新的虚拟主机,其中包含以下代码:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/mysite
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/mysite>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Mysite.com 仅在默认禁用时加载,但随后 x.x.x.x/site1 不会。
所以,我启用了具有以下代码的默认虚拟主机:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
现在,xxxx/site1 有效,但 mysite.com 无效 - 而是加载 /var/www/index.html 页面.
我对问题所在感到困惑。
【问题讨论】:
-
网站建立在哪种语言之上。它有助于给出明确的答案
-
当您在文档根目录加载主网站时,它下面的任何 url 都会在第一个应用程序中搜索。你可以有 xx.xx/app1 和 xx.xx/app2 或 mysite.com 到主网站和 site1.mysite.com 到其他网站
-
这里的一些评论说,对于 ubuntu 12.10,您必须将默认值更改为 default.conf 才能让您的 mysite.com 正常工作。
标签: apache2 virtualhost ubuntu-12.10