Skip to content

Commit 98197e2

Browse files
ThomasLandauerjaviereguiluz
authored andcommitted
Update web_server_configuration.rst: Movin nginx above Apache
Page: https://symfony.com/doc/current/setup/web_server_configuration.html Reason: IMO nginx is more widely used nowadays.
1 parent bae7219 commit 98197e2

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

setup/web_server_configuration.rst

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -49,60 +49,6 @@ listen on. Each pool can also be run under a different UID and GID:
4949
; or listen on a TCP connection
5050
; listen = 127.0.0.1:9000
5151
52-
Apache
53-
------
54-
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:
60-
61-
.. code-block:: apache
62-
63-
# /etc/apache2/conf.d/example.com.conf
64-
<VirtualHost *:80>
65-
ServerName example.com
66-
ServerAlias www.example.com
67-
68-
# Uncomment the following line to force Apache to pass the Authorization
69-
# header to PHP: required for "basic_auth" under PHP-FPM and FastCGI
70-
#
71-
# SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
72-
73-
<FilesMatch \.php$>
74-
# when using PHP-FPM as a unix socket
75-
SetHandler proxy:unix:/var/run/php/php8.3-fpm.sock|fcgi://dummy
76-
77-
# when PHP-FPM is configured to use TCP
78-
# SetHandler proxy:fcgi://127.0.0.1:9000
79-
</FilesMatch>
80-
81-
DocumentRoot /var/www/project/public
82-
<Directory /var/www/project/public>
83-
AllowOverride None
84-
Require all granted
85-
FallbackResource /index.php
86-
</Directory>
87-
88-
# uncomment the following lines if you install assets as symlinks
89-
# or run into problems when compiling LESS/Sass/CoffeeScript assets
90-
# <Directory /var/www/project>
91-
# Options FollowSymlinks
92-
# </Directory>
93-
94-
ErrorLog /var/log/apache2/project_error.log
95-
CustomLog /var/log/apache2/project_access.log combined
96-
</VirtualHost>
97-
98-
.. note::
99-
100-
If you are doing some quick tests with Apache, you can also run
101-
``composer require symfony/apache-pack``. This package creates an ``.htaccess``
102-
file in the ``public/`` directory with the necessary rewrite rules needed to serve
103-
the Symfony application. However, in production, it's recommended to move these
104-
rules to the main Apache configuration file (as shown above) to improve performance.
105-
10652
Nginx
10753
-----
10854

@@ -190,6 +136,60 @@ The **minimum configuration** to get your application running under Nginx is:
190136

191137
For advanced Nginx configuration options, read the official `Nginx documentation`_.
192138

139+
Apache
140+
------
141+
142+
If you are running Apache 2.4+, you can use ``mod_proxy_fcgi`` to pass
143+
incoming requests to PHP-FPM. Install the Apache2 FastCGI mod
144+
(``libapache2-mod-fastcgi`` on Debian), enable ``mod_proxy`` and
145+
``mod_proxy_fcgi`` in your Apache configuration, and use the ``SetHandler``
146+
directive to pass requests for PHP files to PHP FPM:
147+
148+
.. code-block:: apache
149+
150+
# /etc/apache2/conf.d/example.com.conf
151+
<VirtualHost *:80>
152+
ServerName example.com
153+
ServerAlias www.example.com
154+
155+
# Uncomment the following line to force Apache to pass the Authorization
156+
# header to PHP: required for "basic_auth" under PHP-FPM and FastCGI
157+
#
158+
# SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
159+
160+
<FilesMatch \.php$>
161+
# when using PHP-FPM as a unix socket
162+
SetHandler proxy:unix:/var/run/php/php8.3-fpm.sock|fcgi://dummy
163+
164+
# when PHP-FPM is configured to use TCP
165+
# SetHandler proxy:fcgi://127.0.0.1:9000
166+
</FilesMatch>
167+
168+
DocumentRoot /var/www/project/public
169+
<Directory /var/www/project/public>
170+
AllowOverride None
171+
Require all granted
172+
FallbackResource /index.php
173+
</Directory>
174+
175+
# uncomment the following lines if you install assets as symlinks
176+
# or run into problems when compiling LESS/Sass/CoffeeScript assets
177+
# <Directory /var/www/project>
178+
# Options FollowSymlinks
179+
# </Directory>
180+
181+
ErrorLog /var/log/apache2/project_error.log
182+
CustomLog /var/log/apache2/project_access.log combined
183+
</VirtualHost>
184+
185+
.. note::
186+
187+
If you are doing some quick tests with Apache, you can also run
188+
``composer require symfony/apache-pack``. This package creates an ``.htaccess``
189+
file in the ``public/`` directory with the necessary rewrite rules needed to serve
190+
the Symfony application. However, in production, it's recommended to move these
191+
rules to the main Apache configuration file (as shown above) to improve performance.
192+
193193
Caddy
194194
-----
195195

0 commit comments

Comments
 (0)