Commit e9bd89bb authored by Fabien Potencier's avatar Fabien Potencier

minor #1185 Changed the proposed nginx configuration to mimic Symfony's one (mTorres)

This PR was squashed before being merged into the 1.3 branch (closes #1185).

Discussion
----------

Changed the proposed nginx configuration to mimic Symfony's one

The proposed configuration solves [this 404 error issue](https://github.com/silexphp/Silex-Skeleton/issues/24) when trying to load the web profiler under nginx.

Commits
-------

7e8157f9 Changed the proposed nginx configuration to mimic Symfony's one
parents 14a33ebe 7e8157f9
...@@ -39,38 +39,45 @@ Alternatively, if you use Apache 2.2.16 or higher, you can use the ...@@ -39,38 +39,45 @@ Alternatively, if you use Apache 2.2.16 or higher, you can use the
nginx nginx
----- -----
If you are using nginx, configure your vhost to forward non-existent The **minimum configuration** to get your application running under Nginx is:
resources to ``index.php``:
.. code-block:: nginx .. code-block:: nginx
server { server {
#site root is redirected to the app boot script server_name domain.tld www.domain.tld;
location = / { root /var/www/project/web;
try_files @site @site;
}
#all other locations try other files first and go to our front controller if none of them exists
location / { location / {
try_files $uri $uri/ @site; # try to serve file directly, fallback to front controller
} try_files $uri /index.php$is_args$args;
#return 404 for all php files as we do have a front controller
location ~ \.php$ {
return 404;
} }
location @site { # If you have 2 front controllers for dev|prod use the following line instead
# location ~ ^/(index|index_dev)\.php(/|$) {
location ~ ^/index\.php(/|$) {
# the ubuntu default # the ubuntu default
fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_pass unix:/var/run/php5-fpm.sock;
# for running on centos # for running on centos
#fastcgi_pass unix:/var/run/php-fpm/www.sock; #fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params; include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#uncomment when running via https fastcgi_param HTTPS off;
#fastcgi_param HTTPS on;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/index.php/some-path
# Enable the internal directive to disable URIs like this
# internal;
}
#return 404 for all php files as we do have a front controller
location ~ \.php$ {
return 404;
} }
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
} }
IIS IIS
......
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