Skip to content

Commit a10d717

Browse files
committed
Clean-up Apache and Nginx parts
1 parent 035af33 commit a10d717

File tree

1 file changed

+31
-35
lines changed

1 file changed

+31
-35
lines changed

setup/web_server_configuration.rst

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

25-
Apache with PHP-FPM
25+
Configuring PHP-FPM
2626
-------------------
2727

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

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

3837
.. code-block:: ini
3938
39+
; /etc/php/7.4/fpm/pool.d/www.conf
40+
4041
; a pool called www
4142
[www]
4243
user = www-data
@@ -45,43 +46,37 @@ listen on. Each pool can also be run under a different UID and GID:
4546
; use a unix domain socket
4647
listen = /var/run/php/php7.4-fpm.sock
4748
48-
; or listen on a TCP socket
49-
listen = 127.0.0.1:9000
49+
; or listen on a TCP connection
50+
; listen = 127.0.0.1:9000
5051
51-
Using mod_proxy_fcgi with Apache 2.4
52-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52+
Apache
53+
------
5354

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

5961
.. code-block:: apache
6062
63+
# /etc/apache2/conf.d/example.com.conf
6164
<VirtualHost *:80>
62-
ServerName domain.tld
63-
ServerAlias www.domain.tld
65+
ServerName example.com
66+
ServerAlias www.example.com
6467
6568
# Uncomment the following line to force Apache to pass the Authorization
6669
# header to PHP: required for "basic_auth" under PHP-FPM and FastCGI
6770
#
6871
# SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
6972
70-
# For Apache 2.4.9 or higher
71-
# Using SetHandler avoids issues with using ProxyPassMatch in combination
72-
# with mod_rewrite or mod_autoindex
7373
<FilesMatch \.php$>
74-
SetHandler proxy:fcgi://127.0.0.1:9000
75-
# for Unix sockets, Apache 2.4.10 or higher
76-
# SetHandler proxy:unix:/path/to/fpm.sock|fcgi://dummy
77-
</FilesMatch>
74+
# when using PHP-FPM as a unix socket
75+
SetHandler proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://dummy
7876
79-
# If you use Apache version below 2.4.9 you must consider update or use this instead
80-
# ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/public/$1
81-
82-
# If you run your Symfony application on a subpath of your document root, the
83-
# regular expression must be changed accordingly:
84-
# ProxyPassMatch ^/path-to-app/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/public/$1
77+
# when PHP-FPM is configured to use TCP
78+
# SetHandler proxy:fcgi://127.0.0.1:9000
79+
</FilesMatch>
8580
8681
DocumentRoot /var/www/project/public
8782
<Directory /var/www/project/public>
@@ -107,8 +102,9 @@ The **minimum configuration** to get your application running under Nginx is:
107102

108103
.. code-block:: nginx
109104
105+
# /etc/nginx/conf.d/example.com.conf
110106
server {
111-
server_name domain.tld www.domain.tld;
107+
server_name example.com www.example.com;
112108
root /var/www/project/public;
113109
114110
location / {
@@ -124,7 +120,12 @@ The **minimum configuration** to get your application running under Nginx is:
124120
# }
125121
126122
location ~ ^/index\.php(/|$) {
123+
# when using PHP-FPM as a unix socket
127124
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
125+
126+
# when PHP-FPM is configured to use TCP
127+
# fastcgi_pass 127.0.0.1:9000;
128+
128129
fastcgi_split_path_info ^(.+\.php)(/.*)$;
129130
include fastcgi_params;
130131
@@ -146,7 +147,7 @@ The **minimum configuration** to get your application running under Nginx is:
146147
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
147148
fastcgi_param DOCUMENT_ROOT $realpath_root;
148149
# Prevents URIs that include the front controller. This will 404:
149-
# http://domain.tld/index.php/some-path
150+
# http://example.com/index.php/some-path
150151
# Remove the internal directive to allow URIs like this
151152
internal;
152153
}
@@ -166,11 +167,6 @@ The **minimum configuration** to get your application running under Nginx is:
166167
If you use NGINX Unit, check out the official article about
167168
`How to run Symfony applications using NGINX Unit`_.
168169

169-
.. note::
170-
171-
Depending on your PHP-FPM config, the ``fastcgi_pass`` can also be
172-
``fastcgi_pass 127.0.0.1:9000``.
173-
174170
.. tip::
175171

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

0 commit comments

Comments
 (0)