Skip to main content
Hosting How-To

How to create a symbolic link in cPanel – Hosting

By May 21, 2021No Comments

Symlinks, small for symbolic links, are basically shortcuts to personal information or folders. Just one of the benefits of a symlink is that it can cross filesystems, as it references summary filenames/directories and not bodily destinations.

There is a variety of methods to build a symlink in cPanel:&#13
&#13

1. You can make a symlink via SSH by running the following command:&#13
&#13

 ln -s /route/to/goal /path/to/shortcut&#13
&#13

2. It can also be made via a cronjob employing the exact same command:&#13
&#13

Note: Make absolutely sure that you delete the cronjob the moment the symlink has been developed.&#13
&#13
&#13

3. You can also create a symlink making use of the PHP functionality.

The illustration of the script can be located below:&#13
&#13

$target=”/home/cPanelusername/public_html/index.html”&#13

$shortcut=”script.html”&#13

symlink($target, $shortcut)&#13

?>

Just operate this PHP file in the browser and it will produce symlink correct away. &#13
&#13

Instance of the symlink utilization

A symlink may well be a perfect resolution for a range of cases. In our example we will use a symlink in buy to use visuals situated in the primary domain world-wide-web root (/general public_html/) for the addon area website (/general public_html/area1.com):

Considering that the addon domain site does not have entry to /public_html or any bigger degree directory, the only way to use images located in the /community_html/pictures folder is to make a symlink in the addon area folder:&#13

ln -s /property/ncexample/general public_html/visuals/ /home/ncexample/public_html/domain1.com/photos&#13
&#13

As you can see, symlinks will help you to avoid duplicate material if you use the very same documents for numerous websites.&#13
&#13
&#13

Observe: Producing symlinks to root directories of other internet sites may result in significant safety breaches, that’s why we hugely advocate utilizing symlinks only for all those folders that do not expose any config or program documents, as, if acquired, this kind of documents may possibly be utilized for hacking or other destructive action.&#13
&#13
&#13
&#13
&#13

Which is it!

                       Require any support? Get hold of us by using HelpDesk

Leave a Reply