Reputation: 4715
I get permissions errors when running dev/build in either the browser or the cli, depending on which way round I last "fixed" it.
Webserver is www-data Deployment is ssh'd as "beanstalk" and that user is the only user to use the cli to do dev/build like so:
php vendor/silverstripe/framework/cli-script.php dev/build flush=1
I can't change the user of the webserver or deployment service.
To untangle it when it gets mixed up so i can run it via the cli, I have to change the ownership to beanstalk:www-data for these files:
/var/www/stage/public_html/.graphql-generated/
/var/www/stage/public_html/public/assets/.protected/.htaccess
/var/www/stage/public_html/public/assets/.htaccess
/var/www/stage/public_html/public/asset/404-error.html
/var/www/stage/public_html/public/asset/500-error.html
Then, to avoid further calamity, never ever ever run the dev/build?flush via the web browser, which is a peculiur restriction when using silverstripe, as its the go-to action to fix everything!
There are lots of other people over the years facing the same problems:
eg https://forum.silverstripe.org/t/chmod-operation-not-permitted-vendor-league-flysystem/2020
There is some activity in the repo to fix this, but I can't find where the documentation is to use it, eg to set $default_server and how that helps.
https://github.com/silverstripe/silverstripe-assets/issues/81
How can I set my permissions / configure silverstripe to allow www-data OR beanstalk to run the dev/build?
Upvotes: 1
Views: 88
Reputation: 15794
If we have sudo
permissions we can precede the php
command with sudo -u www-data
. This will run the php
command as the www-data
user.
sudo -u www-data php vendor/silverstripe/framework/cli-script.php dev/build flush=1
Upvotes: 0