Skip to content

Step 5 of 10

Laravel file permissions on shared hosting

Laravel only needs to write to two places: storage/ and bootstrap/cache/. Everything else can stay read-only for the web server, and nothing needs 777.

What to set

  • Folders: 755
  • Files: 644
  • .env: 640 or 600, if your host allows it
  • storage/ and bootstrap/cache/: 755, or 775 if logs and cache still can't be written

On most cPanel hosts PHP runs as your own account, so 755 is enough for writing.

cd ~/laravel-app
find . -type d -exec chmod 755 {} +
find . -type f -exec chmod 644 {} +
chmod -R 775 storage bootstrap/cache

Without a Terminal

In File Manager, right-click a folder and choose Change Permissions. Zip uploads normally extract with correct permissions, so you only need this when something fails.

Why 777 can make things worse

Besides being unsafe, many shared hosts refuse to run PHP from a folder or file that is writable by everyone, and answer with a 500 or 403 error. If you changed things to 777 to fix an error, set them back.

Frequently asked questions

Laravel says the log "could not be opened in append mode". What now?

It can't write to storage/logs. Set storage/ to 775 and check the folder belongs to your account. If you ran a command as another user, the file may belong to that user.

Get new articles in your inbox

Practical tutorials and deep dives, about once a week. No spam, unsubscribe anytime.

Privacy policy

Add DEV Talk to your Home Screen

  1. 1 Tap the Share button in Safari's toolbar.
  2. 2 Scroll down and tap Add to Home Screen.
  3. 3 Tap Add. Open it from the Home Screen to read like an app and to turn on notifications with the bell.

We use cookies to improve your experience and analyze traffic. By continuing, you agree to our Privacy Policy.