Commit 4d106637 authored by Fabien Potencier's avatar Fabien Potencier

moved web server configuration info to its own chapter

parent 074a1152
......@@ -13,5 +13,6 @@ Silex
internals
contributing
providers/index
web_servers
changelog
phar
......@@ -61,8 +61,8 @@ definitions, call the ``run`` method on your application::
$app->run();
Then, you have to configure your web server (read below hints for Apache and
IIS).
Then, you have to configure your web server (read the dedicated chapter for
more information).
.. tip::
......@@ -768,90 +768,4 @@ to prevent Cross-Site-Scripting attacks.
return $app->json(array('name' => $name));
});
Webserver configuration
-----------------------
Apache
~~~~~~
If you are using Apache you can use a ``.htaccess`` file for this:
.. code-block:: apache
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
#RewriteBase /path/to/app
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
.. note::
If your site is not at the webroot level you will have to uncomment the
``RewriteBase`` statement and adjust the path to point to your directory,
relative from the webroot.
Alternatively, if you use Apache 2.2.16 or higher, you can use the
`FallbackResource directive`_ so make your .htaccess even easier:
.. code-block:: apache
FallbackResource index.php
nginx
~~~~~
If you are using nginx, configure your vhost to forward non-existent
resources to ``index.php``:
.. code-block:: nginx
server {

index index.php
location / {
try_files $uri $uri/ /index.php;
}
location ~ index\.php$ {
fastcgi_pass /var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
IIS
~~~
If you are using the Internet Information Services from Windows, you can use
this sample ``web.config`` file:
.. code-block:: xml
<?xml version="1.0"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Silex Front Controller" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
.. _FallbackResource directive: http://www.adayinthelifeof.nl/2012/01/21/apaches-fallbackresource-your-new-htaccess-command/
.. _download: http://silex.sensiolabs.org/download
Webserver Configuration
=======================
Apache
------
If you are using Apache you can use a ``.htaccess`` file for this:
.. code-block:: apache
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
#RewriteBase /path/to/app
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
.. note::
If your site is not at the webroot level you will have to uncomment the
``RewriteBase`` statement and adjust the path to point to your directory,
relative from the webroot.
Alternatively, if you use Apache 2.2.16 or higher, you can use the
`FallbackResource directive`_ so make your .htaccess even easier:
.. code-block:: apache
FallbackResource index.php
nginx
-----
If you are using nginx, configure your vhost to forward non-existent
resources to ``index.php``:
.. code-block:: nginx
server {
index index.php
location / {
try_files $uri $uri/ /index.php;
}
location ~ index\.php$ {
fastcgi_pass /var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
IIS
---
If you are using the Internet Information Services from Windows, you can use
this sample ``web.config`` file:
.. code-block:: xml
<?xml version="1.0"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Silex Front Controller" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
.. _FallbackResource directive: http://www.adayinthelifeof.nl/2012/01/21/apaches-fallbackresource-your-new-htaccess-command/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment