Skip to content

Commit d46e96c

Browse files
tvlooyweaverryan
authored andcommitted
example webserver configs
1 parent e843754 commit d46e96c

File tree

4 files changed

+95
-2
lines changed

4 files changed

+95
-2
lines changed

book/installation.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,10 @@ Symfony2 should welcome and congratulate you for your hard work so far!
195195
this is not required for development it is recommended at the time your
196196
application goes into production as all system and configuration files
197197
become inaccessible to clients then. For information on configuring
198-
your specific web server document root, see the following
199-
documentation: `Apache`_ | `Nginx`_ .
198+
your specific web server document root, read
199+
:doc:`/cookbook/configuration/web_server_configuration`
200+
or consult the official documentation of your webserver:
201+
`Apache`_ | `Nginx`_ .
200202

201203
Beginning Development
202204
---------------------

book/page_creation.rst

+2
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ the same basic and recommended directory structure:
439439

440440
* ``web/``: This is the web root directory and contains any publicly accessible files;
441441

442+
.. _the-web-directory:
443+
442444
The Web Directory
443445
~~~~~~~~~~~~~~~~~
444446

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
.. index::
2+
single: Web Server
3+
4+
Configuring a web server
5+
========================
6+
7+
The web directory is the home of all of your application's public and static
8+
files. Including images, stylesheets and JavaScript files. It is also where the
9+
front controllers live. For more details, see the chapter about
10+
:ref:`the-web-directory`.
11+
12+
The web directory is the one that you will need to configure in your webserver
13+
as the documentroot. In the examples below, this directory is in
14+
``/var/www/project/web/``.
15+
16+
Apache2
17+
-------
18+
19+
For advanced Apache configuration options, see the official `Apache`_
20+
documentation. The minimum basics to get your application running under Apache2
21+
are:
22+
23+
.. code-block:: Apache2
24+
25+
<VirtualHost *:80>
26+
ServerName www.domain.tld
27+
28+
DocumentRoot /var/www/project/web
29+
<Directory /var/www/project/web>
30+
# enable the .htaccess rewrites
31+
AllowOverride All
32+
Order allow,deny
33+
Allow from All
34+
</Directory>
35+
36+
ErrorLog /var/log/apache2/project_error.log
37+
CustomLog /var/log/apache2/project_access.log combined
38+
</VirtualHost>
39+
40+
.. note::
41+
42+
For performance reasons, you will probably want to set
43+
``AllowOverride None`` and implement your ``.htaccess`` into the
44+
vhost config.
45+
46+
Nginx
47+
-----
48+
49+
For advanced Nginx configuration options, see the official `Nginx`_
50+
documentation. The minimum basics to get your application running under Nginx
51+
are:
52+
53+
.. code-block:: nginx
54+
55+
server {
56+
server_name www.domain.tld;
57+
root /var/www/project/web;
58+
59+
location / {
60+
# try to serve file directly, fallback to rewrite
61+
try_files $uri @rewriteapp;
62+
}
63+
64+
location @rewriteapp {
65+
# rewrite all to app.php
66+
rewrite ^(.*)$ /app.php/$1 last;
67+
}
68+
69+
location ~ ^/(config|app|app_dev)\.php(/|$) {
70+
fastcgi_pass unix:/var/run/php5-fpm.sock;
71+
fastcgi_split_path_info ^(.+\.php)(/.*)$;
72+
include fastcgi_params;
73+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
74+
fastcgi_param HTTPS off;
75+
}
76+
77+
error_log /var/log/nginx/project_error.log;
78+
access_log /var/log/nginx/project_access.log;
79+
}
80+
81+
.. note::
82+
83+
Depending on your PHP-FPM config, the ``fastcgi_pass`` can also be
84+
``fastcgi_pass 127.0.0.1:9000``.
85+
86+
.. _`Apache`: http://httpd.apache.org/docs/current/mod/core.html#documentroot
87+
.. _`Nginx`: http://wiki.nginx.org/Symfony
88+

cookbook/map.rst.inc

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* :doc:`/cookbook/configuration/external_parameters`
2525
* :doc:`/cookbook/configuration/pdo_session_storage`
2626
* :doc:`/cookbook/configuration/apache_router`
27+
* :doc:`/cookbook/configuration/web_server_configuration`
2728

2829
* :doc:`/cookbook/console/index`
2930

0 commit comments

Comments
 (0)