How to solve the problem Warning: file_put_contents failed to open stream: Permission denied

This problem happens when the php user does not have permission to work with the folder on the server ( maybe it is var or pubĀ folder ).

In the magento 2 some times you often run ssh command line with the root user and it create some new folders and filse with root owner.

You can change owner or change permission for them to solve the problem.

Change owner by using the ssh command line:

sudo chown -R www-data:www-data ./var
sudo chown -R www-data:www-data ./pub

Change permission by using the ssh command line:

sudo chmod -R 777 ./var
sudo chmod -R 777 ./pub


Add Comment

Required fields are marked *. Your email address will not be published.