diff --git a/.env.dist b/.env.dist
new file mode 100644
index 0000000000000000000000000000000000000000..3d1b90bbdb650736d11ec8b6471aa09bfed3b13d
--- /dev/null
+++ b/.env.dist
@@ -0,0 +1,15 @@
+# MYSQL_HOST=""
+# MYSQL_USER=""
+# MYSQL_PASSWORD=""
+# MYSQL_DATABASE=""
+
+# STUDIP_CACHING_ENABLE=""
+# STUDIP_CACHE_IS_SESSION_STORAGE=""
+# STUDIP_ENV=""
+# STUDIP_MAIL_TRANSPORT=""
+# STUDIP_PLUGINS_UPLOAD_ENABLE=""
+
+## You may also change configuration settings from the environment. To do so, prefix the configuration name with
+## "STUDIP_CONFIG_". Example for changing the site name:
+#
+# STUDIP_CONFIG_UNI_NAME_CLEAN="new uni name"
diff --git a/app/views/admin/configuration/table-row.php b/app/views/admin/configuration/table-row.php
index 12769ed5c3c535520fc5fda7fee934fd54ebe5ee..a0725a5809bbb1976033490f88546b70aec6ba62 100644
--- a/app/views/admin/configuration/table-row.php
+++ b/app/views/admin/configuration/table-row.php
@@ -9,12 +9,16 @@
 ?>
 <tr id="field-<?= htmlReady($field) ?>">
     <td>
+    <? if (!Config::get()->fromEnv($field)): ?>
         <a data-dialog href="<?= $controller->link_for($linkchunk, compact('field')) ?>">
             <?= htmlReady($field) ?>
         </a>
-        <? if (!empty($description)): ?>
-            <br><small><?= htmlReady($description) ?></small>
-        <? endif; ?>
+    <? else: ?>
+        <?= htmlReady($field) ?>
+    <? endif; ?>
+    <? if (!empty($description)): ?>
+        <br><small><?= htmlReady($description) ?></small>
+    <? endif; ?>
     </td>
     <td class="wrap-content">
         <? if ($type === 'string' || $type === 'i18n'): ?>
@@ -31,8 +35,14 @@
     </td>
     <td><?= htmlReady($type) ?></td>
     <td class="actions">
+    <? if (!Config::get()->fromEnv($field)): ?>
         <a data-dialog="size=auto" href="<?= $controller->link_for($linkchunk, compact('field')) ?>">
             <?= Icon::create('edit')->asImg(['title' => _('Konfigurationsparameter bearbeiten')]) ?>
         </a>
+    <? else: ?>
+        <?= Icon::create('ufo', Icon::ROLE_INFO)->asImg([
+            'title' => _('Wert wurde über eine Umgebungsvariable gesetzt und kann an dieser Stelle nicht verändert werden.'),
+        ]) ?>
+    <? endif; ?>
     </td>
 </tr>
diff --git a/composer.json b/composer.json
index 92003f817f60951675361701a982e85f8f69c536..64ed0481c573a511aa77aa6ec06c74c635ca0a03 100644
--- a/composer.json
+++ b/composer.json
@@ -60,7 +60,8 @@
         "symfony/polyfill-php83": "^1.28",
         "phpoffice/phpspreadsheet": "^1.19",
         "psy/psysh": "^0.12.2",
-        "okvpn/clock-lts": "^1.0"
+        "okvpn/clock-lts": "^1.0",
+        "vlucas/phpdotenv": "^5.6"
     },
     "replace": {
         "symfony/polyfill-php73": "*",
diff --git a/composer.lock b/composer.lock
index 0c2e769ca2fafc342334c6952aa59d68a9392fcf..c469e1e0d194e7aaeb093d3fbe35f4e1ec0aa09d 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "2300fa9bd6d32d616b562b0790585cbe",
+    "content-hash": "69b82b7aa6db216cb8afdb9da520b4e7",
     "packages": [
         {
             "name": "algo26-matthias/idna-convert",
@@ -412,6 +412,68 @@
             },
             "time": "2020-11-24T22:02:12+00:00"
         },
+        {
+            "name": "graham-campbell/result-type",
+            "version": "v1.1.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/GrahamCampbell/Result-Type.git",
+                "reference": "fbd48bce38f73f8a4ec8583362e732e4095e5862"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/fbd48bce38f73f8a4ec8583362e732e4095e5862",
+                "reference": "fbd48bce38f73f8a4ec8583362e732e4095e5862",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.2.5 || ^8.0",
+                "phpoption/phpoption": "^1.9.2"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "GrahamCampbell\\ResultType\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Graham Campbell",
+                    "email": "hello@gjcampbell.co.uk",
+                    "homepage": "https://github.com/GrahamCampbell"
+                }
+            ],
+            "description": "An Implementation Of The Result Type",
+            "keywords": [
+                "Graham Campbell",
+                "GrahamCampbell",
+                "Result Type",
+                "Result-Type",
+                "result"
+            ],
+            "support": {
+                "issues": "https://github.com/GrahamCampbell/Result-Type/issues",
+                "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.2"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/GrahamCampbell",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2023-11-12T22:16:48+00:00"
+        },
         {
             "name": "guzzlehttp/psr7",
             "version": "2.4.4",
@@ -2432,6 +2494,81 @@
             },
             "time": "2021-10-31T15:09:20+00:00"
         },
