Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

farshadf's avatar

how to force laravel not read the storage files from symlink

i am hosting my laravel on an cpanel that not sups symlink so when i run storage:link i get this error :

symlink() has been disabled for security reasons

when i contacted my provider they told me that they cant open it but i have to make changes in my file system to read from the storage it self . now my question is how can i change the config/filesystem.php to not read from symlink but the storage folder it self . thanks in advance

0 likes
2 replies
farshadf's avatar

You have a couple options.

If you have access to the command line, you can attempt to manually create the symlink yourself. It's possible they disabled the PHP symlink() command, but the OS ln command may still be available to you. From the command line:

ln -s /path-to-project/storage/app/public /path-to-project/public/storage

If you don't have access to the command line, you can attempt to run the command from PHP using one of the program execution methods (exec(), shell_exec(), etc.). However, if they've disabled symlink(), they've probably disabled all of those, as well. To attempt this, create a temporary route, hit it once, then delete it:

Route::get('temp-create-link', function () {
    exec("ln -s ".escapeshellarg(storage_path('app/public')).' '.escapeshellarg(public_path('storage')));
});

If you don't have a way to run the ln command, or if it has been disabled at the OS level, then you'll need to manually create your public/storage folder and update your filesystem config to point to it. Once you've created the public/storage folder, open your config/filesystems.php file and update the root key for your public disk to point to it:

'disks' => [

    // ...

    'public' => [
        'driver' => 'local',
        // old value: 'root' => storage_path('app/public'),
        'root' => public_path('storage'),
        'url' => env('APP_URL').'/storage',
        'visibility' => 'public',
    ],

    // ...

],

Please or to participate in this conversation.