├── public
└── index.php
├── .gitignore
├── craft
└── config
│ ├── db.php
│ └── general.php
├── LICENSE
├── CHANGELOG.md
├── example.env.php
├── forge-example
└── NginxConfiguration.conf
└── README.md
/public/index.php:
--------------------------------------------------------------------------------
1 | $craftPath is set correctly in '.__FILE__);
24 | }
25 |
26 | require_once $path;
27 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Craft .gitignore
2 | #
3 | # Example .gitignore file for Craft CMS
4 | #
5 | # @author nystudio107
6 | # @copyright Copyright (c) 2017 nystudio107
7 | # @link https://nystudio107.com/
8 | # @package nystudio107/craft
9 | # @since 1.0.0
10 | # @license MIT
11 |
12 | # This file should be renamed to '.gitignore' and placed in your
13 | # Craft CMS project root directory
14 |
15 | # CRAFT ENVIRONMENT
16 | .env.php
17 | .env.sh
18 | .env
19 |
20 | # BUILD FILES
21 | /bower_components/*
22 | /node_modules/*
23 | /build/*
24 | /yarn-error.log
25 | /npm-debug.log
26 |
27 | # MISC FILES
28 | .cache
29 | .DS_Store
30 | .idea
31 | .project
32 | .settings
33 | *.esproj
34 | *.sublime-workspace
35 | *.sublime-project
36 | *.tmproj
37 | *.tmproject
38 | .vscode/*
39 | !.vscode/settings.json
40 | !.vscode/tasks.json
41 | !.vscode/launch.json
42 | !.vscode/extensions.json
43 | config.codekit3
44 | prepros-6.config
45 |
--------------------------------------------------------------------------------
/craft/config/db.php:
--------------------------------------------------------------------------------
1 | array(
15 | 'tablePrefix' => 'craft',
16 | 'server' => getenv('CRAFTENV_DB_HOST'),
17 | 'database' => getenv('CRAFTENV_DB_NAME'),
18 | 'user' => getenv('CRAFTENV_DB_USER'),
19 | 'password' => getenv('CRAFTENV_DB_PASS'),
20 | ),
21 |
22 | // Live (production) environment
23 | 'live' => array(
24 | ),
25 |
26 | // Staging (pre-production) environment
27 | 'staging' => array(
28 | ),
29 |
30 | // Local (development) environment
31 | 'local' => array(
32 | ),
33 | );
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 nystudio107
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Craft-Multi-Environment Changelog
2 |
3 | ## 1.0.6 - 2017.12.07
4 | ### Changed
5 | * Updated the default CME config to be in line with the Craft 3 version, in terms of the `custom` sub-array
6 | * Updated the `.gitignore` for popular editors
7 |
8 | ## 1.0.5 - 2017.02.20
9 | ### Changed
10 | * Handle load balancing and shared environments better via a check for `HTTP_X_FORWARDED_PROTO` in the protocol
11 | * General code cleanup
12 |
13 | ## 1.0.4 - 2017.01.02
14 | ### Changed
15 | * Refactored the `example.env.php` to set the `CRAFTENV` vars in an array, and auto-prefix them programatically
16 | * Updated README.md
17 |
18 | ## 1.0.3 - 2016.11.30
19 | ### Added
20 | * Added `CRAFTENV_CRAFT_ENVIRONMENT` so that the `CRAFT_ENVIRONMENT` constant is set via `.env.php`
21 | * Renamed `env` to `craftEnd`, accessible via `{{ craft.config.craftEnv }}`
22 | * Added an example Forge configuration in `forge-example`
23 |
24 | ### Changed
25 | * Updated README.md
26 |
27 | ## 1.0.2 - 2016.11.09
28 | ### Added
29 | * Added the `env` variable to `general.php`, accessible via `{{ craft.config.env }}`
30 |
31 | ### Changed
32 | * Updated README.md
33 |
34 | ## 1.0.1 - 2016.11.02
35 | ### Added
36 | * Added support for `CRAFTENV_SITE_URL`
37 |
38 | ### Changed
39 | * Clarified the usage for `CRAFTENV_BASE_URL` & `CRAFTENV_BASE_PATH`
40 | * Updated README.md
41 |
42 | ## 1.0.0 - 2016.11.01
43 | ### Changed
44 | * Initial release
45 |
--------------------------------------------------------------------------------
/craft/config/general.php:
--------------------------------------------------------------------------------
1 | array(
15 | 'omitScriptNameInUrls' => true,
16 | 'usePathInfo' => true,
17 | 'cacheDuration' => false,
18 | 'useEmailAsUsername' => true,
19 | 'generateTransformsBeforePageLoad' => true,
20 | 'siteUrl' => getenv('CRAFTENV_SITE_URL'),
21 | 'defaultSearchTermOptions' => array(
22 | 'subLeft' => true,
23 | 'subRight' => true,
24 | ),
25 | // Set the environmental variables
26 | 'environmentVariables' => array(
27 | 'baseUrl' => getenv('CRAFTENV_BASE_URL'),
28 | 'basePath' => getenv('CRAFTENV_BASE_PATH'),
29 | ),
30 | // Custom site-specific config settings
31 | 'custom' => array(
32 | 'basePath' => getenv('CRAFTENV_BASE_PATH'),
33 | 'baseUrl' => getenv('CRAFTENV_BASE_URL'),
34 | 'craftEnv' => CRAFT_ENVIRONMENT,
35 | 'staticAssetsVersion' => 1,
36 | ),
37 | ),
38 |
39 | // Live (production) environment
40 | 'live' => array(
41 | 'devMode' => false,
42 | 'enableTemplateCaching' => true,
43 | 'allowAutoUpdates' => false,
44 | // Custom site-specific config settings
45 | 'custom' => array(
46 | ),
47 | ),
48 |
49 | // Staging (pre-production) environment
50 | 'staging' => array(
51 | 'devMode' => false,
52 | 'enableTemplateCaching' => true,
53 | 'allowAutoUpdates' => false,
54 | // Custom site-specific config settings
55 | 'custom' => array(
56 | ),
57 | ),
58 |
59 | // Local (development) environment
60 | 'local' => array(
61 | 'devMode' => true,
62 | 'enableTemplateCaching' => false,
63 | 'allowAutoUpdates' => true,
64 | // Custom site-specific config settings
65 | 'custom' => array(
66 | ),
67 | ),
68 | );
69 |
--------------------------------------------------------------------------------
/example.env.php:
--------------------------------------------------------------------------------
1 | 'REPLACE_ME',
31 |
32 | // The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'.
33 | 'DB_HOST' => 'REPLACE_ME',
34 |
35 | // The name of the database to select.
36 | 'DB_NAME' => 'REPLACE_ME',
37 |
38 | // The database username to connect with.
39 | 'DB_USER' => 'REPLACE_ME',
40 |
41 | // The database password to connect with.
42 | 'DB_PASS' => 'REPLACE_ME',
43 |
44 | // The site url to use; it can be hard-coded as well
45 | 'SITE_URL' => $protocol . $httpHost . '/',
46 |
47 | // The base url environmentVariable to use for Assets; it can be hard-coded as well
48 | 'BASE_URL' => $protocol . $httpHost . '/',
49 |
50 | // The base path environmentVariable for Assets; it can be hard-coded as well
51 | 'BASE_PATH' => realpath(dirname(__FILE__)) . '/public/',
52 | );
53 |
54 | // Set all of the .env values, auto-prefixed with `CRAFTENV_`
55 | foreach ($craftEnvVars as $key => $value) {
56 | putenv("CRAFTENV_{$key}={$value}");
57 | }
58 |
59 | /**
60 | * For production environments, this .env.php file can be used, or preferably,
61 | * (for security & speed), set the $_ENV variables directly from the server config.
62 | *
63 | * Apache - inside the block:
64 |
65 | SetEnv CRAFTENV_CRAFT_ENVIRONMENT "REPLACE_ME"
66 | SetEnv CRAFTENV_DB_HOST "REPLACE_ME"
67 | SetEnv CRAFTENV_DB_NAME "REPLACE_ME"
68 | SetEnv CRAFTENV_DB_USER "REPLACE_ME"
69 | SetEnv CRAFTENV_DB_PASS "REPLACE_ME"
70 | SetEnv CRAFTENV_SITE_URL "REPLACE_ME"
71 | SetEnv CRAFTENV_BASE_URL "REPLACE_ME"
72 | SetEnv CRAFTENV_BASE_PATH "REPLACE_ME"
73 |
74 | * Nginx - inside the server {} or location ~ \.php$ {} block:
75 |
76 | fastcgi_param CRAFTENV_CRAFT_ENVIRONMENT "REPLACE_ME";
77 | fastcgi_param CRAFTENV_DB_HOST "REPLACE_ME";
78 | fastcgi_param CRAFTENV_DB_NAME "REPLACE_ME";
79 | fastcgi_param CRAFTENV_DB_USER "REPLACE_ME";
80 | fastcgi_param CRAFTENV_DB_PASS "REPLACE_ME";
81 | fastcgi_param CRAFTENV_SITE_URL "REPLACE_ME";
82 | fastcgi_param CRAFTENV_BASE_URL "REPLACE_ME";
83 | fastcgi_param CRAFTENV_BASE_PATH "REPLACE_ME";
84 |
85 | */
86 |
--------------------------------------------------------------------------------
/forge-example/NginxConfiguration.conf:
--------------------------------------------------------------------------------
1 | # FORGE CONFIG (DOT NOT REMOVE!)
2 | include forge-conf/SOMEDOMAIN.com/before/*;
3 |
4 | # Bots to ban via user agent
5 | map $http_user_agent $limit_bots {
6 | default 0;
7 | ~*(AhrefsBot|Baiduspider|PaperLiBot) 1;
8 | }
9 |
10 | server {
11 | # Listen for both IPv4 & IPv6 requests on port 443 with http2 enabled
12 | listen 443 ssl http2;
13 | listen [::]:443 ssl http2;
14 |
15 | # General virtual host settings
16 | server_name SOMEDOMAIN.com;
17 | root /home/forge/SOMEDOMAIN.com/public;
18 | index index.html index.htm index.php;
19 | charset utf-8;
20 |
21 | # Ban certain bots from crawling the site
22 | if ($limit_bots = 1) {
23 | return 403;
24 | }
25 |
26 | # 404 error handler
27 | error_page 404 /index.php?$query_string;
28 |
29 | # 301 Redirect URLs with trailing /'s as per https://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html
30 | rewrite ^/(.*)/$ /$1 permanent;
31 |
32 | # Change // -> / for all URLs, so it works for our php location block, too
33 | merge_slashes off;
34 | rewrite (.*)//+(.*) $1/$2 permanent;
35 |
36 | # Handle Do Not Track as per https://www.eff.org/dnt-policy
37 | location /.well-known/dnt-policy.txt {
38 | try_files /dnt-policy.txt /index.php?p=/dnt-policy.txt;
39 | }
40 |
41 | # For WordPress bots/users
42 | location ~ ^/(wp-login|wp-admin|wp-config|wp-content|wp-includes|(.*)\.exe) {
43 | return 301 https://wordpress.com/wp-login.php;
44 | }
45 |
46 | # Access and error logging
47 | access_log off;
48 | error_log /var/log/nginx/SOMEDOMAIN.com-error.log error;
49 | # If you want error logging to go to SYSLOG (for services like Papertrailapp.com), uncomment the following:
50 | #error_log syslog:server=unix:/dev/log,facility=local7,tag=nginx,severity=error;
51 |
52 | # FORGE SSL (DO NOT REMOVE!)
53 | # ssl_certificate;
54 | # ssl_certificate_key;
55 | ssl_certificate /etc/nginx/ssl/SOMEDOMAIN.com/XXXXXX/server.crt;
56 | ssl_certificate_key /etc/nginx/ssl/SOMEDOMAIN.com/XXXXXX/server.key;
57 |
58 | # SSL/TLS configuration, with TLSv1.0 disabled because it is insecure; note that IE 8, 9 & 10 support
59 | # TLSv1.1, but it's not enabled by default clients using those browsers will not be able to connect
60 | ssl_protocols TLSv1.2 TLSv1.1;
61 | ssl_prefer_server_ciphers on;
62 | ssl_dhparam /etc/ssl/certs/dhparam.pem;
63 | ssl_ciphers 'ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5';
64 | ssl_buffer_size 4k;
65 | ssl_session_timeout 4h;
66 | ssl_session_cache shared:SSL:40m;
67 | ssl_stapling on;
68 | ssl_stapling_verify on;
69 | ssl_trusted_certificate /etc/nginx/ssl/lets-encrypt-x3-cross-signed.pem;
70 |
71 | # FORGE CONFIG (DOT NOT REMOVE!)
72 | include forge-conf/SOMEDOMAIN.com/server/*;
73 |
74 | # Load configuration files from nginx-partials
75 | include /etc/nginx/nginx-partials/*.conf;
76 |
77 | # Root directory location handler
78 | location / {
79 | try_files $uri/index.html $uri $uri/ /index.php?$query_string;
80 | }
81 |
82 | # Localized sites, hat tip to Johannes -- https://gist.github.com/johanneslamers/f6d2bc0d7435dca130fc
83 |
84 | # If you are creating a localized site as per: https://craftcms.com/docs/localization-guide
85 | # the directives here will help you handle the locale redirection so that requests will
86 | # be routed through the appropriate index.php wherein you set the `CRAFT_LOCALE`
87 |
88 | # Enable this by un-commenting it, and changing the language codes as appropriate
89 | # Add a new location @XXrewrites and location /XX/ block for each language that
90 | # you need to support
91 |
92 | #location @enrewrites {
93 | # rewrite ^/en/(.*)$ /en/index.php?p=$1? last;
94 | #}
95 | #
96 | #location /en/ {
97 | # try_files $uri $uri/ @enrewrites;
98 | #}
99 |
100 | # Craft-specific location handlers to ensure AdminCP requests route through index.php
101 | # If you change your `cpTrigger`, change it here as well
102 | location ^~ /admin {
103 | try_files $uri $uri/ /index.php?$query_string;
104 | }
105 | location ^~ /cpresources {
106 | try_files $uri $uri/ /index.php?$query_string;
107 | }
108 |
109 | # php-fpm configuration
110 | location ~ [^/]\.php(/|$) {
111 | try_files $uri $uri/ /index.php?$query_string;
112 | fastcgi_split_path_info ^(.+\.php)(/.+)$;
113 | # Change this to whatever version of php you are using
114 | fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
115 | fastcgi_index index.php;
116 | include fastcgi_params;
117 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
118 | fastcgi_param PATH_INFO $fastcgi_path_info;
119 | fastcgi_param HTTP_PROXY "";
120 |
121 | # See https://github.com/nystudio107/craft-multi-environment or https://github.com/nystudio107/craft3-multi-environment
122 | fastcgi_param CRAFTENV_CRAFT_ENVIRONMENT "REPLACE_ME";
123 | fastcgi_param CRAFTENV_DB_HOST "REPLACE_ME";
124 | fastcgi_param CRAFTENV_DB_NAME "REPLACE_ME";
125 | fastcgi_param CRAFTENV_DB_USER "REPLACE_ME";
126 | fastcgi_param CRAFTENV_DB_PASS "REPLACE_ME";
127 | fastcgi_param CRAFTENV_SITE_URL "REPLACE_ME";
128 | fastcgi_param CRAFTENV_BASE_URL "REPLACE_ME";
129 | fastcgi_param CRAFTENV_BASE_PATH "REPLACE_ME";
130 |
131 | fastcgi_intercept_errors off;
132 | fastcgi_buffer_size 16k;
133 | fastcgi_buffers 4 16k;
134 | fastcgi_connect_timeout 300;
135 | fastcgi_send_timeout 300;
136 | fastcgi_read_timeout 300;
137 | }
138 |
139 | location ~ /\.ht {
140 | deny all;
141 | }
142 | }
143 |
144 | # FORGE CONFIG (DOT NOT REMOVE!)
145 | include forge-conf/SOMEDOMAIN.com/after/*;
146 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Craft-Multi-Environment
2 |
3 | Efficient and flexible multi-environment config for Craft CMS
4 |
5 | Related: [Craft3-Multi-Environment for Craft 3.x](https://github.com/nystudio107/craft3-multi-environment)
6 |
7 | ## Overview
8 |
9 | [Multi-Environment Configs](https://craftcms.com/docs/multi-environment-configs) let you easily run a Craft CMS project in local dev, staging, and production. They allow different people to work in different environments without painful setup or coordination. You can read a more in-depth discussion of it in the M[ulti-Environment Config for Craft CMS](https://nystudio107.com/blog/multi-environment-config-for-craft-cms) article.
10 |
11 | ### Why another multi-environment config?
12 |
13 | There are a number of good approaches to implementing a multi-environment config in Craft CMS, but they each have drawbacks. There are two main approaches typically used are:
14 |
15 | 1. [Multi-Environment Configs](https://craftcms.com/docs/multi-environment-configs) - The problem with this approach is that it often results in data stored in a git repo (such as passwords, Stripe keys, etc.) that really shouldn't be.
16 | 2. [PHP dotenv](https://github.com/vlucas/phpdotenv) - The problem with this approach is that PHP dotenv is fairly heavy, and indeed the authors warn against using it in production. Instantiating the Composer auto-loader and reading in the `.env` file for every request adds unnecessary overhead.
17 |
18 | Craft-Multi-Environment (CME) is my attempt to create something that finds a middle-ground between the two approaches.
19 |
20 | ### How does it work?
21 |
22 | CME works by including a `.env.php` file (which is never checked into git) via the Craft `index.php` file that is loaded for every non-static request.
23 |
24 | The `.env.php` file sets some globally-accessible settings via `putenv()` for common things like the database password, database user, base URL, etc. You're also free to add your own as you see fit. The `craft/config/general.php` and `craft/config/db.php` can thus remain abstracted, and each environment can have their own local settings.
25 |
26 | This is more performant than auto-loading a class and reading a `.env` file for each request, but maintains the same flexibility. Additionally, since we are using `getenv()` to access the settings, these can be set directly by the webserver (without using the `.env.php` file at all) for additional security and performance.
27 |
28 | Also, since we're using `getenv()`, these settings are globally accessible in the PHP session, and can for instance be used in a Craft Commerce `commerce.php` file, accessed via plugins, etc.
29 |
30 | ## Using Craft-Multi-Environment
31 |
32 | ### Assumptions
33 |
34 | CME assumes that you have a folder structure such as this for your project root:
35 |
36 | .env.php
37 | craft/
38 | public/
39 | index.php
40 |
41 | If your folder structure is different, that's fine. But you may need to adjust the path to `.env.php` in the `index.php` file, and you may need to adjust the way `CRAFTENV_BASE_PATH` is constructed in your `.env.php` (or just hardcode the path).
42 |
43 | CME will also work fine with localized sites as well, you'll just need to adjust the aforementioned paths as appropriate.
44 |
45 | ### Setting it up
46 |
47 | 1. Copy `craft/config/general.php` and `craft/config/db.php` to your project's `craft/config` folder
48 | 2. Copy `public/index.php` to your project's public folder
49 | 3. Copy `example.env.php` to your project's root folder, then duplicate it, and rename the copy `.env.php`
50 | 4. Edit the `.env.php` file, replacing instances of `REPLACE_ME` with your appropriate settings
51 | 5. Add `/.env.php` to your `.gitignore` file
52 |
53 | The `public/index.php` file included with CME just has the following added at the top of it (it is otherwise unchanged):
54 |
55 | // Load the local Craft environment
56 | if (file_exists('../.env.php'))
57 | require_once '../.env.php';
58 | // Default environment
59 | if (!defined('CRAFT_ENVIRONMENT'))
60 | define('CRAFT_ENVIRONMENT', getenv('CRAFTENV_CRAFT_ENVIRONMENT'));
61 |
62 | You will need to create an `.env.php` file for each environment on which your Craft CMS project will be used (other team member's local dev, staging, production, etc.), but the `db.php`, `general.php`, and `index.php` are the same on all environments.
63 |
64 | It's recommended that the `example.env.php` **is** checked into your git repo, so others can use it for a guide when creating their own local `.env.php` file.
65 |
66 | ### Local environments
67 |
68 | CME suggests the following environments, each of which can have different Craft settings per environment, independent of the private settings defined in `.env.php`:
69 |
70 | 1. `*` - applies globally to all environments
71 | 2. `live` - your live production environment
72 | 3. `staging` - your staging or pre-production environment for client review, external testing, etc.
73 | 4. `local` - your local development environment
74 |
75 | The `db.php` and `config.php` define each environment, and you can put whatever [Craft Config Settings](https://craftcms.com/docs/config-settings) you desire for each environment in each. The names of the environments and the default settings for each are just suggestions, however. You can change them to be whatever you like.
76 |
77 | ### Extending it
78 |
79 | If you have additional settings that need to be globally accessible, you can just add them to the `.env.php`. For example, let's say we need a private key for Stripe, you can add this to `.env.php` by adding it to the `$craftenv_vars` array:
80 |
81 | // The private Stripe key.
82 | 'STRIPE_KEY' => 'REPLACE_ME',
83 |
84 | CME will auto-prefix all settings in the `$craftenv_vars` with `CRAFTENV_` for semantic reasons, and to avoid namespace collisions.
85 |
86 | You should also update the `example.env.php` to include any settings you add, for reference and your team's reference.
87 |
88 | ### Accessing the settings in `general.php`
89 |
90 | You can access any variables defined in the `general.php` file in Twig via `{{ craft.config }}`. e.g.:
91 |
92 | {% if craft.config.custom.craftEnv == "local" %}
93 | {% endif %}
94 |
95 | The `custom` sub-array in the config setup is for any non-Craft defined config settings that you might want to include in `general.php`. Since Craft does a recursive merge on the config settings, you can change just the config settings you need on a per-environment basis.
96 |
97 | ### Production via webserver config
98 |
99 | It's perfectly fine to use CME as discussed above in a production environment. However, if you want an added measure of security and performance, you can set up your webserver to set the same globally accessible settings via webserver config.
100 |
101 | It's slightly more secure, in that only a user with admin privileges should have access to the server config files. It's ever so slightly more performant, in that there's no extra `.env.php` file that is being processed with each request.
102 |
103 | This is entirely optional, but if you're interested in doing it, here's how.
104 |
105 | 1. Keep the original `public/index.php` file as it came with Craft CMS on your production environment instead of using the `index.php` that comes with CME.
106 | 2. Configure your webserver as described below, and then restart it
107 |
108 | #### Apache
109 |
110 | Inside the `` block:
111 |
112 | SetEnv CRAFTENV_CRAFT_ENVIRONMENT "REPLACE_ME"
113 | SetEnv CRAFTENV_DB_HOST "REPLACE_ME"
114 | SetEnv CRAFTENV_DB_NAME "REPLACE_ME"
115 | SetEnv CRAFTENV_DB_USER "REPLACE_ME"
116 | SetEnv CRAFTENV_DB_PASS "REPLACE_ME"
117 | SetEnv CRAFTENV_SITE_URL "REPLACE_ME"
118 | SetEnv CRAFTENV_BASE_URL "REPLACE_ME"
119 | SetEnv CRAFTENV_BASE_PATH "REPLACE_ME"
120 |
121 | (...and any other custom config settings you've added)
122 |
123 | #### Nginx
124 |
125 | Inside the `server {}` or `location ~ \.php {}` block or in the `fastcgi_params` file:
126 |
127 | fastcgi_param CRAFTENV_CRAFT_ENVIRONMENT "REPLACE_ME";
128 | fastcgi_param CRAFTENV_DB_HOST "REPLACE_ME";
129 | fastcgi_param CRAFTENV_DB_NAME "REPLACE_ME";
130 | fastcgi_param CRAFTENV_DB_USER "REPLACE_ME";
131 | fastcgi_param CRAFTENV_DB_PASS "REPLACE_ME";
132 | fastcgi_param CRAFTENV_SITE_URL "REPLACE_ME";
133 | fastcgi_param CRAFTENV_BASE_URL "REPLACE_ME";
134 | fastcgi_param CRAFTENV_BASE_PATH "REPLACE_ME";
135 |
136 | (...and any other custom config settings you've added)
137 |
138 | Brought to you by [nystudio107](https://nystudio107.com/)
139 |
--------------------------------------------------------------------------------