Storage in laravel says symlink - no such file

后端 未结 12 1943
离开以前
离开以前 2020-12-07 22:39

I deployed laravel app on shared hosting in public_html/app folder. Here is everything from public folder. In /../../files I have rest of files. When I do php artisan storag

相关标签:
12条回答
  • 2020-12-07 23:20

    Just in case your down here still without an answer.

    I had trouble because I did the symlink locally, then copied the files to the server. In order to make it work I did the following:

    $  cd path/to/laravel/root
    
    // if public does not exist, first create it.
    $  cd public
    
    // if public/storage does not exist, first create it.
    $  rm -r storage
    
    $  cd ..
    
    // Now it should work
    $  php artisan storage:link 
    
    0 讨论(0)
  • 2020-12-07 23:23

    I'm face same error when use share hosting and my public directory move to public_html or different directory like : project directory in root name "project" and public directory in root name "public_html"

    when run artisan command by Artisan::call('storage:link'); then face this error.

    Solution: 1st need to bind your public directory in app/Providers/AppServiceProvider register method

     $this->app->bind('path.public', function() {
        return base_path('../public_html');
     });
    

    Now run the command its working fine

    0 讨论(0)
  • 2020-12-07 23:27

    Go to config/filesystem.php in the symbolic links section in my case I removed public_path function and wrote my own path in it then run php artisan storage:link command again.

     'links' => [
        '/var/www/storage' => storage_path('app/public'),
    ],
    

    Worked for me.

    0 讨论(0)
  • 2020-12-07 23:28

    Make sure the APP_URL configuration in .env file is set correctly. after that run following command line:

    php artisan config:cache
    php artisan storage:link
    
    0 讨论(0)
  • 2020-12-07 23:28

    My problem was that te symlink not was placed in /localhost/public/ but in /localhost/storage/app/ When i removed the symlink in /localhost/storage/app/ the artisan command works like a charm

    In my code i placed this to prevent creating the wrong symlink

    Route::get('/clear', function () {
        Storage::deleteDirectory('public');
        Storage::makeDirectory('public');
    
        Artisan::call('route:clear');
        Artisan::call('storage:link', [] );
    });
    
    0 讨论(0)
  • 2020-12-07 23:29
    1. Go to /public directory and run:

      rm storage

    2. Go to Laravel root directory and run:

      php artisan storage:link


    Edited on May 1st 2018

    This problem comes when laravel project is moved/copied to some other folder.

    The storage link is still there thus causing the exception error. public/storage folder exists and points to wrong location and it needs to be deleted with rm storage command.

    After that run php artisan storage:link in terminal and it will create the storage link.

    This needs to be done EVERY time when laravel is moved/copied/deployed!

    0 讨论(0)
提交回复
热议问题