@@ -25,13 +25,12 @@ with Apache or Nginx.
25
25
another location (e.g. ``public_html/ ``) make sure you
26
26
:ref: `override the location of the public/ directory <override-web-dir >`.
27
27
28
- Apache with PHP-FPM
28
+ Configuring PHP-FPM
29
29
-------------------
30
30
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).
35
34
36
35
PHP-FPM uses so-called *pools * to handle incoming FastCGI requests. You can
37
36
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:
40
39
41
40
.. code-block :: ini
42
41
42
+ ; /etc/php/7.4/fpm/pool.d/www.conf
43
+
43
44
; a pool called www
44
45
[www]
45
46
user = www-data
@@ -48,19 +49,21 @@ listen on. Each pool can also be run under a different UID and GID:
48
49
; use a unix domain socket
49
50
listen = /var/run/php/php7.4-fpm.sock
50
51
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
53
54
54
- Using mod_proxy_fcgi with Apache 2.4
55
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55
+ Apache
56
+ ------
56
57
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:
61
63
62
64
.. code-block :: apache
63
65
66
+ # /etc/apache2/conf.d/domain.tld.conf
64
67
<VirtualHost *:80>
65
68
ServerName domain.tld
66
69
ServerAlias www.domain.tld
@@ -70,21 +73,13 @@ requests to PHP-FPM. Configure PHP-FPM to listen on a TCP or Unix socket, enable
70
73
#
71
74
# SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
72
75
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
76
76
<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
81
79
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>
88
83
89
84
DocumentRoot /var/www/project/public
90
85
<Directory /var/www/project/public>
@@ -110,6 +105,7 @@ The **minimum configuration** to get your application running under Nginx is:
110
105
111
106
.. code-block :: nginx
112
107
108
+ # /etc/nginx/conf.d/domain.tld.conf
113
109
server {
114
110
server_name domain.tld www.domain.tld;
115
111
root /var/www/project/public;
@@ -127,7 +123,12 @@ The **minimum configuration** to get your application running under Nginx is:
127
123
# }
128
124
129
125
location ~ ^/index\.php(/|$) {
126
+ # when using PHP-FPM as a unix socket
130
127
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
+
131
132
fastcgi_split_path_info ^(.+\.php)(/.*)$;
132
133
include fastcgi_params;
133
134
@@ -169,11 +170,6 @@ The **minimum configuration** to get your application running under Nginx is:
169
170
If you use NGINX Unit, check out the official article about
170
171
`How to run Symfony applications using NGINX Unit `_.
171
172
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
-
177
173
.. tip ::
178
174
179
175
This executes **only ** ``index.php `` in the public directory. All other files
0 commit comments