From 24e2d35c2241f1494b8ac51b9ffb5c969e971ac4 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Thu, 6 Oct 2016 19:24:57 +0200 Subject: [PATCH 1/2] Add Nginx configuration to environment variables --- configuration/external_parameters.rst | 41 +++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/configuration/external_parameters.rst b/configuration/external_parameters.rst index 2455040f150..29ccaa3fc8d 100644 --- a/configuration/external_parameters.rst +++ b/configuration/external_parameters.rst @@ -22,8 +22,8 @@ applied to the resulting parameter name: * Double underscores are replaced with a period, as a period is not a valid character in an environment variable name. -For example, if you're using Apache, environment variables can be set using -the following ``VirtualHost`` configuration: +For example, if you're using Apache, environment variables can be set using the +`SetEnv`_ directive with the following ``VirtualHost`` configuration: .. code-block:: apache @@ -40,13 +40,41 @@ the following ``VirtualHost`` configuration: +For Nginx web servers, the environment variables can be set with `fastcgi_param`_ +directive. For example in the configuration file where the ``fastcgi_params`` +file is included: + +.. code-block:: nginx + + server { + server_name domain.tld www.domain.tld; + root /var/www/project/web; + + location / { + try_files $uri /app.php$is_args$args; + } + + location ~ ^/app\.php(/|$) { + fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + fastcgi_param SYMFONY__DATABASE__USER user; + fastcgi_param SYMFONY__DATABASE__PASSWORD secret; + internal; + } + + # ... + } + .. note:: - The example above is for an Apache configuration, using the `SetEnv`_ - directive. However, this will work for any web server which supports - the setting of environment variables. + The examples above are for an Apache and Nginx configuration. However, this + will work for any web server which supports the setting of environment + variables. - Also, in order for your console to work (which does not use Apache), + Also, in order for your console to work (which does not use web server), you must export these as shell variables. On a Unix system, you can run the following: @@ -148,3 +176,4 @@ the Symfony service container. $container->setParameter('drupal.database.url', $db_url); .. _`SetEnv`: http://httpd.apache.org/docs/current/env.html +.. _`fastcgi_param`: http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_param From 8112db2d0557231f8b35afb13c4c22ecd8c18b9b Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Fri, 7 Oct 2016 21:48:43 +0200 Subject: [PATCH 2/2] Fix grammar in External parameters --- configuration/external_parameters.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configuration/external_parameters.rst b/configuration/external_parameters.rst index 29ccaa3fc8d..819daf60266 100644 --- a/configuration/external_parameters.rst +++ b/configuration/external_parameters.rst @@ -40,8 +40,8 @@ For example, if you're using Apache, environment variables can be set using the -For Nginx web servers, the environment variables can be set with `fastcgi_param`_ -directive. For example in the configuration file where the ``fastcgi_params`` +For Nginx web servers, the environment variables can be set with the `fastcgi_param`_ +directive. For example, in the configuration file where the ``fastcgi_params`` file is included: .. code-block:: nginx