Reputation: 115
I am using Laravel 7 on Direct admin. I don't actually have access to Command Line/Terminal, and I need a Symbolic link of Storage.
I have Tried:
Route::get('/foo', function () {
Artisan::call('storage:link');
});
and also:
symlink('/domains/MyProject.com/LaravelFolder/storage/app/public', '/domains/MyProject.com/public_html');
But I am receiving this Error:
symlink() has been disabled for security reasons
My LaravelFolder is Placed before public_html.
UPDATE: I realized that the Hosting company disabled this function; I asked them to enable it, But They say: it is impossible. Do you know an alternative way to do that?
Upvotes: 2
Views: 2564
Reputation: 115
Old Solution
But I finally Solved This, It seems little bit stupid but it works:
In Ubuntu Linux I tried to create a symlink like the storage symbolic link in Laravel, with the following Command:
ln -s ../laravelFolder/storage/app/public storage
and then I compressed this symbolic link and uploaded to my public_html Folder and it works. I hope it will be Helpful..
2022 UPDATE (New Solution)
In such cases that your projects production environment is a Linux server and you are developing your project on Windows I offer you to set up a WSL (Windows Subsystem for Linux) development environment.
This way you can simply use Linux terminal to creating a symbolic link with the following command:
// change laravelFolder with your laravel folder name
ln -s ../laravelFolder/storage/app/public storage
Here is Microsoft's quick guide to install and use WSL.
Upvotes: 3
Reputation: 885
You can modify the public
disk's root path to point directly public folder. Consider the below snippet;
/** /config/filesystems.php */
'disks' => [
// ...
'public' => [
'driver' => 'local',
'root' => public_path('storage'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
// ...
],
Note that this is not a best practice.
Upvotes: 1