我有一个Symfony 2.7应用程序,可以在本地开发环境和AWS Ubuntu ec2实例上正常运行。我将其迁移到Heroku并且我能够登录,但所有网络资产(css / img / js)请求都会在浏览器控制台中生成403 (Forbidden)
。
Heroku日志显示,例如:
AH00037: Symbolic link not allowed or link target not accessible
在我的composer.json
中,在'额外'节点,我有:
"symfony-assets-install": "symlink"
我目前没有使用资产。
我尝试过的事情
运行heroku run bash
并前往我应用的网络目录,我看到了:
~/web/bundles $ ls -la
lrwxrwxrwx 1 u46658 46658 85 Jun 24 13:56 mybundle -> /tmp/build_0940aedabf55a47c5c407ff7b7a58c58/src/MyApp/MyBundle/Resources/public
但是我不能cd
进入mybundle
目录,也不能进入/temp/...
目录('没有这样的文件或目录')。
由于这似乎是因为Apache没有遵循符号链接,我还尝试了php app/console assets:install
,它产生了“将资产安装为硬拷贝”,然后清除了缓存(带有app/console cache:clear
)但问题仍然存在。 php app/check.php
给了我A-OK。
我可以提供任何想法或更多信息吗?
答案 0 :(得分:1)
尝试从
更改"symfony-assets-install": "symlink"
要
"symfony-assets-install": "relative"
答案 1 :(得分:0)
I solved this by adding the following to the scripts
key in composer.json:
"compile": [
"app/console assets:install"
]
I believe this is related to the heroku ephemeral file system, which apparently resists file system changes after a deploy. Interesting that performing an app/console assets:install
in the heroku bash shell doesn't result in an error, but also doesn't fix the problem, while issuing the same command during deployment does.