Last active
October 12, 2015 16:58
-
-
Save symm/4058861 to your computer and use it in GitHub Desktop.
Nginx Symfony 2.1 vhost config
This file contains 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
server { | |
listen 80; | |
server_name yourdomain.com; | |
root /www/yourdomain.com/current/web; | |
error_log /var/log/nginx/yourdomain.error.log; | |
access_log /var/log/nginx/yourdomain.access.log; | |
# strip app.php/ prefix if it is present | |
rewrite ^/app\.php/?(.*)$ /$1 permanent; | |
location / { | |
index app.php; | |
try_files $uri @rewriteapp; | |
} | |
location @rewriteapp { | |
rewrite ^(.*)$ /app.php/$1 last; | |
} | |
## Any other attempt to access PHP files redirects to the root. | |
location ~* ^.+\.php$ { | |
return 302 /; | |
} | |
## Aggressively cache assets. Be sure you have your assetic configured properly! | |
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { | |
expires max; | |
log_not_found off; | |
} | |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
location ~ ^/(app|config|app_dev)\.php(/|$) { | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_split_path_info ^(.+\.php)(/.*)$; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param HTTPS off; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment