-
-
Save LouWii/6464876 to your computer and use it in GitHub Desktop.
NGinx Server block configuration for Symfony 2 app.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Things needed to be adapted : | |
# server_name my-domain.com | |
# | |
# root /home/www | |
# The root of the Symfony "web" folder (with app.php and app_dev.php in it). | |
# | |
# fastcgi_pass unix:/var/run/php5-fpm.sock | |
# This sock can be elsewhere (/var/run/php5-fpm/php5-fpm.sock for example...) | |
# | |
# There are other things needed to be changed/fixed. | |
# | |
# When going to my-domain.com/config.php, the file is downloaded. | |
# my-domain.com/favicon.ico gives me the NGinx welcome page. | |
# ... | |
# | |
# But it's a good start ! | |
server { | |
listen 80; | |
server_name my-domain.com; | |
root /home/www/clients/client1/web7/web; | |
rewrite ^/app\.php/?(.*)$ /$1 permanent; | |
try_files $uri @rewriteapp; | |
location @rewriteapp { | |
rewrite ^(.*)$ /app.php/$1 last; | |
} | |
# Deny all . files | |
location ~ /\. { | |
deny all; | |
} | |
location ~ ^/(app|app_dev)\.php(/|$) { | |
fastcgi_split_path_info ^(.+\.php)(/.*)$; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_index app.php; | |
send_timeout 1800; | |
fastcgi_read_timeout 1800; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
#fastcgi_pass 127.0.0.1:9000; | |
} | |
# Statics | |
location /(bundles|media) { | |
access_log off; | |
expires 30d; | |
# Font files | |
#if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$){ | |
# add_header Access-Control-Allow-Origin *; | |
#} | |
try_files $uri @rewriteapp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment