Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add example server configuration #2410

Closed
wants to merge 2 commits into from

3 participants

@tvlooy
Q A
Doc fix? no
New docs? yes
Applies to all
Fixed tickets #578 #1705
book/installation.rst
@@ -291,8 +291,9 @@ Symfony2 should welcome and congratulate you for your hard work so far!
this is not required for development it is recommended at the time your
application goes into production as all system and configuration files
become inaccessible to clients then. For information on configuring
- your specific web server document root, see the following
- documentation: `Apache`_ | `Nginx`_ .
+ your specific web server document root, read :doc:`configuring a web server
+ </cookbook/configuration/web_server_configuration>` or consult the official
@WouterJ Collaborator
WouterJ added a note

I prefer to add the rules on one line (that means you need to break the previous line before :doc:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
cookbook/configuration/web_server_configuration.rst
@@ -0,0 +1,78 @@
+.. index::
+ single: Web Server
+
+Configuring a web server
+========================
+
+The web directory is the home of all of your application's public and static
+files. Including images, stylesheets, and JavaScript files. It is also where the
@WouterJ Collaborator
WouterJ added a note

stylesheets and JavaScript files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
cookbook/configuration/web_server_configuration.rst
((20 lines not shown))
+
+.. code-block:: Apache2
+
+ <VirtualHost *:80>
+ ServerName www.domain.tld
+
+ DocumentRoot /var/www/project/web
+ <Directory /var/www/ReadingCorner/web>
+ AllowOverride All
+ Order allow,deny
+ Allow from All
+ </Directory>
+
+ ErrorLog /var/log/apache2/project_error.log
+ CustomLog /var/log/apache2/project_access.log combined
+ </VirtualHost>
@WouterJ Collaborator
WouterJ added a note

The code should get indented by 4 spaces

@tvlooy
tvlooy added a note

Ugh! Those are tabs. I hate tabs! ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
book/installation.rst
@@ -291,8 +291,10 @@ Symfony2 should welcome and congratulate you for your hard work so far!
this is not required for development it is recommended at the time your
application goes into production as all system and configuration files
become inaccessible to clients then. For information on configuring
- your specific web server document root, see the following
- documentation: `Apache`_ | `Nginx`_ .
+ your specific web server document root, read
+ :doc:`configuring a web server </cookbook/configuration/web_server_configuration>`
@weaverryan Collaborator

You can actually leave the "configuring a web server part out - if you do this, it will default to using the title from that document:

:doc:`/cookbook/configuration/web_server_configuration`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@weaverryan weaverryan commented on the diff
cookbook/configuration/web_server_configuration.rst
@@ -0,0 +1,78 @@
+.. index::
+ single: Web Server
+
+Configuring a web server
+========================
+
+The web directory is the home of all of your application's public and static
+files. Including images, stylesheets and JavaScript files. It is also where the
+front controllers live. For more details, see the chapter about
+:ref:`the-web-directory`.
@weaverryan Collaborator

I'm not sure this reference exists anywhere - where should it point to?

@tvlooy
tvlooy added a note

it should link to the book/installation.rst line 295 (the one you commented on above)

@WouterJ Collaborator
WouterJ added a note

@tvlooy then you should add:

.. _the-web-directory:

Above that note, otherwise Sphinx can't find the reference.

I prefer to make the reference somewhat more discribable and because the pointer is not before a heading, you need to include a link name:

:ref:`the web directory <setting-document-root>`
@tvlooy
tvlooy added a note

Oh, my bad. It should link to this instead http://symfony.com/doc/current/book/page_creation.html#the-web-directory I could have sworn that reference was there though. I'll add it.

@WouterJ Collaborator
WouterJ added a note

@tvlooy there is no reference pointer to that section aswell.

When you do something like:

:ref:`the-web-directory`

Sphinx will look at the current page to find a section name which matches that name, then it will look at the hole documentation to find a reference pointer:

.. _the-web-directory:

If he find one, that will become the link.

If this pointer is above a section title, it will take that title as the link name at default. Otherwise, you need to set a link name.

.. _the-web-directory:

The Web Directory
-----------------
@tvlooy
tvlooy added a note

yep, think I get it now. I added it in my last commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
cookbook/configuration/web_server_configuration.rst
((31 lines not shown))
+ </Directory>
+
+ ErrorLog /var/log/apache2/project_error.log
+ CustomLog /var/log/apache2/project_access.log combined
+ </VirtualHost>
+
+.. note::
+
+ For performance reasons, you will probably want to set
+ ``AllowOverride None`` and implement your ``.htaccess`` into the
+ vhost config.
+
+Nginx
+-----
+
+The minimum basics to get your application running under Nginx are:
@weaverryan Collaborator

Perhaps we should also add a reference to http://wiki.nginx.org/Symfony?

It would also be awesome to add a few comments inline below about what some of the different pieces do.

I really like how short and "to the point" this server block is though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@weaverryan weaverryan commented on the diff
cookbook/configuration/index.rst
@@ -9,3 +9,4 @@ Configuration
external_parameters
pdo_session_storage
apache_router
+ web_server_configuration
@weaverryan Collaborator

Whenever you have a new entry, there's also a second spot where you need to add a reference - which is the "map" file. Check out map.rst.inc in the cookbook/ directory and you'll see where you need to add the entry there. Most people miss this, and I usually take care of it for them, but since you've been having nice success with the docs, I thought I'd make you do it the right way ;)