+        {
+            "name": "phpoption/phpoption",
+            "version": "1.9.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/schmittjoh/php-option.git",
+                "reference": "80735db690fe4fc5c76dfa7f9b770634285fa820"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/80735db690fe4fc5c76dfa7f9b770634285fa820",
+                "reference": "80735db690fe4fc5c76dfa7f9b770634285fa820",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.2.5 || ^8.0"
+            },
+            "require-dev": {
+                "bamarni/composer-bin-plugin": "^1.8.2",
+                "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2"
+            },
+            "type": "library",
+            "extra": {
+                "bamarni-bin": {
+                    "bin-links": true,
+                    "forward-command": true
+                },
+                "branch-alias": {
+                    "dev-master": "1.9-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "PhpOption\\": "src/PhpOption/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "Johannes M. Schmitt",
+                    "email": "schmittjoh@gmail.com",
+                    "homepage": "https://github.com/schmittjoh"
+                },
+                {
+                    "name": "Graham Campbell",
+                    "email": "hello@gjcampbell.co.uk",
+                    "homepage": "https://github.com/GrahamCampbell"
+                }
+            ],
+            "description": "Option Type for PHP",
+            "keywords": [
+                "language",
+                "option",
+                "php",
+                "type"
+            ],
+            "support": {
+                "issues": "https://github.com/schmittjoh/php-option/issues",
+                "source": "https://github.com/schmittjoh/php-option/tree/1.9.2"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/GrahamCampbell",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2023-11-12T21:59:55+00:00"
+        },
         {
             "name": "phpowermove/docblock",
             "version": "v2.0.1",
@@ -5016,6 +5153,90 @@
             ],
             "time": "2021-09-14T12:46:25+00:00"
         },
