How to create a symbolic link for laravel website in cPanel

Posted: 26-05-2019 | Views: 20324
How to create a symbolic link for laravel website in cPanel

Symlinks, short for symbolic links, are basically shortcuts to individual files or folders. One of the advantages of a symlink is that it can cross filesystems, as it references abstract filenames/directories and not physical locations.

There is a number of ways to create a symlink

1) Remove storage folder in public_html/public/storage

2) Create a php file for example symlink.php in public_html folder

3) Add codes to symlink.php file

$targetFolder = $_SERVER['DOCUMENT_ROOT'].'/storage/app/public';
$linkFolder = $_SERVER['DOCUMENT_ROOT'].'/public/storage';
symlink($targetFolder,$linkFolder);
echo 'Symlink process successfully completed';

4) Go to web site example.com/symlink.php

That is all...

8 comments

Add comment


  • vainqueur 1 year ago

    thanks, men its worked but there is a problem when the link has created the link that is created is not working: 

    public -> /domains/domain.com/public_html/storage/app/public 

    when I upload an image it doesn't show up.

  • Thanks

  • if you get text of above when you go {app_url}/symlink.php

  • Is this applicable to cpanel when using GoDaddy? Thank you!

  • chosenOne 8 months ago

    is it applicable in using cpanel and godaddy?

  • thanks buddy

  • Thank you very much, please specify that you must add the "symlink" file in the view folder and go through: route-controller-view... excuse my English, I speak French