You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apache2为何不自动搜索目录中的index.php?

Alright, let's troubleshoot this step by step—since you're running Debian Stretch with XAMPP (given the /opt/lampp path), here are the most likely issues even if you think your httpd.conf is configured correctly:

Possible Causes & Fixes

1. DirectoryIndex Configuration Override or Oversight

While you checked httpd.conf, XAMPP often uses additional config files that can override global settings.

  • Open /opt/lampp/etc/httpd.conf and locate the DirectoryIndex line. Make sure it includes index.php, and that it’s listed before index.html (if both files exist in your root). A valid line looks like:
    DirectoryIndex index.php index.html index.htm
    
  • Also check /opt/lampp/etc/extra/httpd-xampp.conf—this file sometimes has its own DirectoryIndex setting that might take precedence.

2. Wrong Root Directory Placement

XAMPP’s default web root is /opt/lampp/htdocs. If your index.php is stored in a subfolder (like /opt/lampp/htdocs/my-project) instead of directly in htdocs, accessing localhost will load Apache’s default page instead of your file.

  • Double-check that your index.php lives directly in /opt/lampp/htdocs.

3. Apache’s Default index.html Still Exists

If /opt/lampp/htdocs contains both the Apache default index.html (the welcome page) and your index.php, Apache will load whichever file comes first in the DirectoryIndex list. If index.html is prioritized, you’ll see the default page.

  • Either delete /opt/lampp/htdocs/index.html, or adjust the DirectoryIndex order to put index.php first.

4. .htaccess File Interference

A .htaccess file in your htdocs directory can override the global DirectoryIndex setting without you noticing.

  • Check /opt/lampp/htdocs/.htaccess for lines like:
    DirectoryIndex index.html
    
    If found, modify it to include index.php (e.g., DirectoryIndex index.php index.html).

5. Apache Configuration Not Reloaded

Any changes to config files won’t take effect until you restart Apache.

  • Run this command in your terminal to restart XAMPP’s Apache service:
    sudo /opt/lampp/lampp restart apache
    

内容的提问来源于stack exchange,提问作者J. Doe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:29:55