+        {
+            "name": "vlucas/phpdotenv",
+            "version": "v5.6.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/vlucas/phpdotenv.git",
+                "reference": "2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4",
+                "reference": "2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4",
+                "shasum": ""
+            },
+            "require": {
+                "ext-pcre": "*",
+                "graham-campbell/result-type": "^1.1.2",
+                "php": "^7.2.5 || ^8.0",
+                "phpoption/phpoption": "^1.9.2",
+                "symfony/polyfill-ctype": "^1.24",
+                "symfony/polyfill-mbstring": "^1.24",
+                "symfony/polyfill-php80": "^1.24"
+            },
+            "require-dev": {
+                "bamarni/composer-bin-plugin": "^1.8.2",
+                "ext-filter": "*",
+                "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2"
+            },
+            "suggest": {
+                "ext-filter": "Required to use the boolean validator."
+            },
+            "type": "library",
+            "extra": {
+                "bamarni-bin": {
+                    "bin-links": true,
+                    "forward-command": true
+                },
+                "branch-alias": {
+                    "dev-master": "5.6-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Dotenv\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Graham Campbell",
+                    "email": "hello@gjcampbell.co.uk",
+                    "homepage": "https://github.com/GrahamCampbell"
+                },
+                {
+                    "name": "Vance Lucas",
+                    "email": "vance@vancelucas.com",
+                    "homepage": "https://github.com/vlucas"
+                }
+            ],
+            "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.",
+            "keywords": [
+                "dotenv",
+                "env",
+                "environment"
+            ],
+            "support": {
+                "issues": "https://github.com/vlucas/phpdotenv/issues",
+                "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/GrahamCampbell",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2023-11-12T22:43:29+00:00"
+        },
         {
             "name": "willdurand/negotiation",
             "version": "3.1.0",
diff --git a/config/config_defaults.inc.php b/config/config_defaults.inc.php
index 4a362ad0d9f6b855cb0f390725abc5e608c44bee..5901c2420cb095ce6cc36bf96ed728599b7888ff 100644
--- a/config/config_defaults.inc.php
+++ b/config/config_defaults.inc.php
@@ -10,10 +10,10 @@ please fill in your database connection settings.
 */
 
 // default Stud.IP database (DB_Seminar)
-$DB_STUDIP_HOST = "localhost";
-$DB_STUDIP_USER = "";
-$DB_STUDIP_PASSWORD = "";
-$DB_STUDIP_DATABASE = "studip";
+$DB_STUDIP_HOST = $_ENV['MYSQL_HOST'] ?? 'localhost';
+$DB_STUDIP_USER = $_ENV['MYSQL_USER'] ?? '';
+$DB_STUDIP_PASSWORD = $_ENV['MYSQL_PASSWORD'] ?? '';
+$DB_STUDIP_DATABASE = $_ENV['MYSQL_DATABASE'] ?? 'studip';
 $DEBUG_ALL_DB_QUERIES_WITH_TRACE = false;
 /*
 // optional Stud.IP slave database
@@ -66,9 +66,9 @@ $TMP_PATH ="/tmp";                                  //the system temp path
 $MEDIA_CACHE_PATH = $STUDIP_BASE_PATH . '/data/media_cache';
 
 //caching
-$CACHING_ENABLE = true;
+$CACHING_ENABLE = $_ENV['STUDIP_CACHING_ENABLE'] ?? true;
 $CACHING_FILECACHE_PATH = $TMP_PATH . '/studip_cache';
-$CACHE_IS_SESSION_STORAGE = false;                 //store session data in cache
+$CACHE_IS_SESSION_STORAGE = $_ENV['STUDIP_CACHE_IS_SESSION_STORAGE'] ?? false; //store session data in cache
 
 /*Stud.IP modules
 ----------------------------------------------------------------
@@ -159,7 +159,7 @@ $ELEARNING_INTERFACE_MODULES["loncapa"] =
         ]
 ];
 
-$PLUGINS_UPLOAD_ENABLE = TRUE;      //Upload of Plugins is enabled
+$PLUGINS_UPLOAD_ENABLE = $_ENV['STUDIP_PLUGIN_UPLOAD_ENABLE'] ?? true;      //Upload of Plugins is enabled
 
 $PLUGIN_REPOSITORIES = [
     'https://develop.studip.de/studip/plugins.php/pluginmarket/extern/xml',
@@ -193,7 +193,7 @@ sendmail  use local sendmail script
 qmail     use local Qmail MTA
 debug     mails are only written to a file in $TMP_PATH
 */
-$MAIL_TRANSPORT = "smtp";
+$MAIL_TRANSPORT = $_ENV['STUDIP_MAIL_TRANSPORT'] ?? 'smtp';
 
 /*smtp settings
 ----------------------------------------------------------------
diff --git a/lib/bootstrap-autoload.php b/lib/bootstrap-autoload.php
index 3a767c1fd74118252b625c50c7778ff051c514b1..eb9ac124e951192a3ba2c8f2fe04b5e28be96345 100644
--- a/lib/bootstrap-autoload.php
+++ b/lib/bootstrap-autoload.php
@@ -1,7 +1,4 @@
 <?php
-// Include composer's autoload
-require __DIR__ . '/../composer/autoload.php';
-
 // Setup autoloading
 require 'lib/classes/StudipAutoloader.php';
 StudipAutoloader::register();
diff --git a/lib/bootstrap.php b/lib/bootstrap.php
index 06ddca5d7b11eacf657ab1cea00c9ea853777daf..364f9d9f69fa47504ab5d323fb6544eebf5beb53 100644
--- a/lib/bootstrap.php
+++ b/lib/bootstrap.php
@@ -9,8 +9,16 @@
  * the License, or (at your option) any later version.
  */
 
+// Include composer's autoload
+require __DIR__ . '/../composer/autoload.php';
+
+// Load enviroment
+$dot_env_path = __DIR__ . '/..';
+$dotenv = \Dotenv\Dotenv::createImmutable($dot_env_path);
+$dotenv->safeLoad();
+
 // Default environment, do not change. Change in config/config_local.inc.php.
-const DEFAULT_ENV = 'production';
+define('DEFAULT_ENV',  $_ENV['STUDIP_ENV'] ?? 'production');
 
 //software version - please leave it as it is!
 $SOFTWARE_VERSION = '6.0.alpha';
diff --git a/lib/classes/Config.class.php b/lib/classes/Config.class.php
index 2f6b728fd03aff8a1bfc356ca81056308993310b..642665db5f5c1182e02f8e303a21ea188178e7a4 100644
--- a/lib/classes/Config.class.php
+++ b/lib/classes/Config.class.php
@@ -127,9 +127,14 @@ class Config implements ArrayAccess, Countable, IteratorAggregate
      */
     public function getValue($field)
     {
+        if ($this->fromEnv($field)) {
+            return $_ENV["STUDIP_CONFIG_{$field}"];
+        }
+
         if (array_key_exists($field, $this->data)) {
             return $this->data[$field];
         }
+
         if (isset($GLOBALS[$field]) && !isset($_REQUEST[$field])) {
             return $GLOBALS[$field];
         }
@@ -450,4 +455,15 @@ class Config implements ArrayAccess, Countable, IteratorAggregate
 
         return (string) $value;
     }
+
+    /**
+     * Returns whether the value was set from the environment.
+     *
+     * @param string $field
+     * @return bool
+     */
+    public function fromEnv(string $field): bool
+    {
+        return isset($_ENV["STUDIP_CONFIG_{$field}"]);
+    }
 }