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

Laravel Envoyer部署:能否将当前版本公共路径文件复制到新版本?

Absolutely! You've hit on a common scenario with Laravel + Envoyer deployments, and there are two solid ways to handle preserving user-uploaded files like those in public/uploads:

Envoyer has a built-in feature specifically for this kind of persistent content—shared directories. Instead of copying files between releases, this method creates a symlink from each deployment's public/uploads to a single shared directory that lives outside the release folders. Here's how to set it up:

  • Head to your project in Envoyer, then navigate to Settings > Shared Folders & Files
  • Add public/uploads to the list of shared paths
  • Save the settings. On your next deployment, Envoyer will automatically:
    1. Create shared/public/uploads if it doesn't exist
    2. Symlink your new release's public/uploads to the shared directory
  • From then on, all releases will use the same shared uploads directory—no copying needed, and files persist across deployments automatically.

2. Custom Deployment Script to Copy Files

If you specifically need to copy files (rather than use symlinks), you can add a custom hook to your deployment workflow. Here's how:

  • Go to your project in Envoyer, then go to Deployment Hooks
  • Choose the stage where you want the copy to run—Before Activate New Release is a good spot (so files are in place before the new version goes live)
  • Add a bash script like this:
# Copy uploads from the current live release to the new release
cp -R {{ release }}/../current/public/uploads/* {{ release }}/public/uploads/

# Optional: Ensure correct file permissions for the web server
chown -R www-data:www-data {{ release }}/public/uploads

A quick breakdown of the variables:

  • {{ release }} is an Envoyer variable that points to the directory of the new release being deployed
  • ../current navigates to the symlink pointing to your currently active live release

A Quick Note on Which to Choose

The shared directory method is almost always better—it's faster (no file copying overhead), cleaner, and aligns with how Envoyer is designed to handle persistent assets. Copying files works, but can slow down deployments if you have a lot of uploads, and introduces more points where permissions or file conflicts could pop up.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 09:48:06