我正在尝试让现有的网站在我提供的流浪环境中本地运行。但是,CSS资产是404。
app/config/config_dev.yml
有:
assetic:
use_controller: true
write_to: "/%kernel.root_dir%/../web/"
我做完了:
php app/console assets:install --symlink
php app/console assetic:dump --env=dev
两个命令的输出看起来都符合预期,我可以在/web/css/
当我访问本地网站时,我得到了404:
http://192.168.33.10/app_dev.php/css/59addc3_main_1.css
如果我手动编辑它:
http://192.168.33.10/css/59addc3_main_1.css
加载CSS文件。
这是Nginx conf而不是Symfony的问题吗?我的完整虚拟主机看起来像:
server {
listen *:80 default_server;
server_name www.mysite.dev;
root '/vagrant/web';
access_log /var/log/nginx/mysite.access.log;
error_log /var/log/nginx/mysite.error.log;
location ^~ /javascript {
default_type text/plain;
return 410 "d14:failure reason13:not a tracker8:retry in5:nevere";
}
location ~* \.(jpg|jpeg|png|gif|ico)$ {
expires 30d;
}
location ~* \.(js|css)$ {
expires 30d;
gzip_min_length 1100;
gzip_proxied any;
gzip_types text/plain application/xml text/css text/js text/xml application/x-javascript text/javascript application/json application/xml+rss application/javascript;
}
location / {
try_files $uri /app_dev.php$is_args$args;
}
location ~ ^/(app|app_dev|app_test|config)\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}