我有一个 Symfony 2.7 应用程序,它在本地开发环境和 AWS Ubuntu ec2 实例上运行良好。我正在将其迁移到 Heroku 并且能够登录,但是所有 Web Assets (css/img/js) 请求都会导致 403 (Forbidden)
在浏览器控制台中。
Heroku 日志显示,例如:
AH00037: Symbolic link not allowed or link target not accessible
在我的
composer.json
,在“额外”节点下,我有:"symfony-assets-install": "symlink"
我目前没有使用 Assets 。
我尝试过的事情
运行
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 没有遵循符号链接(symbolic link),所以我也尝试了
php app/console assets:install
,产生“将 Assets 安装为硬拷贝”,然后清除缓存(使用 app/console cache:clear
),但问题仍然存在。 php app/check.php
给我A-OK。有什么想法,或者我可以提供更多信息吗?
最佳答案
尝试从
"symfony-assets-install": "symlink"
至
"symfony-assets-install": "relative"
关于apache - Symfony Heroku 部署 : Assets Not Accessible,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31033627/