Arama Yap Mesaj Submit
Request a Callback
+90
X
X

Select Your Currency

Turkish Lira $ US Dollar Euro
X
X

Select Your Currency

Turkish Lira $ US Dollar Euro

Contact Us

Location Halkali merkez neighborhood fatih st ozgur apt no 46 , Kucukcekmece , Istanbul , 34303 , TR
Linux permissions and Laravel

Safely fix Laravel 500 errors caused by storage and bootstrap/cache permissions

Laravel must let the web server process write logs, sessions, compiled views and cache files under storage and bootstrap/cache. The solution is not chmod 777, but correct ownership and group permissions.

root@eka:~/application
UnexpectedValueException
The stream or file storage/logs/laravel.log could not be opened
Permission denied
2Core writable directories
USERIdentify the actual PHP-FPM user
GROUPDeploy and web users can share a group
NO 777World-writable permissions are not a fix
01
Technical diagnosis

Find the running user before changing chmod values

Laravel deployment documentation requires storage and bootstrap/cache to be writable by the web server process. The runtime user differs across cPanel, Plesk, Nginx, Apache and PHP-FPM setups, so one universal chown command is not correct for every server.

01

Unsafe broad permission

Replace user and group names according to your server.

Incorrect
chmod -R 777 storage bootstrap/cache
Correct
chown -R deploy:www-data storage bootstrap/cache
chmod -R ug+rwX storage bootstrap/cache
02

Incorrect ownership

The web process may not write to files owned only by root.

Incorrect
root:root storage/logs
Correct
deploy:www-data storage/logs
03

SELinux restriction

On AlmaLinux/Rocky, security context must also be checked.

Incorrect
chmod correct ama Permission denied
Correct
restorecon -Rv storage bootstrap/cache
02
SSH and terminal

Measure and verify logs before guessing

01

Identify PHP-FPM and web server users

Confirms the actual process rather than guessing chown targets.

ps -eo user,group,comm,args | grep -E 'php-fpm|apache2|httpd|lsphp' | grep -v grep
grep -R '^user\|^group' /etc/php/*/fpm/pool.d /etc/php-fpm.d 2>/dev/null
02

Inspect ownership and permissions

Also reveals missing execute permission on parent directories.

namei -l storage/logs/laravel.log 2>/dev/null || true
find storage bootstrap/cache -maxdepth 2 -printf "%M %u:%g %p\n" | head -n 100
03

Apply group-based permissions

Replace deploy and www-data with your real user and group.

chown -R deploy:www-data storage bootstrap/cache
find storage bootstrap/cache -type d -exec chmod 2775 {} \;
find storage bootstrap/cache -type f -exec chmod 664 {} \;
04

Run Laravel write tests

If CLI and web users differ, verify through an HTTP request as well.

php artisan optimize:clear
php artisan view:cache
php artisan tinker --execute="logger()->info('izin testi');"
03
Controlled implementation

Safe step-by-step resolution sequence

01

Step 1

Back up the project and database, and record current permissions.

02

Step 2

Determine the actual user and group of PHP-FPM, Apache or LSAPI.

03

Step 3

Set storage and bootstrap/cache ownership according to the deployment model.

04

Step 4

Grant group write and execute to directories and group write to files.

05

Step 5

Validate SELinux contexts or ACL rules when applicable.

06

Step 6

Test Laravel log, session, view and cache writes.

04
Error dictionary

Map similar-looking errors to the correct cause

4 entries
Error

Permission denied

The runtime user cannot write to the directory or traverse a parent directory.

Error

laravel.log could not be opened

storage/logs or the existing log file belongs to another user.

Error

Please provide a valid cache path

storage/framework subdirectories are missing or unwritable.

Error

Operation not permitted

The filesystem has immutable flags, ACL, mount or SELinux restrictions.

No matching error was found.

What to avoid

Actions that make the problem worse

  • Do not chmod 777 the entire project.
  • Do not make .env and config files unnecessarily writable by the web user.
  • Do not assume www-data on cPanel or Plesk and break their ownership model.
  • Do not run Artisan as root and create new root-owned files.
Success verification

How do you know the fix is complete?

  • storage/logs/laravel.log can be updated.
  • Session and cache drivers write without errors.
  • view:cache and optimization commands succeed.
  • Web and CLI users do not rely on overly broad permissions.
05
FAQ

Frequently asked technical questions

Why is chmod 777 discouraged?

World-writable files allow unrelated processes on the server to modify application data. Correct ownership and group permissions are safer.

Which user should be used on cPanel?

Usually the cPanel account user and its PHP handler model apply. Inspect running processes before copying www-data commands.

Why do permissions break again after deployment?

If deployment creates files as root or another user, ownership changes again. Run deployment as the application user and include permission normalization in the pipeline.

06
Topic cluster

Related Laravel and server error guides

Official technical sources

Resolution steps were verified against primary documentation

Laravel Deployment PermissionsLaravel Directory StructurePHP Error ConfigurationLaravel Configuration
EKA SOFTWARE AND INFORMATION SYSTEMS

Fix Laravel permissions with correct ownership and groups, not chmod 777

We implement permanent fixes by reviewing Laravel, PHP-FPM, Nginx, Apache, MySQL, cPanel and Plesk layers together with their logs.

Get Technical SupportWrite on WhatsApp
Top