Symbolic links (symlinks) in cpanel

A symbolic link (known as soft link or symlink), is a special file that points to another file, similar to a shortcut in Windows or a Mac OS alias. Symbolic links do not contain the data in the target file (unlike the hard links) but simply point to another entry in your file system.

There are two ways to create symlink in cPanel:

  1. It can be created via cronjob using the command:

ln -s /path/to/target /path/to/shortcut

NOTE: make sure to delete the cronjob once the symlink has been created.

  1. You can also create symlink using PHP function.

The example of the script can be found below:

<?php

$target = ‘/home/cPanelusername/public_html/index.html’;

$shortcut = ‘script.html’;

symlink($target, $shortcut);

?>

Just run this PHP file in the browser and it will create symlink right away.

 

Was this article helpful?

Related Articles

Leave A Comment?