|
1 | 1 | Setting up or Fixing File Permissions |
2 | 2 | ===================================== |
3 | 3 |
|
4 | | -The ``var/`` directory in a Symfony application is used to store generated |
5 | | -files (cache and logs) and file-based cache files. In the production |
6 | | -environment, you often need to add explicit permissions to let Symfony |
7 | | -write files into this directory. |
| 4 | +Symfony generates certain files in the ``var/`` directory of your project when |
| 5 | +running the application. In the ``dev`` :ref:`environment <configuration-environments>`, |
| 6 | +the ``bin/console`` and ``public/index.php`` files use ``umask()`` to make sure |
| 7 | +that the directory is writable. This means that you don't need to configure |
| 8 | +permissions when developing the application in your local machine. |
8 | 9 |
|
9 | | -.. tip:: |
| 10 | +However, using ``umask()`` is not considered safe in production. That's why you |
| 11 | +often need to configure some permissions explicitly in your production servers |
| 12 | +as explained in this article. |
10 | 13 |
|
11 | | - In dev environments, ``umask()`` is used in ``bin/console`` and |
12 | | - ``public/index.php`` to make sure the directory is writable. However, |
13 | | - this is not a safe method and should not be used in production. |
| 14 | +Permissions Required by Symfony Applications |
| 15 | +-------------------------------------------- |
14 | 16 |
|
15 | | -Setting up File Permissions in Production |
16 | | ------------------------------------------ |
17 | | - |
18 | | -This section describes the required permissions. See |
19 | | -:ref:`the next section <setup-file-permissions>` on how to add the |
20 | | -permissions. |
| 17 | +These are the permissions required to run Symfony applications: |
21 | 18 |
|
22 | 19 | * The ``var/log/`` directory must exist and must be writable by both your |
23 | 20 | web server user and the terminal user; |
24 | 21 | * The ``var/cache/`` directory must be writable by the terminal user (the |
25 | | - user running ``cache:warmup`` or ``cache:clear``). It must also be writable |
26 | | - by the web server user if you're using the |
27 | | - :doc:`filesystem cache provider </components/cache/adapters/filesystem_adapter>`; |
28 | | - or Doctrine query result cache. |
| 22 | + user running ``cache:warmup`` or ``cache:clear`` commands); |
| 23 | +* The ``var/cache/`` directory must be writable by the web server user if you use |
| 24 | + a :doc:`filesystem-based cache </components/cache/adapters/filesystem_adapter>`. |
29 | 25 |
|
30 | 26 | .. _setup-file-permissions: |
31 | 27 |
|
32 | | -Configuring File Permissions on Linux and macOS System |
33 | | ------------------------------------------------------- |
| 28 | +Configuring Permissions for Symfony Applications |
| 29 | +------------------------------------------------ |
34 | 30 |
|
35 | 31 | On Linux and macOS systems, if your web server user is different from your |
36 | 32 | command line user, you need to configure permissions properly to avoid issues. |
@@ -84,7 +80,7 @@ If none of the previous methods work for you, change the ``umask`` so that the |
84 | 80 | cache and log directories are group-writable or world-writable (depending |
85 | 81 | if the web server user and the command line user are in the same group or not). |
86 | 82 | To achieve this, put the following line at the beginning of the ``bin/console``, |
87 | | -``web/app.php`` and ``web/app_dev.php`` files:: |
| 83 | +and ``public/index.php`` files:: |
88 | 84 |
|
89 | 85 | umask(0002); // This will let the permissions be 0775 |
90 | 86 |
|
|
0 commit comments