Issue
I'm new to Ubuntu, and I'm trying to get my Ubuntu web server running, but I have a problem with composer. When I run composer install
it outputs this error [ErrorException] file_put_contents(./composer.lock): Failed to open stream: Permission denied
.
I found a solution for this on the internet, but it doesn't work for me
Not working solution:
sudo chown -R $USER ~/.composer/
It outputs
chown: cannot access '/home/admin/.composer/': No such file or directory
I'm using Ubuntu 20.04. Does anyone know what should I do?
Solution
composer install
is trying to create a .composer.lock
file in your project directory, so php should have permission to do that.
A quick hack is to use sudo composer install
,but this is not the recommended way.
this should also work
sudo chown -R :www-data /fullpath-to-your-project
Answered By - Kushal Billaiya Answer Checked By - Robin (WPSolving Admin)