8000 minor #7044 Add Nginx configuration to environment variables (peterko… · toby-griffiths/symfony-docs@eefbbec · GitHub
  • [go: up one dir, main page]

    Skip to content

    Commit eefbbec

    Browse files
    committed
    minor symfony#7044 Add Nginx configuration to environment variables (peterkokot)
    This PR was squashed before being merged into the 2.7 branch (closes symfony#7044). Discussion ---------- Add Nginx configuration to environment variables The environment variables example in the configuration chapter currently includes only configuration for Apache web server. This patch adds also Nginx with the `fastcgi_param` directive. Thank you for considering merging it. In case there needs to be some additional rewording or changes done, let me know. Commits ------- 2888016 Add Nginx configuration to environment variables
    2 parents 40f27ef + 2888016 commit eefbbec

    File tree

    1 file changed

    +35
    -6
    lines changed

    1 file changed

    +35
    -6
    lines changed

    configuration/external_parameters.rst

    Lines changed: 35 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -22,8 +22,8 @@ applied to the resulting parameter name:
    2222
    * Double underscores are replaced with a period, as a period is not
    2323
    a valid character in an environment variable name.
    2424

    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:
    2727

    2828
    .. code-block:: apache
    2929
    @@ -40,13 +40,41 @@ the following ``VirtualHost`` configuration:
    4040
    </Directory>
    4141
    </VirtualHost>
    4242
    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+
    4371
    .. note::
    4472

    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.
    4876

    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),
    5078
    you must export these as shell variables. On a Unix system, you can run
    5179
    the following:
    5280

    @@ -148,3 +176,4 @@ the Symfony service container.
    148176
    $container->setParameter('drupal.database.url', $db_url);
    149177
    150178
    .. _`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

    Comments
     (0)
    0