我使用Amazing Beanstalk部署了我的Laravel 5.1应用程序,在重复使用后我最终得到了这个错误。
"file_put_contents(/var/app/current/storage/framework/cache/d4/d7/d4d77eddeb64100f6da8f8b601a4631b): failed to open stream: Permission denied"
在我的.ebextensions配置文件中,我尝试将此命令添加到部署中,但它无法解决问题,因为文件似乎是在部署后浏览网站时创建的。
container_commands:
"02-chmod-storage":
command: "cd /var/app/ondeck; chmod -R 777 storage"
我该如何永久修复此问题?
这应该这样做:
commands:
create_post_dir:
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_chmod_storage.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
. /opt/elasticbeanstalk/support/envvars
cd $EB_CONFIG_APP_CURRENT
su -c "chmod -R 777 storage" $EB_CONFIG_APP_USER
尝试在/ storage上设置ACL权限,允许root和webapp(或运行Web服务器的用户名)的rwx访问:
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_setfacl_storage.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
echo "Setting ACL permissions for /storage..."
setfacl -Rdm u:root:rwx,u:webapp:rwx /var/app/current/storage
setfacl -Rm u:root:rwx,u:webapp:rwx /var/app/current/storage