DEV Community

loading...
Cover image for Creating symbolic link in a shared hosting using PHP

Creating symbolic link in a shared hosting using PHP

TRUNG VU
Full-Stack web developer
・1 min read

Now, we will learn how create symbolic link in a shared hosting using PHP

In Laravel documentation, a symbolic link (symlink or soft link) from public/storage to storage/app/public should be created to make files accessible from the web.

Create a symlink.php file:

$targetFolder = '/home/your_account/your_project_src/storage/app/public';
$linkFolder = '/home/your_account/your_domain.com/storage';
symlink($targetFolder, $linkFolder);
echo 'Symlink process successfully completed';
Enter fullscreen mode Exit fullscreen mode

Upload to public_html or your domain folder and run this symlink.php file:

http://your_domain.com/symlink.php
Enter fullscreen mode Exit fullscreen mode

Done! A folder named storage will be created to link path with an indicator >>> on the folder icon.

Happy Coding:)

Discussion (0)