Skip to content
Advertisement

How can i link the mounted folder to Laravel project?

I have a Laravel project, which placed here:

/home/user/www/example.com

We attached a new storage to vds and mounted it for

/home/user/www/storage

folder.

After that we need add symbolic link from /home/user/www/storage to /home/user/www/example.com/storage , but we can not do it, because the last one is already exists and contains needed files.

How can we link it for more space to storage folder in the project?

terminal output:

ln -s /home/user/www/storage /home/user/www/example.com/
ln: failed to create symbolic link '/home/user/www/example.com/storage': File exists

Advertisement

Answer

Option 1

You can link it to another place inside the storage folder and create a separate disk

$ ln -s /home/user/www/storage/more-space /home/user/www/example.com/

Inside your config/filesystem.php you can add an additional disk

// config/filesystem.php
'disks' => [
  'more-space' => [
    'local' => [
        'driver' => 'local',
        'root' => storage_path('more-space'),
    ],
  ]
]

and work with it Storage::disk('more-space').

Option 2

  1. You move everything that is inside your current storage folder into your new folder /home/user/www/example.com/
  2. Remove your storage folder with rm -rf /home/user/www/storage
  3. Symlink the new folder ln -s /home/user/www/storage /home/user/www/example.com/
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement