I have deployed Laravel 10 to Siteground. I placed the contents of Laravel’s public folder directly inside public_html
, and created a separate folder within public_html
for the rest of Laravel’s directory structure. As a result, the storage folder (which is a symlink) resides inside public_html
. However, all my images uploaded to Laravel/storage/app/public
are not visible on the website. I have tried recreating the symlink via SSH using the ln -s
Linux script. The symlink appears to be there, but I still can’t view the images on the website. I have also attempted to modify the .env(APP_URL)
or .env(APP_STORAGE_PATH)
and filesystem files, but to no avail. What could I be doing wrong?
Here’s what I’ve tried so far:
- Connecting to the server via SSH and running
ln -s
to linkstorage/app/public
withpublic_html/storage
. This seems to work as I can see the symbolic link, but I still can’t view the images on the website. - Modifying the
.env(APP_URL)
or.env(APP_STORAGE_PATH)
and filesystem files, but this doesn’t seem to have any effect.
I’m running out of ideas. Can anyone provide some guidance?
2
Answers
This is not advisable. Your public_html directory will be what the web server points to, meaning that anyone can potentially access all the Laravel code, potentially including your .env file which is a common point of attack as it may contain sensitive API keys and database credentials.
I am unfamiliar with the host you are referring to, but I would strongly recommend reaching out to their support and check with them if you are able to change the document root for the web server and maintain the standard Laravel file structure in order to protect the files you need to keep away from prying eyes.
Symbolic links like paths relative to link or absolute. What should work is first
cd public_html
, you can delete storage directory if it exists. Then runln -s ./Laravel/storage/app/public ./storage
. Storage directory now should be linked to your private storage, seels -l
.