Skip to content

Commit 46bc2bb

Browse files
committed
Shortening the setup section
1 parent 7b04ffd commit 46bc2bb

File tree

2 files changed

+118
-125
lines changed

2 files changed

+118
-125
lines changed

setup.rst

+37-125
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ the most common issues that may appear during the installation process.
1010
Creating Symfony Applications
1111
-----------------------------
1212

13-
Symfony provides a dedicated application called **Symfony Installer** to ease
13+
Symfony provides a dedicated application called the **Symfony Installer** to ease
1414
the creation of Symfony applications. This installer is a PHP 5.4 compatible
15-
application that has to be installed in your system only once:
15+
executable that needs to be installed on your system only once:
1616

1717
.. code-block:: bash
1818
@@ -26,7 +26,7 @@ application that has to be installed in your system only once:
2626
.. note::
2727

2828
In Linux and macOS, a global ``symfony`` command is created. In Windows,
29-
move the ``symfony`` file to some directory included in the ``PATH``
29+
move the ``symfony`` file to a directory that's included in the ``PATH``
3030
environment variable to create the global command or move it to any other
3131
directory convenient for you:
3232

@@ -126,7 +126,7 @@ Running the Symfony Application
126126

127127
Symfony leverages the internal PHP web server (available since PHP 5.4) to run
128128
applications while developing them. Therefore, running a Symfony application is
129-
a matter of browsing the project directory and executing this command:
129+
a matter of browsing to the project directory and executing this command:
130130

131131
.. code-block:: bash
132132
@@ -142,8 +142,7 @@ Welcome Page of Symfony:
142142

143143
If you see a blank page or an error page instead of the Welcome Page, there is
144144
a directory permission misconfiguration. The solution to this problem is
145-
explained in the :ref:`Setting up Permissions <book-installation-permissions>`
146-
section.
145+
explained in the :doc:`/setup/file_permissions`.
147146

148147
When you are finished working on your Symfony application, stop the server by
149148
pressing ``Ctrl+C`` from the terminal or command console.
@@ -169,95 +168,20 @@ before moving on:
169168
170169
.. _book-installation-permissions:
171170

172-
Setting up Permissions
173-
----------------------
171+
Fixing Permissions Problems
172+
---------------------------
174173

175-
One important Symfony requirement is that the ``app/cache`` and ``app/logs``
176-
directories must be writable both by the web server and the command line user.
177-
178-
On Linux and macOS systems, if your web server user is different from your
179-
command line user, you need to configure permissions properly to avoid issues.
180-
There are several ways to achieve that:
181-
182-
1. Use the same user for the CLI and the web server
183-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
184-
185-
Edit your web server configuration (commonly ``httpd.conf`` or ``apache2.conf``
186-
for Apache) and set its user to be the same as your CLI user (e.g. for Apache,
187-
update the ``User`` and ``Group`` directives).
188-
189-
.. caution::
190-
191-
If this solution is used in a production server, be sure this user only has
192-
limited privileges (no access to private data or servers, execution of
193-
unsafe binaries, etc.) as a compromised server would give to the hacker
194-
those privileges.
195-
196-
2. Using ACL on a system that supports ``chmod +a`` (macOS)
197-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
198-
199-
On macOS systems, the ``chmod`` command supports the ``+a`` flag to define an
200-
ACL. Use the following script to determine your web server user and grant the
201-
needed permissions:
202-
203-
.. code-block:: bash
204-
205-
$ rm -rf app/cache/*
206-
$ rm -rf app/logs/*
207-
208-
$ HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
209-
$ sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
210-
$ sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
211-
212-
3. Using ACL on a system that supports ``setfacl`` (Linux/BSD)
213-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
214-
215-
Most Linux and BSD distributions don't support ``chmod +a``, but do support
216-
another utility called ``setfacl``. You may need to install ``setfacl`` and
217-
`enable ACL support`_ on your disk partition before using it. Then, use the
218-
following script to determine your web server user and grant the needed permissions:
219-
220-
.. code-block:: bash
221-
222-
$ HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
223-
# if this doesn't work, try adding `-n` option
224-
$ sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
225-
$ sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
226-
227-
.. note::
228-
229-
setfacl isn't available on NFS mount points. However, storing cache and logs
230-
over NFS is strongly discouraged for performance reasons.
231-
232-
4. Without using ACL
233-
~~~~~~~~~~~~~~~~~~~~
234-
235-
If none of the previous methods work for you, change the umask so that the
236-
cache and log directories are group-writable or world-writable (depending
237-
if the web server user and the command line user are in the same group or not).
238-
To achieve this, put the following line at the beginning of the ``app/console``,
239-
``web/app.php`` and ``web/app_dev.php`` files::
240-
241-
umask(0002); // This will let the permissions be 0775
242-
243-
// or
244-
245-
umask(0000); // This will let the permissions be 0777
246-
247-
.. note::
248-
249-
Changing the umask is not thread-safe, so the ACL methods are recommended
250-
when they are available.
174+
If you have any file permission errors or see a white screen, then read
175+
:doc:`/setup/file_permissions` for more information.
251176

252177
.. _installation-updating-vendors:
253178

254179
Updating Symfony Applications
255180
-----------------------------
256181

257-
At this point, you've created a fully-functional Symfony application in which
258-
you'll start to develop your own project. A Symfony application depends on
259-
a number of third-party libraries stored in the ``vendor/`` directory and
260-
managed by Composer.
182+
At this point, you've created a fully-functional Symfony application! Every Symfony
183+
app depends on a number of third-party libraries stored in the ``vendor/`` directory
184+
and managed by Composer.
261185

262186
Updating those libraries frequently is a good practice to prevent bugs and
263187
security vulnerabilities. Execute the ``update`` Composer command to update them
@@ -281,46 +205,30 @@ complexity of your project):
281205
A good security practice is to execute this command regularly to be able to
282206
update or replace compromised dependencies as soon as possible.
283207

284-
Installing the Symfony Demo Application
285-
---------------------------------------
286-
287-
The `Symfony Demo application`_ is a fully-functional application that shows the
288-
recommended way to develop Symfony applications. The application has been
289-
conceived as a learning tool for Symfony newcomers and its source code contains
290-
tons of comments and helpful notes.
291-
292-
If you have installed the Symfony Installer as explained in the above sections,
293-
install the Symfony Demo application anywhere in your system executing the
294-
``demo`` command:
295-
296-
.. code-block:: bash
297-
298-
$ symfony demo
208+
.. _installing-a-symfony2-distribution:
299209

300-
Once downloaded, enter into the ``symfony_demo/`` directory, run the PHP's
301-
built-in web server (``php app/console server:run``) and access to the
302-
``http://localhost:8000`` URL to start using the Symfony Demo application.
210+
Installing the Symfony Demo or Other Distributions
211+
--------------------------------------------------
303212

304-
.. _installing-a-symfony2-distribution:
213+
You've already downloaded the Symfony Standard Edition: the default starting project
214+
for all Symfony apps. You'll use this project throughout the documentation to build
215+
your app!
305216

306-
Installing a Symfony Distribution
307-
---------------------------------
217+
Symfony also provides some other projects and starting skeletons that you can use:
308218

309-
Symfony distributions are fully-functional applications that include the Symfony
310-
core libraries, a selection of useful bundles, a sensible directory structure
311-
and some default configuration. In fact, when you created a Symfony application
312-
in the previous sections, you actually downloaded the default distribution
313-
provided by Symfony, which is called `Symfony Standard Edition`_.
219+
`The Symfony Demo Application`_
220+
This is a fully-functional application that shows the recommended way to develop
221+
Symfony applications. The app has been conceived as a learning tool for Symfony
222+
newcomers and its source code contains tons of comments and helpful notes.
314223

315-
The Symfony Standard Edition is the best choice for developers starting with
316-
Symfony. However, the Symfony Community has published other distributions that
317-
you may use in your applications:
224+
`The Symfony CMF Standard Edition`_
225+
The `Symfony CMF`_ is a project that helps make it easier for developers to add
226+
CMS functionality to their Symfony applications. This is a starting project
227+
containing the Symfony CMF.
318228

319-
* The `Symfony CMF Standard Edition`_ to get started with the `Symfony CMF`_
320-
project, which is a project that makes it easier for developers to add CMS
321-
functionality to Symfony applications.
322-
* The `Symfony REST Edition`_ shows how to build an application that provides a
323-
RESTful API using the `FOSRestBundle`_ and several other related bundles.
229+
`Symfony REST Edition`_
230+
Shows how to build an application that provides a RESTful API using the
231+
`FOSRestBundle`_ and several other related Bundles.
324232

325233
.. _install-existing-app:
326234

@@ -348,23 +256,27 @@ the following when installing an existing Symfony application:
348256
# now Composer will ask you for the values of any undefined parameter
349257
$ ...
350258
259+
Keep Going!
260+
-----------
261+
262+
With setup behind you, it's time to :doc:`Create your First Page in Symfony </page_creation>`.
263+
351264
Learn More
352265
----------
353266

354267
.. toctree::
355268
:maxdepth: 1
356269
:glob:
357270

358-
install/*
359271
setup/*
272+
install/*
360273

361274
.. _`Composer`: https://getcomposer.org/
362-
.. _`enable ACL support`: https://help.ubuntu.com/community/FilePermissionsACLs
363275
.. _`Symfony Standard Edition`: https://github.com/symfony/symfony-standard
364276
.. _`Symfony CMF Standard Edition`: https://github.com/symfony-cmf/symfony-cmf-standard
365277
.. _`Symfony CMF`: http://cmf.symfony.com/
366278
.. _`Symfony REST Edition`: https://github.com/gimler/symfony-rest-edition
367279
.. _`FOSRestBundle`: https://github.com/FriendsOfSymfony/FOSRestBundle
368280
.. _`Git`: http://git-scm.com/
369281
.. _`Phar extension`: http://php.net/manual/en/intro.phar.php
370-
.. _`Symfony Demo application`: https://github.com/symfony/symfony-demo
282+
.. _`The Symfony Demo application`: https://github.com/symfony/symfony-demo

setup/file_permissions.rst

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
Setting up or Fixing File Permissions
2+
=====================================
3+
4+
One important Symfony requirement is that the ``app/cache`` and ``app/logs``
5+
directories must be writable both by the web server and the command line user.
6+
7+
On Linux and macOS systems, if your web server user is different from your
8+
command line user, you need to configure permissions properly to avoid issues.
9+
There are several ways to achieve that:
10+
11+
1. Use the same user for the CLI and the web server
12+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13+
14+
Edit your web server configuration (commonly ``httpd.conf`` or ``apache2.conf``
15+
for Apache) and set its user to be the same as your CLI user (e.g. for Apache,
16+
update the ``User`` and ``Group`` directives).
17+
18+
.. caution::
19+
20+
If this solution is used in a production server, be sure this user only has
21+
limited privileges (no access to private data or servers, execution of
22+
unsafe binaries, etc.) as a compromised server would give to the hacker
23+
those privileges.
24+
25+
2. Using ACL on a system that supports ``chmod +a`` (macOS)
26+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27+
28+
On macOS systems, the ``chmod`` command supports the ``+a`` flag to define an
29+
ACL. Use the following script to determine your web server user and grant the
30+
needed permissions:
31+
32+
.. code-block:: bash
33+
34+
$ rm -rf app/cache/*
35+
$ rm -rf app/logs/*
36+
37+
$ HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
38+
$ sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
39+
$ sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
40+
41+
3. Using ACL on a system that supports ``setfacl`` (Linux/BSD)
42+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43+
44+
Most Linux and BSD distributions don't support ``chmod +a``, but do support
45+
another utility called ``setfacl``. You may need to install ``setfacl`` and
46+
`enable ACL support`_ on your disk partition before using it. Then, use the
47+
following script to determine your web server user and grant the needed permissions:
48+
49+
.. code-block:: bash
50+
51+
$ HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
52+
# if this doesn't work, try adding `-n` option
53+
$ sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
54+
$ sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
55+
56+
.. note::
57+
58+
setfacl isn't available on NFS mount points. However, storing cache and logs
59+
over NFS is strongly discouraged for performance reasons.
60+
61+
4. Without using ACL
62+
~~~~~~~~~~~~~~~~~~~~
63+
64+
If none of the previous methods work for you, change the umask so that the
65+
cache and log directories are group-writable or world-writable (depending
66+
if the web server user and the command line user are in the same group or not).
67+
To achieve this, put the following line at the beginning of the ``app/console``,
68+
``web/app.php`` and ``web/app_dev.php`` files::
69+
70+
umask(0002); // This will let the permissions be 0775
71+
72+
// or
73+
74+
umask(0000); // This will let the permissions be 0777
75+
76+
.. note::
77+
78+
Changing the umask is not thread-safe, so the ACL methods are recommended
79+
when they are available.
80+
81+
.. _`enable ACL support`: https://help.ubuntu.com/community/FilePermissionsACLs

0 commit comments

Comments
 (0)