DEV Community

Cover image for Creating symbolic link in a shared hosting using PHP
TRUNG VU
TRUNG VU

Posted on

Creating symbolic link in a shared hosting using PHP

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:)

Top comments (1)

Collapse
 
sadiazia profile image
Sadia Zia

I ditched shared hosting for managed cloud hosting because the prior had so many limitations. As a web developer who is managing a lot of clients at a time, I had to choose the best hosting that offered the choice of having unlimited websites on one platform. I tried out a 3 day free trial offered by Cloudways and was mindblown with the user-friendliness of the platform. It’s been 8 months and I am super satisfied with Cloudways performance, my website’s speed, and the flexibility I get to scale the serve according to my needs. When it comes to hosting, I always look for a pay as you go model and Cloudways luckily has the same. I am never going back to shared hosting again.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.