I am trying to access my image files stored inside storage/app/public/subfolder/
using symlink inside /public
folder in my Laravel app. Everything works fine in my local setup and also in Jelastic Apache deployment, but it doesn't seem to work in CPanel with LiteSpeed. I am trying to access the files using the link /storage/subfolder/image.png
but it is not accessible on CPanel deployment.
I tried creating and deleting storage symlink hundreds of times, but it didn't work. Below are few things I tried:
php artisan storage:link
command.ln -s ../storage/app/public storage
inside public folder.Artisan::call('storage:link')
using a web route entry.In all of these failed attempts I can verify that storage symlink is created every time inside public folder. I can navigate and view files from public/storage/
folder using CPanel terminal without any issues but can't access them in the deployed app.
I have exact same configuration in Jelastic Apache deployment and in my local deployment and there it is working without any issues.
UPDATE:
Additionally, I tried creating a storage
directly manually inside public
folder with the same structure and it worked. But symlink doesn't work.
UPDATE 2: I found below error log while checking error logs from CPanel.
2022-11-06 05:07:07.342556 [ERROR] [1669834] [T0] [HTAccess] Failed to open [/home/user/my-project/public/storage/subfolder/.htaccess]: Permission denied
There is no .htaccess
inside subfolder
but it is there in my public folder.
What might be the issue?
After a long search, I finally found the cause.
Somehow the storage/app/public
directory didn't have sufficient permissions. So, I gave permissions to that public folder recursively using chmod
and everything works fine now.
The symlink was working fine but it was not working due to permission issues in the parent folder.
This is a bit weird as I have never manually altered permissions in any Laravel folders in any of my other deployments.