下面是我的 /etc/apache2/sites_available/default 文件。
我已将 mysite.com 指向 /etc/hosts 中的 localhost,当从运行它的同一台机器访问该网站时,该网站工作正常。
但是,如果我有第二台机器,编辑它的 /etc/hosts 并将 mysite.com 指向第一台机器,那么 apache 只会提供一般Not Found: The requested URL / was not found on this server
消息。(如果我在第一台机器上导航到http://127.0.0.1而不是使用名称 mysite.com,则会收到完全相同的消息) access.log 或 error.log 中没有任何内容,但 other_vhosts_access.log 中有内容
为什么会发生这种情况,我该如何解决?另外,当我踢 Apache 时,它会说NameVirtualHost *:80 has no VirtualHosts
,以防万一。
这是配置文件:
<VirtualHost mysite.com:80>
ServerName mysite.com
ServerAdmin webmaster@mysite.com
DocumentRoot /var/www/mysite.com/public_html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/mysite.com/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel info
ErrorLog ${APACHE_LOG_DIR}/mysite.com.error.log
CustomLog ${APACHE_LOG_DIR}/mysite.com.access.log combined
</VirtualHost>