You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行Voyager安装命令遇symlink权限拒绝错误,安装后无图片求助

Hey there, let's tackle this issue you're facing. That symlink(): Permission denied error pops up because Laravel can't create the required symbolic link between public/storage and storage/app/public—and without that link, Voyager can't serve the images stored in your storage/app/public directory, which is exactly why your media isn't showing up. Let's walk through the most reliable fixes:

The simplest fix is to create the link yourself via terminal, since the artisan command might be running under a user that doesn't have the right permissions (like your server's web user vs. your terminal user).

For Linux/macOS:

Navigate to your project's root directory and run this command:

ln -s ../storage/app/public public/storage

For Windows (Command Prompt):

mklink /d public\storage ..\storage\app\public

For Windows (PowerShell):

New-Item -ItemType SymbolicLink -Path "public\storage" -Target "..\storage\app\public"

After creating the link, double-check the permissions on your storage folder and the new public/storage link. Set them to something like:

chmod -R 755 storage public/storage
chown -R www-data:www-data storage public/storage

(Note: Replace www-data with your server's web user—this might be apache on some systems, or your hosting provider's specific user.)

If you don't have terminal access to your server, you can temporarily add a route to create the link for you:

  1. Open routes/web.php and add this code:
Route::get('/create-storage-link', function () {
    $targetPath = storage_path('app/public');
    $linkPath = public_path('storage');

    if (file_exists($linkPath)) {
        return 'Storage link already exists!';
    }

    symlink($targetPath, $linkPath);
    return 'Storage link created successfully!';
});
  1. Visit your site's URL followed by /create-storage-link (e.g., https://yourdomain.com/create-storage-link).
  2. Once you see the success message, delete this route immediately—it's a security risk to leave it accessible.

If symlinks aren't an option (some shared hosts block them), you can tweak Laravel's filesystem config to serve images directly:

  1. Open config/filesystems.php and find the public disk configuration. Update it to:
'public' => [
    'driver' => 'local',
    'root' => storage_path('app/public'),
    'url' => env('APP_URL') . '/storage',
    'visibility' => 'public',
],
  1. Then, create a public/storage folder manually and copy all existing images from storage/app/public into it. Keep in mind—any new images uploaded via Voyager will go to storage/app/public, so you'll need to sync these folders regularly (or set up an automated script to handle this).

Once you've implemented one of these fixes, clear your Laravel cache just to be safe:

php artisan cache:clear

Your Voyager images should start showing up right away!

内容的提问来源于stack exchange,提问作者Brendan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 04:09:59