Microsoft Azure Build and deploy PHP app to Azure Web App: Laravel App - Unable to create lockable file

80 Views Asked by At

We have a Laravel PHP application and we have deployed with the Build and deploy PHP app to Azure Web App workflow.

we have used nginx.

Sometimes we are facing issues related to permissions please find the below detailed error:

Unable to create lockable file: /home/site/wwwroot/storage/framework/cache/data/5a/0f/5a0fce553c194ec423d77dd06617ff2720c4c5c6. Please ensure you have permission to create files in this location.

So the solution is we need to give the permission and ownership using the below command:

chmod -R 775 /home/site/wwwroot/storage
chown -R www-data:www-data /home/site/wwwroot/storage

but after execution, nothing happened, and I was facing the same problem randomly.

Can anyone help with it?

1

There are 1 best solutions below

2
Suresh Chikkam On

give the permission and ownership using the below command: chmod -R 775 /home/site/wwwroot/storage chown -R www-data:www-data /home/site/wwwroot/storage

  • Firstly, check that the web server user (often www-data or nginx) has appropriate ownership of the directories. On Azure Web App, the web server user may have a different name.

  • Remove the cache directory and run the application. You can remove all the content in the framework directory. It will be created automatically if the permissions are indeed 755.

Remember cache files won't be deleted automatically. This will cause issues over time.

  • run the Artisan cache clear command.

If still the issue is not cleared please use the below cmd.

sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

This command sets the permissions to read, write, and execute (full permissions) for the storage directory and all its contents.

Reference:

  1. Unable to create lockable file.

  2. Unable to create lockable file Laravel.

  3. I resolved it by providing owner permission to apache user.