DEV Community

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

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/';
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:
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 (2)

victorrims68524 profile image
Rimsha Victor Gill

Thank you for providing guidance on creating a symbolic link in a PHP hosting environment! PHP hosting offers more flexibility and control compared to shared hosting, making it an excellent choice for projects like Laravel.

Your clear and concise steps have empowered anyone to set up their symbolic link and leverage the benefits of PHP hosting. Having this increased control over the server environment allows to optimize performance and security for any Laravel project.

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.