@@ -22,8 +22,8 @@ applied to the resulting parameter name:
22
22
* Double underscores are replaced with a period, as a period is not
23
23
a valid character in an environment variable name.
24
24
25
- For example, if you're using Apache, environment variables can be set using
26
- the following ``VirtualHost `` configuration:
25
+ For example, if you're using Apache, environment variables can be set using the
26
+ ` SetEnv `_ directive with the following ``VirtualHost `` configuration:
27
27
28
28
.. code-block :: apache
29
29
@@ -40,13 +40,41 @@ the following ``VirtualHost`` configuration:
40
40
</Directory>
41
41
</VirtualHost>
42
42
43
+ For Nginx web servers, the environment variables can be set with the `fastcgi_param `_
44
+ directive. For example, in the configuration file where the ``fastcgi_params ``
45
+ file is included:
46
+
47
+ .. code-block :: nginx
48
+
49
+ server {
50
+ server_name domain.tld www.domain.tld;
51
+ root /var/www/project/web;
52
+
53
+ location / {
54
+ try_files $uri /app.php$is_args$args;
55
+ }
56
+
57
+ location ~ ^/app\.php(/|$) {
58
+ fastcgi_pass unix:/var/run/php5-fpm.sock;
59
+ fastcgi_split_path_info ^(.+\.php)(/.*)$;
60
+ include fastcgi_params;
61
+ fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
62
+ fastcgi_param DOCUMENT_ROOT $realpath_root;
63
+ fastcgi_param SYMFONY__DATABASE__USER user;
64
+ fastcgi_param SYMFONY__DATABASE__PASSWORD secret;
65
+ internal;
66
+ }
67
+
68
+ # ...
69
+ }
70
+
43
71
.. note ::
44
72
45
- The example above is for an Apache configuration, using the ` SetEnv `_
46
- directive. However, this will work for any web server which supports
47
- the setting of environment variables.
73
+ The examples above are for an Apache and Nginx configuration. However, this
74
+ will work for any web server which supports the setting of environment
75
+ variables.
48
76
49
- Also, in order for your console to work (which does not use Apache ),
77
+ Also, in order for your console to work (which does not use web server ),
50
78
you must export these as shell variables. On a Unix system, you can run
51
79
the following:
52
80
@@ -148,3 +176,4 @@ the Symfony service container.
148
176
$container->setParameter('drupal.database.url', $db_url);
149
177
150
178
.. _`SetEnv` : http://httpd.apache.org/docs/current/env.html
179
+ .. _`fastcgi_param` : http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_param
0 commit comments