为什么我得到的是 Apache2 Ubuntu 默认页面而不是我自己的 index.html 页面?

Que*_*ner 11 apache2

我有一台用于本地网站测试的 Ubuntu 14.10 计算机,它不提供给互联网。在它上面,我设置了七个网站。但是,当我访问七个中的两个时,我得到的是Apache2 Ubuntu Default Page而不是我自己的索引页。

据我所知,我使用完全相同的过程设置了所有七个,所以我不知道这两个缺少什么。此外,在我的 Apache 日志目录中,我有两个日志文件,error并且access对于两个行为不端的站点中的每一个,但它们都是空的。当我重新启动apache2服务时,没有错误。我已经多次回溯我的步骤,我看不出工作站点和非工作站点之间有任何区别。

我有哪些选项可以诊断此问题?我可以以某种方式强制更详细的错误日志吗?是否有其他日志可以参考?

以下是.conf故障站点之一的文件示例:

<VirtualHost *:80>
   ServerName www.local_example.com
   ServerAlias local_example.com
   ServerAdmin address@example.com

   DocumentRoot /var/www/Websites/example.com
   <Directory /var/www/Websites/example.com/>
       Options Indexes FollowSymLinks MultiViews
       # pcw AllowOverride None
       AllowOverride All
       Order allow,deny
       allow from all
       # This directive allows us to have apache2's default start page
       # in /apache2-default/, but still have / go to the right place
       # Commented out for Ubuntu
       #RedirectMatch ^/$ /apache2-default/
   </Directory>

   ErrorLog /home/example/Apache_Logs/local_example.com_error.log

   # Possible values include: debug, info, notice, warn, error, crit,
   # alert, emerg.
   LogLevel warn

   CustomLog /home/example/Apache_Logs/local_example.com_access.log combined
   ServerSignature On

</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

270*_*974 10

尝试以下

启用详细日志

sudo nano /etc/apache2/apache2.conf
Run Code Online (Sandbox Code Playgroud)

找到 LogLevel 变量,并将其从默认的 warn 更新为 info 或 debug。debug 将产生最大量的输出。

# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
# 
LogLevel debug
Run Code Online (Sandbox Code Playgroud)

重启阿帕奇

sudo service apache2 restart
Run Code Online (Sandbox Code Playgroud)

Apache 包含一个不错的小语法检查工具

apache2ctl -t
Run Code Online (Sandbox Code Playgroud)

检查虚拟主机定义

apache2ctl -S
Run Code Online (Sandbox Code Playgroud)


小智 7

对我来说,@Dan 的建议之一解决了它。

sudo a2dissite 000-default.conf
service apache2 reload
Run Code Online (Sandbox Code Playgroud)

显然,默认站点配置覆盖了我的 vhost 配置。


Que*_*ner 3

结果发现问题出在权限上。

当您将网站存储在外部目录/var/www并通过符号链接连接时,源目录及其父目录必须具有755.

由于某种未知的原因,这两个行为不当的网站具有不同的权限,chmod -R 755在网站目录及其父目录上运行可以解决问题。