diff --git a/core/includes/install.inc b/core/includes/install.inc
index 6f61503..8ba52b6 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -7,6 +7,7 @@
 
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use Drupal\Component\Utility\Crypt;
+use Drupal\Component\Utility\OpCodeCache;
 use Drupal\Component\Utility\Settings;
 use Drupal\Core\Database\Database;
 use Drupal\Core\DrupalKernel;
@@ -324,6 +325,11 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
         $old_settings = Settings::getAll();
         new Settings($settings_settings + $old_settings);
       }
+      // The existing settings.php file might have been included already. In
+      // case an opcode cache is enabled, the rewritten contents of the file
+      // will not be reflected in this process. Ensure to invalidate the file
+      // in case an opcode cache is enabled.
+      OpCodeCache::invalidate(DRUPAL_ROOT . '/' . $settings_file);
     }
   }
   else {
diff --git a/core/lib/Drupal/Component/Utility/OpCodeCache.php b/core/lib/Drupal/Component/Utility/OpCodeCache.php
new file mode 100644
index 0000000..eb17c0d
--- /dev/null
+++ b/core/lib/Drupal/Component/Utility/OpCodeCache.php
@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Component\Utility\OpCodeCache.
+ */
+
+namespace Drupal\Component\Utility;
+
+/**
+ * Provides helpers to handle PHP opcode caches.
+ *
+ * @ingroup utility
+ */
+class OpCodeCache {
+
+  /**
+   * Invalidates a PHP file from a possibly active opcode cache.
+   *
+   * In case the opcode cache does not support to invalidate an individual file,
+   * the entire cache will be flushed.
+   *
+   * @param string $pathname
+   *   The absolute pathname of the PHP file to invalidate.
+   */
+  public static function invalidate($pathname) {
+    clearstatcache(TRUE, $pathname);
+
+    if (extension_loaded('Zend OPcache')) {
+      opcache_invalidate($pathname, TRUE);
+    }
+    if (extension_loaded('apc')) {
+      // apc_delete_file() throws a PHP warning in case the specified file was
+      // not compiled yet.
+      // @see http://php.net/manual/en/function.apc-delete-file.php
+      @apc_delete_file($pathname);
+    }
+  }
+
+}