thx

@tvlooy
tvlooy added a note

okay, thanks. I added this now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
tvlooy added some commits
@tvlooy tvlooy [WIP] Add example server configuration
| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes
| Applies to    | all
| Fixed tickets | #578 #1705
292bafa
@tvlooy tvlooy example webserver configs 378ffc1
@weaverryan
Collaborator

Hi Tom!

Thanks for making these changes - this is a very nice entry! I've patched it into the 2.0 branch at sha: e843754 and sha: d46e96c with only minor tweaks.

Thanks!

@weaverryan weaverryan closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 4, 2013
  1. @tvlooy

    [WIP] Add example server configuration

    tvlooy authored
    | Q             | A
    | ------------- | ---
    | Doc fix?      | no
    | New docs?     | yes
    | Applies to    | all
    | Fixed tickets | #578 #1705
  2. @tvlooy

    example webserver configs

    tvlooy authored
This page is out of date. Refresh to see the latest.
View
6 book/installation.rst
@@ -294,8 +294,10 @@ Symfony2 should welcome and congratulate you for your hard work so far!
this is not required for development it is recommended at the time your
application goes into production as all system and configuration files
become inaccessible to clients then. For information on configuring
- your specific web server document root, see the following
- documentation: `Apache`_ | `Nginx`_ .
+ your specific web server document root, read
+ :doc:`/cookbook/configuration/web_server_configuration`
+ or consult the official documentation of your webserver:
+ `Apache`_ | `Nginx`_ .
Beginning Development
---------------------
View
2  book/page_creation.rst
@@ -439,6 +439,8 @@ the same basic and recommended directory structure:
* ``web/``: This is the web root directory and contains any publicly accessible files;
+.. _the-web-directory:
+
The Web Directory
~~~~~~~~~~~~~~~~~
View
1  cookbook/configuration/index.rst
@@ -9,3 +9,4 @@ Configuration
external_parameters
pdo_session_storage
apache_router
+ web_server_configuration
@weaverryan Collaborator

Whenever you have a new entry, there's also a second spot where you need to add a reference - which is the "map" file. Check out map.rst.inc in the cookbook/ directory and you'll see where you need to add the entry there. Most people miss this, and I usually take care of it for them, but since you've been having nice success with the docs, I thought I'd make you do it the right way ;)

thx

@tvlooy
tvlooy added a note

okay, thanks. I added this now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
88 cookbook/configuration/web_server_configuration.rst
@@ -0,0 +1,88 @@
+.. index::
+ single: Web Server
+
+Configuring a web server
+========================
+
+The web directory is the home of all of your application's public and static
+files. Including images, stylesheets and JavaScript files. It is also where the
+front controllers live. For more details, see the chapter about
+:ref:`the-web-directory`.
@weaverryan Collaborator

