I have the following code inside my project.config file:
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
or the same code if inside the post deployment script defined under files:
. Now this works perfectly fine when I ssh into the server and see the file permissions and ownership, but the problem is the app doesn't work and it gives following error:
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
When I manually run the same commands, I still notice the same permissions and ownership with ls -l
as before, the same green app/cache
directory and everything is same but I no more get the above error and the app works.
Why does it happen? Why do I have to execute them manually?
Maybe try it as a hook, and test different owner/groups?
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
Ref: serverfault question