Drupal 8突发跳转到/core/install.php且提示已安装求助
Hey there, let's work through this frustrating issue you're facing—suddenly getting redirected to www.example.com/core/install.php with the "Drupal already installed" message while updating your site, even though it was working fine before. I've dealt with this a handful of times, so here are the most likely causes and actionable fixes:
1. Check Your settings.php File (Most Common Culprit)
Drupal relies on the sites/default/settings.php file to confirm it's already installed. Issues here are usually the root cause:
- File Permissions: Make sure the file has correct permissions (typically
644on Linux servers). If permissions are too restrictive or open, Drupal might not be able to read the configuration and gets confused about the install state. - Missing/Corrupted Configuration: Open
settings.phpand verify:- The
$databasesarray has the correct database connection details (username, password, database name). A broken DB connection can trigger this redirect. - The
$settings['install_profile']line exists and points to your active profile (like'standard'). If this was accidentally removed, Drupal might think it needs to reinstall.
- The
- Accidental Overwrite: If you made a backup of
settings.phpbefore updating, compare it with the current version to spot any unintended changes.
2. Clear All Drupal Caches
Cached data can sometimes cause Drupal to misread its install state. Here's how to fix it:
- Manual Cache Clear: Delete all files in
sites/default/files/cacheandsites/default/files/php(leave.htaccessand other config files untouched). - Drush Command: If you have Drush access, run
drush crto clear all caches in one go. This is the fastest method if you can use it.
3. Verify Database Install State
Drupal stores its install status in the database's config table. A corrupted entry here can cause the conflicting message:
- Log into your database (via phpMyAdmin, CLI, or your hosting tool) and run this query:
SELECT * FROM config WHERE name = 'system.site'; - Look at the
datafield and check if"install_task":"done"is present. If it's set to anything else (like'install'), Drupal thinks the installation is incomplete, but since the site is already installed, you get the error. - To fix it, run this update query (adjust the old value if needed):
UPDATE config SET data = REPLACE(data, '"install_task":"install"', '"install_task":"done"') WHERE name = 'system.site';
4. Check .htaccess Rewrite Rules
If you modified the root .htaccess file while updating content, incorrect rewrite rules might be forcing the redirect to install.php:
- Compare your current
.htaccesswith the default version from the Drupal core package (match your Drupal version). Look for any extra rewrite rules that could be redirecting traffic to the install page. - Restore the default
.htaccessif you're unsure, then reapply any custom rules you had before (one at a time to test).
Start with the first two fixes—they resolve 90% of cases like this. If those don't work, move on to checking the database and .htaccess.
内容的提问来源于stack exchange,提问作者Byte Developer

