yassach's avatar

storage link not working in production

I deployed my laravel project in production, but it seems i have problem with storage link i can not show images that are stored withing storage link.

I already tried to delete the symlink file and tape the artisan command, but still not working !! Any ideas ?

0 likes
10 replies
MichalOravec's avatar

Try to create symlink manually, run tis command from public folder

ln -s ../storage/app/public storage

Also you have to include storage in asset helper.

<img src="{{ asset('storage/path-to-image.jpg') }}">
ingenieursage's avatar

@MichalOravec thanks a lot, it worked for me under laravel 9. php artisan storage:link has permission problems on linux distributions.

Snapey's avatar

there is loads of investigation you could do on your own. We don't have access to what you see

For instance

  • what does the img src tag look like in the browser? correct server? correct path?
  • if you are in the terminal do you see the same content when you look in storage/app/public and public/storage? (you should)
  • any inconsistency in the letter case of folder or file names
yassach's avatar

Hey @snapey

The path is correct, i have the same content in storage/app/public and public/storage folders!

I verified that everything is done correctly. i don't see why it won't work !!

Snapey's avatar

and when looking in the browser network tools you see 404 errors for your images?

Snapey's avatar

well that's useful to know since it's then a different type of problem

check the permissions and ownership of the files, obviously they need to be readable by your webserver (commonly the www-data user)

yassach's avatar

I have found some solutions on internet to give permission with chmod 777 on my directory, but i can not allow myself to do it. Also i'm not the owner of this project ...

Snapey's avatar

never set 777 thats just asking for trouble. Permissions are there for a reason.

The directories should be 755 and files 644 as a rule.

If you can't change permissions (or ownership) then its someone else's problem to fix!

1 like

Please or to participate in this conversation.