Answer the question
In order to leave comments, you need to log in
What is the best way to switch between environments in Symfony?
Good evening.
How to configure nginx to easily switch between app.php and app_dev.php?
I tried to do acme.com/... for production and acme.com/app_dev.php /... for development
. requests go to acme.com/app_dev.php/foo.js
You can do a rewrite in the location for statics, removing app_dev.php from the address, but it didn't work for me :) And I'm not sure if this is the best option.
I can’t return statics through the controller in the dev environment because of the fonts that have to be copied manually to the web / fonts folder (using symfony, I understand there, they cannot be returned as other statics).
root /home/ivan/sites/acme.com/web;
location / {
try_files $uri /app.php$is_args$args;
}
location ~* \.(?:jp?g|gif|png|ico|svg|css|js|swf|zip|tar|tgz|gz|rar|bz2|doc|docx|xls|xlsx|ppt|pptx|exe|msi|txt|mp3|mp4|mkv|mpg|mov|fla|eot|otf|ttf|woff)$ {
expires 360d;
access_log off;
log_not_found on;
# пытался сделать тут костыль, но он не работает
# if ($request_uri ~ ^/(app|app_dev).php) {
# rewrite ^/(app|app_dev).php/$ /$1 last; break;
# }
try_files $uri =404;
}
location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass php-fpm-acme;
fastcgi_split_path_info ^(.+\.php)(.*)$;
set $fsn /app.php;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
include conf.d/fastcgi.conf;
fastcgi_param SERVER_ADMIN [email protected]$hostname;
}
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
Answer the question
In order to leave comments, you need to log in
Actually...
/ - prod
/app_dev.php/ - dev
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question