Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
190 views
in Technique[技术] by (71.8m points)

linux - 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

question from:https://stackoverflow.com/questions/65945256/how-can-i-link-the-mounted-folder-to-laravel-project

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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/

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...