Skip to content

Commit 705f9ed

Browse files
committed
Merge branch '6.2' into 6.3
* 6.2: Moving nginx above Apache (second attempt) [String] Minor tweak about the slugger and locales Add a tip about signing Symfony server binary on macOS
2 parents 2417b6f + 1ff389e commit 705f9ed

File tree

3 files changed

+104
-91
lines changed

3 files changed

+104
-91
lines changed

components/string.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,11 @@ The slugger transliterates the original string into the Latin script before
490490
applying the other transformations. The locale of the original string is
491491
detected automatically, but you can define it explicitly::
492492

493-
// this tells the slugger to transliterate from Korean language
493+
// this tells the slugger to transliterate from Korean ('ko') language
494494
$slugger = new AsciiSlugger('ko');
495495

496496
// you can override the locale as the third optional parameter of slug()
497+
// e.g. this slugger transliterates from Persian ('fa') language
497498
$slug = $slugger->slug('...', '-', 'fa');
498499

499500
In a Symfony application, you don't need to create the slugger yourself. Thanks

setup/symfony_server.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ run the Symfony server in the background:
5656
# show the latest log messages
5757
$ symfony server:log
5858
59+
.. tip::
60+
61+
On macOS, when starting the Symfony server you might see a warning dialog asking
62+
_"Do you want the application to accept incoming network connections?"_.
63+
This happens when running unsigned appplications that are not listed in the
64+
firewall list. The solution is to run this command that signs the Symfony binary:
65+
66+
.. code-block:: terminal
67+
68+
# change the path to the location of your Symfony binary
69+
$ sudo codesign --force --deep --sign - /opt/homebrew/Cellar/symfony-cli/5.4.21/bin/symfony
70+
5971
Enabling PHP-FPM
6072
----------------
6173

setup/web_server_configuration.rst

Lines changed: 90 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,98 @@ to use PHP :ref:`with Nginx <web-server-nginx>`.
3030
another location (e.g. ``public_html/``) make sure you
3131
:ref:`override the location of the public/ directory <override-web-dir>`.
3232

