-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
example.env.php
85 lines (71 loc) · 2.93 KB
/
example.env.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**
* Craft-Multi-Environment (CMS)
* @author nystudio107
* @copyright Copyright (c) 2017 nystudio107
* @link https://nystudio107.com/
* @package craft-multi-environment
* @since 1.0.4
* @license MIT
*
* This file should be renamed to '.env.php' and it should reside in your root
* project directory. Add '/.env.php' to your .gitignore. See below for production
* usage notes.
*/
// Determine the incoming protocol
if (isset($_SERVER['HTTPS']) && (strcasecmp($_SERVER['HTTPS'], 'on') === 0 || $_SERVER['HTTPS'] == 1)
|| isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strcasecmp($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') === 0
) {
$protocol = "https://";
} else {
$protocol = "http://";
}
// Determine the server hostname
$httpHost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
// The $craftEnvVars are all auto-prefixed with CRAFTENV_ -- you can add
// whatever you want here and access them via getenv() using the prefixed name
$craftEnvVars = array(
// The Craft environment we're running in ('local', 'staging', 'live', etc.).
'CRAFT_ENVIRONMENT' => 'REPLACE_ME',
// The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'.
'DB_HOST' => 'REPLACE_ME',
// The name of the database to select.
'DB_NAME' => 'REPLACE_ME',
// The database username to connect with.
'DB_USER' => 'REPLACE_ME',
// The database password to connect with.
'DB_PASS' => 'REPLACE_ME',
// The site url to use; it can be hard-coded as well
'SITE_URL' => $protocol . $httpHost . '/',
// The base url environmentVariable to use for Assets; it can be hard-coded as well
'BASE_URL' => $protocol . $httpHost . '/',
// The base path environmentVariable for Assets; it can be hard-coded as well
'BASE_PATH' => realpath(dirname(__FILE__)) . '/public/',
);
// Set all of the .env values, auto-prefixed with `CRAFTENV_`
foreach ($craftEnvVars as $key => $value) {
putenv("CRAFTENV_{$key}={$value}");
}
/**
* For production environments, this .env.php file can be used, or preferably,
* (for security & speed), set the $_ENV variables directly from the server config.
*
* Apache - inside the <VirtualHost> block:
SetEnv CRAFTENV_CRAFT_ENVIRONMENT "REPLACE_ME"
SetEnv CRAFTENV_DB_HOST "REPLACE_ME"
SetEnv CRAFTENV_DB_NAME "REPLACE_ME"
SetEnv CRAFTENV_DB_USER "REPLACE_ME"
SetEnv CRAFTENV_DB_PASS "REPLACE_ME"
SetEnv CRAFTENV_SITE_URL "REPLACE_ME"
SetEnv CRAFTENV_BASE_URL "REPLACE_ME"
SetEnv CRAFTENV_BASE_PATH "REPLACE_ME"
* Nginx - inside the server {} or location ~ \.php$ {} block:
fastcgi_param CRAFTENV_CRAFT_ENVIRONMENT "REPLACE_ME";
fastcgi_param CRAFTENV_DB_HOST "REPLACE_ME";
fastcgi_param CRAFTENV_DB_NAME "REPLACE_ME";
fastcgi_param CRAFTENV_DB_USER "REPLACE_ME";
fastcgi_param CRAFTENV_DB_PASS "REPLACE_ME";
fastcgi_param CRAFTENV_SITE_URL "REPLACE_ME";
fastcgi_param CRAFTENV_BASE_URL "REPLACE_ME";
fastcgi_param CRAFTENV_BASE_PATH "REPLACE_ME";
*/