我的服务器上有两个站点。我通过我的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 页面
我对这个问题感到困惑。
答案 0 :(得分:0)
在myshost.com的vhost configuratin中,您需要添加ServerName指令:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName mysite.com
DocumentRoot /var/www/mysite
[…]