Skip to content

Commit c0d04fa

Browse files
committed
Clean-up Apache and Nginx parts
1 parent fa69cea commit c0d04fa

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

setup/web_server_configuration.rst

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ with Apache or Nginx.
2525
another location (e.g. ``public_html/``) make sure you
2626
:ref:`override the location of the public/ directory <override-web-dir>`.
2727

28-
Apache with PHP-FPM
28+
Configuring PHP-FPM
2929
-------------------
3030

31-
To make use of PHP-FPM with Apache, you first have to ensure that you have
32-
the FastCGI process manager ``php-fpm`` binary and Apache's FastCGI module
33-
installed (for example, on a Debian based system you have to install the
34-
``libapache2-mod-fastcgi`` and ``php7.4-fpm`` packages).
31+
All configuration examples below use the PHP FastCGI process manager
32+
(PHP-FPM). Ensure that you have installed PHP-FPM (for example, on a Debian
33+
based system you have to install the ``php-fpm`` package).
3534

3635
PHP-FPM uses so-called *pools* to handle incoming FastCGI requests. You can
3736
configure an arbitrary number of pools in the FPM configuration. In a pool
@@ -40,6 +39,8 @@ listen on. Each pool can also be run under a different UID and GID:
4039

4140
.. code-block:: ini
4241
42+
; /etc/php/7.4/fpm/pool.d/www.conf
43+
4344
; a pool called www
4445
[www]
4546
user = www-data
@@ -48,19 +49,21 @@ listen on. Each pool can also be run under a different UID and GID:
4849
; use a unix domain socket
4950
listen = /var/run/php/php7.4-fpm.sock
5051
51-
; or listen on a TCP socket
52-
listen = 127.0.0.1:9000
52+
; or listen on a TCP connection
53+
;listen = 127.0.0.1:9000
5354
54-
Using mod_proxy_fcgi with Apache 2.4
55-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55+
Apache
56+
------
5657

57-
If you are running Apache 2.4, you can use ``mod_proxy_fcgi`` to pass incoming
58-
requests to PHP-FPM. Configure PHP-FPM to listen on a TCP or Unix socket, enable
59-
``mod_proxy`` and ``mod_proxy_fcgi`` in your Apache configuration, and use the
60-
``SetHandler`` directive to pass requests for PHP files to PHP FPM:
58+
If you are running Apache 2.4+, you can use ``mod_proxy_fcgi`` to pass
59+
incoming requests to PHP-FPM. Install the Apache2 FastCGI mod
60+
(``libapache2-mod-fastcgi`` on Debian), enable ``mod_proxy`` and
61+
``mod_proxy_fcgi`` in your Apache configuration, and use the ``SetHandler``
62+
directive to pass requests for PHP files to PHP FPM:
6163

6264
.. code-block:: apache
6365
66+
# /etc/apache2/conf.d/domain.tld.conf
6467
<VirtualHost *:80>
6568
ServerName domain.tld
6669
ServerAlias www.domain.tld
@@ -70,21 +73,13 @@ requests to PHP-FPM. Configure PHP-FPM to listen on a TCP or Unix socket, enable
7073
#
7174
# SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
7275
73-
# For Apache 2.4.9 or higher
74-
# Using SetHandler avoids issues with using ProxyPassMatch in combination
75-
# with mod_rewrite or mod_autoindex
7676
<FilesMatch \.php$>
77-
SetHandler proxy:fcgi://127.0.0.1:9000
78-
# for Unix sockets, Apache 2.4.10 or higher
79-
# SetHandler proxy:unix:/path/to/fpm.sock|fcgi://dummy
80-
</FilesMatch>
77+
# when using PHP-FPM as a unix socket
78+
SetHandler proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://dummy
8179
82-
# If you use Apache version below 2.4.9 you must consider update or use this instead
83-
# ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/public/$1
84-
85-
# If you run your Symfony application on a subpath of your document root, the
86-
# regular expression must be changed accordingly:
87-
# ProxyPassMatch ^/path-to-app/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/public/$1
80+
# when PHP-FPM is configured to use TCP
81+
# SetHandler proxy:fcgi://127.0.0.1:9000
82+
</FilesMatch>
8883
8984
DocumentRoot /var/www/project/public
9085
<Directory /var/www/project/public>
@@ -110,6 +105,7 @@ The **minimum configuration** to get your application running under Nginx is:
110105

111106
.. code-block:: nginx
112107
108+
# /etc/nginx/conf.d/domain.tld.conf
113109
server {
114110
server_name domain.tld www.domain.tld;
115111
root /var/www/project/public;
@@ -127,7 +123,12 @@ The **minimum configuration** to get your application running under Nginx is:
127123
# }
128124
129125
location ~ ^/index\.php(/|$) {
126+
# when using PHP-FPM as a unix socket
130127
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
128+
129+
# when PHP-FPM is configured to use TCP
130+
fastcgi_pass 127.0.0.1:9000;
131+
131132
fastcgi_split_path_info ^(.+\.php)(/.*)$;
132133
include fastcgi_params;
133134
@@ -169,11 +170,6 @@ The **minimum configuration** to get your application running under Nginx is:
169170
If you use NGINX Unit, check out the official article about
170171
`How to run Symfony applications using NGINX Unit`_.
171172

172-
.. note::
173-
174-
Depending on your PHP-FPM config, the ``fastcgi_pass`` can also be
175-
``fastcgi_pass 127.0.0.1:9000``.
176-
177173
.. tip::
178174

179175
This executes **only** ``index.php`` in the public directory. All other files

0 commit comments

Comments
 (0)