DEV Community

Roby Cigar
Roby Cigar

Posted on

Unable to create lockable file: /var/www/. Please ensure you have permission to create files in this location.

That error means the current user (probably root or www-data) doesn’t have write permissions to the Laravel storage directory or its subfolders.


🔧 Fix File Permissions

Run these commands to give proper ownership and permissions:

1. Give the web server user access (assuming you're using Apache or Nginx)

cd /var/www/html/million-candles/backend # Set correct ownership (adjust 'www-data' if your web server uses a different user) sudo chown -R www-data:www-data storage bootstrap/cache # Give read/write/execute permission to owner sudo chmod -R 775 storage bootstrap/cache 
Enter fullscreen mode Exit fullscreen mode

If you're running commands as root, and Laravel is executed via www-data, this ensures the app can write to the necessary folders.


✅ Recommended .gitignore reminder

Make sure storage contents like cache, logs, and sessions are ignored in Git:

/storage/* !/storage/.gitignore !/storage/framework/ /storage/framework/cache/* !/storage/framework/cache/.gitignore 
Enter fullscreen mode Exit fullscreen mode

After Fixing Permissions

You can now retry the failed Git commands or run Laravel normally:

php artisan config:cache php artisan route:cache 
Enter fullscreen mode Exit fullscreen mode

Let me know if your Laravel app is running on a different user or if you'd like to reset the file permissions entirely.

Top comments (0)