Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

christian_H's avatar

Can't create storage symlink in Homestead

Hey folks, I have an existing laravel application that I'm trying to run in a new homestead environment. For some reason, I am unable to create the symlink between the storage/app/public and public/storage directories. Running the command ln -s storage/app/public public/storage from inside homestead in my project's directory results in a broken link (it shows up in my IDE as a broken link, and none of my images in storage/app/public are available). I also tried ln -s $(pwd)/storage/app/public $(pwd)/public/storage as well as trying it with the full path written out. All of this results in a broken link.

I've also tried creating the symlink from outside of homestead, just in the directory the files are stored in. Interestingly, this seems to work correctly when I view it in my IDE, the link is there and links to the correct directory. But even then, trying to access the images in the browser results in a 404, same as when the link is broken (or not present at all).

I'm running laravel 5.2.32 with spark 1.0, using a fresh install of homestead with vagrant and virtualbox. Anyone know what's going on here? Thank you very much!

0 likes
11 replies
ejdelmonico's avatar

I think you should be linking from inside the vm by sshing into the box and go to project directory and run php artisan storage:link and it should work fine. Or, from your project directory run php artisan storage:link. I would try from the project directory first and if that does not work then ssh into the box and try it.

Then, for public access use either /storage/file.txt or asset('file.txt')

2 likes
jijoel's avatar

I'll usually just go into the destination directory, and run the link from there.

cd public
ln -s ../storage/app/public storage
cd ..
1 like
christian_H's avatar

@ejdelmonico thanks for your answer! Unfortunately that artisan command was added after the version of laravel I'm running, so I have to do it the hard way :(

@jijoel, thanks, unfortunately that leaves me with a broken link again

ejdelmonico's avatar

oh, I see. Well you can always make your own artisan command. It shouldn't be that hard.

1 like
Cronix's avatar

Are you doing this while ssh'd into the homestead box, or are you running the ln command from the host os? Needs to be done while ssh'd into the homestead box so it's linked in the homestead OS's filesystem and not your native/host filesystem.

1 like
christian_H's avatar

Oh I know, but this old way of doing it has worked fine for me in the past with this same project/laravel version. I have a feeling that artisan command is doing the same thing I'm doing, since this was originally the method described in the spark docs.

I've tried doing it from the project directory like you recommended. It actually does create a working symlink, but all my file paths still result in a 404 inside homestead. When I do it ssh'd into the box, it leaves me with a broken link. I know what you've described should be working, but it seems that there's something wrong with my homestead installation or something that is keeping it from working. I've set this link up on this same project multiple times before with no issue, its just this fresh install that's giving me grief

christian_H's avatar

@Cronix thanks for the reply. I've tried it from ssh'd into homestead, from the root directory of my project. Unfortunately it gives me a broken link, with no error message when I run the command.

ejdelmonico's avatar
Level 53

Try this...make sure there is no public/storage directory in the project and in the project inside the VM. Then, try running the command again from the root of the project inside the VM. ln -s ../storage/app/public public/storage

I know that the link command will sometimes not work if the link-to directory already exists.

2 likes
christian_H's avatar

Thanks @ejdelmonico, unfortunately that results in a broken link with no error message again. No storage directory in public. I tried it with the public/storage directory there just to see what would happen; it returns "Killed" in the command line. So it seems like it should be working normally, it just isn't for whatever reason

ejdelmonico's avatar

That is puzzling. I know the command will sometimes fail silently but as long as both project folders do not have the directory already, it should work. Also, are you the owner of the project and the homestead install? That would cause the link to fail if you do not own both directories.

The Homestead directory on your machine should have 755 permissions so that the VM is created with the appropriate ownership. Also, your project directory on your system should be 755 (rwxr-xr-x)

1 like
christian_H's avatar

@ejdelmonico, I got it, thanks to you! I'm a dummy, was trying to use the full path or using $(pwd) to get the path. I tried it with the ../ like in your example and it worked perfectly. Thank you so much for your help!

Please or to participate in this conversation.