How to create laravel storage symbolic link for production or sub domain system?

前端 未结 6 695
天涯浪人
天涯浪人 2021-02-04 02:41

When I worked on laravel local development server php artisan storage:link works fine for me. But when I transfer my site to production server then I saw my public

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-04 03:23

    In case anyone is looking for another flexible solution using php:

    Route::get('/link', function () {        
       $target = '/home/public_html/storage/app/public';
       $shortcut = '/home/public_html/public/storage';
       symlink($target, $shortcut);
    });
    

    And make any required change to the $target variable and the $shortcut upon your files structure.

    You can use the above code inside that web route or inside any other function.

提交回复
热议问题