amazon-web-services - 配置文件中的 Elastic Beanstalk 文件权限
问题描述
我的 project.config 文件中有以下代码:
container_commands:
10_io_permissions:
command: |
cd /var/app/ondeck
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chmod -R g+w app/cache/
chmod -R g+w app/logs/
chmod -R g+w app/config/
chmod -R g+w media/files/
chmod -R g+w media/images/
chmod -R g+w translations/
chown -R webapp:webapp .
chmod -R 777 app/cache/
php app/console cache:clear --no-warmup -e prod
ignoreErrors: true
或相同的代码,如果在下定义的部署后脚本中files:
。现在,当我 ssh 进入服务器并查看文件权限和所有权时,这可以正常工作,但问题是应用程序无法正常工作,并且出现以下错误:
Cache directory "/var/app/current/app/cache/prod" is not writable. - in file /var/app/current/vendor/symfony/class-loader/ClassCollectionLoader.php - at line 280
当我手动运行相同的命令时,我仍然注意到与ls -l
以前相同的权限和所有权,相同的绿色app/cache
目录,一切都相同,但我不再收到上述错误并且应用程序正常工作。
为什么会这样?为什么我必须手动执行它们?
解决方案
也许尝试将其作为一个钩子,并测试不同的所有者/组?
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_change_permissions.sh":
mode: "000755"
owner: ec2-user
group: ec2-user
content: |
#!/bin/sh
cd /var/app/ondeck
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chmod -R g+w app/cache/
chmod -R g+w app/logs/
chmod -R g+w app/config/
chmod -R g+w media/files/
chmod -R g+w media/images/
chmod -R g+w translations/
chown -R webapp:webapp .
chmod -R 777 app/cache/
php app/console cache:clear --no-warmup -e prod
参考:服务器故障问题
推荐阅读
- c# - .NET 5 WorkerService HostingEnvironment.IsDevelopment() 在环境变量 ASPNETCORE_ENVIRONMENT 设置为 Development 时返回 false
- c# - 为什么我对 RichTextBox.AppendText() 的 C# 代码调用没有一致地处理 \r\n?
- javascript - 变量未在 .then 处理程序中定义
- reactjs - 如何将 Material UI 中的 BOX 组件用于不同的屏幕尺寸?
- node.js - 在 openapi-generator-cli nodejs-express-server 后面编写 Node 业务逻辑
- javascript - 使用 React,单击后退按钮时,视图正在正确更新,但 URL 未正确更新
- reactjs - 错误:在使用 fetch 从 api 收集数据时,对象作为 React 子项(找到:[object Promise])在反应中无效
- javascript - TypeError 提供的 fullPermissions 不是带有斜杠命令权限的 GuildApplicationCommandPermissionData 数组(v13 Discord.js)
- reactjs - React 在我们的页面上获取 iframe 播放视频的图像并将其保存到本地驱动器的最佳方法是什么?
- python - 无法为 Python 3.9 64 位运行 PythonWin