diff --git a/core/authorize.php b/core/authorize.php
index 114dcd3..c533618 100644
--- a/core/authorize.php
+++ b/core/authorize.php
@@ -24,11 +24,6 @@
 chdir('..');
 
 /**
- * Defines the root directory of the Drupal installation.
- */
-define('DRUPAL_ROOT', getcwd());
-
-/**
  * Global flag to identify update.php and authorize.php runs.
  *
  * Identifies update.php and authorize.php runs, avoiding unwanted operations
@@ -63,11 +58,11 @@ function authorize_access_allowed() {
 
 // *** Real work of the script begins here. ***
 
-require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
-require_once DRUPAL_ROOT . '/core/includes/common.inc';
-require_once DRUPAL_ROOT . '/core/includes/file.inc';
-require_once DRUPAL_ROOT . '/core/includes/module.inc';
-require_once DRUPAL_ROOT . '/core/includes/ajax.inc';
+require_once __DIR__ . '/includes/bootstrap.inc';
+require_once __DIR__ . '/includes/common.inc';
+require_once __DIR__ . '/includes/file.inc';
+require_once __DIR__ . '/includes/module.inc';
+require_once __DIR__ . '/includes/ajax.inc';
 
 // We prepare only a minimal bootstrap. This includes the database and
 // variables, however, so we have access to the class autoloader.
diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index a3a0f46..ea3d242 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -327,6 +327,13 @@
 const CONFIG_STAGING_DIRECTORY = 'staging';
 
 /**
+ * Defines the root directory of the Drupal installation.
+ *
+ * This strips two levels of directories off the current directory.
+ */
+define('DRUPAL_ROOT', dirname(dirname(__DIR__)));
+
+/**
  * Starts the timer with the specified name.
  *
  * If you start and stop the same timer multiple times, the measured intervals
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index d2e461e..5bde077 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -257,7 +257,7 @@ function install_begin_request(&$install_state) {
   }
 
   // Allow command line scripts to override server variables used by Drupal.
-  require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
+  require_once __DIR__ . '/bootstrap.inc';
 
   if (!$install_state['interactive']) {
     drupal_override_server_variables($install_state['server']);
diff --git a/core/install.php b/core/install.php
index 6f046b2..23770a9 100644
--- a/core/install.php
+++ b/core/install.php
@@ -9,11 +9,6 @@
 chdir('..');
 
 /**
- * Defines the root directory of the Drupal installation.
- */
-define('DRUPAL_ROOT', getcwd());
-
-/**
  * Global flag to indicate the site is in installation mode.
  *
  * The constant is defined using define() instead of const so that PHP
@@ -32,5 +27,5 @@
 }
 
 // Start the installer.
-require_once DRUPAL_ROOT . '/core/includes/install.core.inc';
+require_once __DIR__ . '/includes/install.core.inc';
 install_drupal();
diff --git a/core/modules/statistics/statistics.php b/core/modules/statistics/statistics.php
index 87e3dae..22d2fb4 100644
--- a/core/modules/statistics/statistics.php
+++ b/core/modules/statistics/statistics.php
@@ -8,12 +8,8 @@
 // Change the directory to the Drupal root.
 chdir('../../..');
 
-/**
-* Root directory of Drupal installation.
-*/
-define('DRUPAL_ROOT', getcwd());
-
-include_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
+// Load the Drupal bootstrap.
+include_once dirname(dirname(__DIR__)) . '/includes/bootstrap.inc';
 drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
 
 if (config('statistics.settings')->get('count_content_views')) {
diff --git a/core/modules/system/tests/http.php b/core/modules/system/tests/http.php
index 84476e3..5e5e702 100644
--- a/core/modules/system/tests/http.php
+++ b/core/modules/system/tests/http.php
@@ -18,7 +18,5 @@
 
 // Change current directory to the Drupal root.
 chdir('../../../..');
-
-define('DRUPAL_ROOT', getcwd());
-require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
+require_once dirname(dirname(dirname(__DIR__))) . '/includes/bootstrap.inc';
 drupal_handle_request(TRUE);
diff --git a/core/modules/system/tests/https.php b/core/modules/system/tests/https.php
index 0d96896..cc2bd45 100644
--- a/core/modules/system/tests/https.php
+++ b/core/modules/system/tests/https.php
@@ -17,7 +17,5 @@
 
 // Change current directory to the Drupal root.
 chdir('../../../..');
-
-define('DRUPAL_ROOT', getcwd());
-require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
+require_once dirname(dirname(dirname(__DIR__))) . '/includes/bootstrap.inc';
 drupal_handle_request(TRUE);
diff --git a/core/scripts/password-hash.sh b/core/scripts/password-hash.sh
index b91cd41..485f497 100755
--- a/core/scripts/password-hash.sh
+++ b/core/scripts/password-hash.sh
@@ -79,9 +79,9 @@
 }
 
 chdir('..');
-define('DRUPAL_ROOT', getcwd());
-
-include_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
+$core = dirname(__DIR__);
+include_once $core . '/includes/password.inc';
+include_once $core . '/includes/bootstrap.inc';
 
 $password_hasher = drupal_container()->get('password');
 
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index 5b666c1..a736492 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -311,8 +311,7 @@ function simpletest_script_init($server_software) {
   }
 
   chdir(realpath(__DIR__ . '/../..'));
-  define('DRUPAL_ROOT', getcwd());
-  require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
+  require_once dirname(__DIR__) . '/includes/bootstrap.inc';
 }
 
 /**
diff --git a/core/update.php b/core/update.php
index d24d6e0..99975d0 100644
--- a/core/update.php
+++ b/core/update.php
@@ -21,11 +21,6 @@
 // Change the directory to the Drupal root.
 chdir('..');
 
-/**
- * Defines the root directory of the Drupal installation.
- */
-define('DRUPAL_ROOT', getcwd());
-
 // Exit early if an incompatible PHP version would cause fatal errors.
 // The minimum version is specified explicitly, as DRUPAL_MINIMUM_PHP is not
 // yet available. It is defined in bootstrap.inc, but it is not possible to
@@ -404,12 +399,12 @@ function update_check_requirements($skip_warnings = FALSE) {
 
 // We prepare a minimal bootstrap for the update requirements check to avoid
 // reaching the PHP memory limit.
-require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
-require_once DRUPAL_ROOT . '/core/includes/update.inc';
-require_once DRUPAL_ROOT . '/core/includes/common.inc';
-require_once DRUPAL_ROOT . '/core/includes/file.inc';
-require_once DRUPAL_ROOT . '/core/includes/unicode.inc';
-require_once DRUPAL_ROOT . '/core/includes/schema.inc';
+require_once __DIR__ . '/includes/bootstrap.inc';
+require_once __DIR__ . '/includes/update.inc';
+require_once __DIR__ . '/includes/common.inc';
+require_once __DIR__ . '/includes/file.inc';
+require_once __DIR__ . '/includes/unicode.inc';
+require_once __DIR__ . '/includes/schema.inc';
 update_prepare_d8_bootstrap();
 
 // Determine if the current user has access to run update.php.
diff --git a/index.php b/index.php
index df30e3f..f0949e0 100644
--- a/index.php
+++ b/index.php
@@ -8,10 +8,5 @@
  * See COPYRIGHT.txt and LICENSE.txt files in the "core" directory.
  */
 
-/**
- * Root directory of Drupal installation.
- */
-define('DRUPAL_ROOT', getcwd());
-
-require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
+require_once __DIR__ . '/core/includes/bootstrap.inc';
 drupal_handle_request();
