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.
UnexpectedValueException
The stream or file storage/logs/laravel.log could not be opened
Permission denied
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.
Replace user and group names according to your server.
chmod -R 777 storage bootstrap/cachechown -R deploy:www-data storage bootstrap/cache
chmod -R ug+rwX storage bootstrap/cacheThe web process may not write to files owned only by root.
root:root storage/logsdeploy:www-data storage/logsOn AlmaLinux/Rocky, security context must also be checked.
chmod correct ama Permission deniedrestorecon -Rv storage bootstrap/cacheConfirms 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
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
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 {} \;
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');"
Back up the project and database, and record current permissions.
Determine the actual user and group of PHP-FPM, Apache or LSAPI.
Set storage and bootstrap/cache ownership according to the deployment model.
Grant group write and execute to directories and group write to files.
Validate SELinux contexts or ACL rules when applicable.
Test Laravel log, session, view and cache writes.
The runtime user cannot write to the directory or traverse a parent directory.
storage/logs or the existing log file belongs to another user.
storage/framework subdirectories are missing or unwritable.
The filesystem has immutable flags, ACL, mount or SELinux restrictions.
No matching error was found.
World-writable files allow unrelated processes on the server to modify application data. Correct ownership and group permissions are safer.
Usually the cPanel account user and its PHP handler model apply. Inspect running processes before copying www-data commands.
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.
We implement permanent fixes by reviewing Laravel, PHP-FPM, Nginx, Apache, MySQL, cPanel and Plesk layers together with their logs.