I'm not sure this reference exists anywhere - where should it point to?

@tvlooy
tvlooy added a note

it should link to the book/installation.rst line 295 (the one you commented on above)

@WouterJ Collaborator
WouterJ added a note

@tvlooy then you should add:

.. _the-web-directory:

Above that note, otherwise Sphinx can't find the reference.

I prefer to make the reference somewhat more discribable and because the pointer is not before a heading, you need to include a link name:

:ref:`the web directory <setting-document-root>`
@tvlooy
tvlooy added a note

Oh, my bad. It should link to this instead http://symfony.com/doc/current/book/page_creation.html#the-web-directory I could have sworn that reference was there though. I'll add it.

@WouterJ Collaborator
WouterJ added a note

@tvlooy there is no reference pointer to that section aswell.

When you do something like:

:ref:`the-web-directory`

Sphinx will look at the current page to find a section name which matches that name, then it will look at the hole documentation to find a reference pointer:

.. _the-web-directory:

If he find one, that will become the link.

If this pointer is above a section title, it will take that title as the link name at default. Otherwise, you need to set a link name.

.. _the-web-directory:

The Web Directory
-----------------
@tvlooy
tvlooy added a note

yep, think I get it now. I added it in my last commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+The web directory is the one that you will need to configure in your webserver
+as the documentroot. In the examples below, this directory is in
+``/var/www/project/web/``.
+
+Apache2
+-------
+
+For advanced Apache configuration options, see the official `Apache`_
+documentation. The minimum basics to get your application running under Apache2
+are:
+
+.. code-block:: Apache2
+
+ <VirtualHost *:80>
+ ServerName www.domain.tld
+
+ DocumentRoot /var/www/project/web
+ <Directory /var/www/project/web>
+ # enable the .htaccess rewrites
+ AllowOverride All
+ Order allow,deny
+ Allow from All
+ </Directory>
+
+ ErrorLog /var/log/apache2/project_error.log
+ CustomLog /var/log/apache2/project_access.log combined
+ </VirtualHost>
+
+.. note::
+
+ For performance reasons, you will probably want to set
+ ``AllowOverride None`` and implement your ``.htaccess`` into the
+ vhost config.
+
+Nginx
+-----
+
+For advanced Nginx configuration options, see the official `Nginx`_
+documentation. The minimum basics to get your application running under Nginx
+are:
+
+.. code-block:: nginx
+
+ server {
+ server_name www.domain.tld;
+ root /var/www/project/web;
+
+ location / {
+ # try to serve file directly, fallback to rewrite
+ try_files $uri @rewriteapp;
+ }
+
+ location @rewriteapp {
+ # rewrite all to app.php
+ rewrite ^(.*)$ /app.php/$1 last;
+ }
+
+ location ~ ^/(config|app|app_dev)\.php(/|$) {
+ fastcgi_pass unix:/var/run/php5-fpm.sock;
+ fastcgi_split_path_info ^(.+\.php)(/.*)$;
+ include fastcgi_params;
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+ fastcgi_param HTTPS off;
+ }
+
+ error_log /var/log/nginx/project_error.log;
+ access_log /var/log/nginx/project_access.log;
+ }
+
+.. note::
+
+ Depending on your PHP-FPM config, the ``fastcgi_pass`` can also be
+ ``fastcgi_pass 127.0.0.1:9000``.
+
+.. _`Apache`: http://httpd.apache.org/docs/current/mod/core.html#documentroot
+.. _`Nginx`: http://wiki.nginx.org/Symfony
+
View
1  cookbook/map.rst.inc
@@ -26,6 +26,7 @@
* :doc:`/cookbook/configuration/external_parameters`
* :doc:`/cookbook/configuration/pdo_session_storage`
* :doc:`/cookbook/configuration/apache_router`
+ * :doc:`/cookbook/configuration/web_server_configuration`
* :doc:`/cookbook/console/index`
Something went wrong with that request. Please try again.