Every time I run composer (e.g., sudo composer install, sudo composer self-update
etc.) I need to run this with sudo as the owner of the file is root.
However every time I use the composer with sudo root owns the vendor folder and then I have to change the owner of that folder/privileges from root to www-data.
What is the best way to fix this so I do not have to run sudo every time?
Change the owner of /usr/local/bin/composer
from root to www-data?
Is this the ideal way to handle this to avoid having to change ownership and assign permission every time I use sudo composer install
?
Edit:
The permissions for composer are currently -rwxr-xr-x
. And I've tried switching the owner of /usr/local/bin/composer
over to www-data:www-data
with permissions set to 775, and still I can't run composer without running sudo
.
Best Answer
If "everyone" is allowed to read and execute composer, you don't need to use sudo:
Since you already executed composer at least once as
root
, composers (per-user-)cache directory is now owned by root and therefore isn't writable by your normal user.will fix the file-owner.