33+
.. _web-server-nginx:
34+
35+
Nginx
36+
-----
37+
38+
The **minimum configuration** to get your application running under Nginx is:
39+
40+
.. code-block:: nginx
41+
42+
server {
43+
server_name domain.tld www.domain.tld;
44+
root /var/www/project/public;
45+
46+
location / {
47+
# try to serve file directly, fallback to index.php
48+
try_files $uri /index.php$is_args$args;
49+
}
50+
51+
# optionally disable falling back to PHP script for the asset directories;
52+
# nginx will return a 404 error when files are not found instead of passing the
53+
# request to Symfony (improves performance but Symfony's 404 page is not displayed)
54+
# location /bundles {
55+
# try_files $uri =404;
56+
# }
57+
58+
location ~ ^/index\.php(/|$) {
59+
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
60+
fastcgi_split_path_info ^(.+\.php)(/.*)$;
61+
include fastcgi_params;
62+
63+
# optionally set the value of the environment variables used in the application
64+
# fastcgi_param APP_ENV prod;
65+
# fastcgi_param APP_SECRET <app-secret-id>;
66+
# fastcgi_param DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name";
67+
68+
# When you are using symlinks to link the document root to the
69+
# current version of your application, you should pass the real
70+
# application path instead of the path to the symlink to PHP
71+
# FPM.
72+
# Otherwise, PHP's OPcache may not properly detect changes to
73+
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
74+
# for more information).
75+
# Caveat: When PHP-FPM is hosted on a different machine from nginx
76+
# $realpath_root may not resolve as you expect! In this case try using
77+
# $document_root instead.
78+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
79+
fastcgi_param DOCUMENT_ROOT $realpath_root;
80+
# Prevents URIs that include the front controller. This will 404:
81+
# http://domain.tld/index.php/some-path
82+
# Remove the internal directive to allow URIs like this
83+
internal;
84+
}
85+
86+
# return 404 for all other php files not matching the front controller
87+
# this prevents access to other php files you don't want to be accessible.
88+
location ~ \.php$ {
89+
return 404;
90+
}
91+
92+
error_log /var/log/nginx/project_error.log;
93+
access_log /var/log/nginx/project_access.log;
94+
}
95+
96+
.. tip::
97+
98+
If you use NGINX Unit, check out the official article about
99+
`How to run Symfony applications using NGINX Unit`_.
100+
101+
.. note::
102+
103+
Depending on your PHP-FPM config, the ``fastcgi_pass`` can also be
104+
``fastcgi_pass 127.0.0.1:9000``.
105+
106+
.. tip::
107+
108+
This executes **only** ``index.php`` in the public directory. All other files
109+
ending in ".php" will be denied.
110+
111+
If you have other PHP files in your public directory that need to be executed,
112+
be sure to include them in the ``location`` block above.
113+
114+
.. caution::
115+
116+
After you deploy to production, make sure that you **cannot** access the ``index.php``
117+
script (i.e. ``http://example.com/index.php``).
118+
119+
For advanced Nginx configuration options, read the official `Nginx documentation`_.
120+
33121
.. _web-server-apache-mod-php:
34122

35-
Adding Rewrite Rules
36-
--------------------
123+
Adding Rewrite Rules for Apache
124+
-------------------------------
37125

38126
The easiest way is to install the ``apache`` :ref:`Symfony pack <symfony-packs>`
39127
by executing the following command:
@@ -292,94 +380,6 @@ instead:
292380
293381
FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php/php8.1-fpm.sock -pass-header Authorization
294382
295-
.. _web-server-nginx:
296-
297-
Nginx
298-
-----
299-
300-
The **minimum configuration** to get your application running under Nginx is:
301-
302-
.. code-block:: nginx
303-
304-
server {
305-
server_name domain.tld www.domain.tld;
306-
root /var/www/project/public;
307-
308-
location / {
309-
# try to serve file directly, fallback to index.php
310-
try_files $uri /index.php$is_args$args;
311-
}
312-
313-
# optionally disable falling back to PHP script for the asset directories;
314-
# nginx will return a 404 error when files are not found instead of passing the
315-
# request to Symfony (improves performance but Symfony's 404 page is not displayed)
316-
# location /bundles {
317-
# try_files $uri =404;
318-
# }
319-
320-
location ~ ^/index\.php(/|$) {
321-
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
322-
fastcgi_split_path_info ^(.+\.php)(/.*)$;
323-
include fastcgi_params;
324-
325-
# optionally set the value of the environment variables used in the application
326-
# fastcgi_param APP_ENV prod;
327-
# fastcgi_param APP_SECRET <app-secret-id>;
328-
# fastcgi_param DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name";
329-
330-
# When you are using symlinks to link the document root to the
331-
# current version of your application, you should pass the real
332-
# application path instead of the path to the symlink to PHP
333-
# FPM.
334-
# Otherwise, PHP's OPcache may not properly detect changes to
335-
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
336-
# for more information).
337-
# Caveat: When PHP-FPM is hosted on a different machine from nginx
338-
# $realpath_root may not resolve as you expect! In this case try using
339-
# $document_root instead.
340-
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
341-
fastcgi_param DOCUMENT_ROOT $realpath_root;
342-
# Prevents URIs that include the front controller. This will 404:
343-
# http://domain.tld/index.php/some-path
344-
# Remove the internal directive to allow URIs like this
345-
internal;
346-
}
347-
348-
# return 404 for all other php files not matching the front controller
349-
# this prevents access to other php files you don't want to be accessible.
350-
location ~ \.php$ {
351-
return 404;
352-
}
353-
354-
error_log /var/log/nginx/project_error.log;
355-
access_log /var/log/nginx/project_access.log;
356-
}
357-
358-
.. tip::
359-
360-
If you use NGINX Unit, check out the official article about
361-
`How to run Symfony applications using NGINX Unit`_.
362-
363-
.. note::
364-
365-
Depending on your PHP-FPM config, the ``fastcgi_pass`` can also be
366-
``fastcgi_pass 127.0.0.1:9000``.
367-
368-
.. tip::
369-
370-
This executes **only** ``index.php`` in the public directory. All other files
371-
ending in ".php" will be denied.
372-
373-
If you have other PHP files in your public directory that need to be executed,
374-
be sure to include them in the ``location`` block above.
375-
376-
.. caution::
377-
378-
After you deploy to production, make sure that you **cannot** access the ``index.php``
379-
script (i.e. ``http://example.com/index.php``).
380-
381-
For advanced Nginx configuration options, read the official `Nginx documentation`_.
382-
383383
.. _`Apache documentation`: https://httpd.apache.org/docs/
384384
.. _`FastCgiExternalServer`: https://docs.oracle.com/cd/B31017_01/web.1013/q20204/mod_fastcgi.html#FastCgiExternalServer
385385
.. _`Nginx documentation`: https://www.nginx.com/resources/wiki/start/topics/recipes/symfony/

0 commit comments

Comments
 (0)