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

部署含Per-project Homestead的Laravel项目至共享主机:文件复制与排除咨询

Hey there! Let's break down exactly what you need to upload to your shared host, and what you can safely leave behind when deploying your per-project Homestead Laravel app.

What to Upload to Your Shared Host

These are the core files and folders your Laravel app needs to run in production:

  • app/: Your entire application logic (controllers, models, middleware, etc.) lives here—don't skip this.
  • bootstrap/: Contains framework bootstrapping files and cached config/routes. Even if some cache folders are empty, the base structure is required.
  • config/: Your app's base configuration files (production-specific values will come from your .env file, but these base files are still needed).
  • database/: Migration files (critical if you need to run database setup on the host) and seed files (optional but useful for populating default data).
  • public/: This is your web server's document root—it includes the index.php entry point, compiled frontend assets (CSS/JS/images), and any static files your app serves.
  • resources/: View templates, language files, and raw frontend assets (if you haven't compiled them locally). At minimum, the views/ and lang/ subfolders are mandatory.
  • routes/: All your app's route definitions (web, API, console)—core to how your app handles requests.
  • storage/: Stores logs, cached data, user uploads, and framework-generated files. Make sure to set proper write permissions on this folder (and its subfolders) on your shared host—Laravel needs to write here.
  • vendor/: All Composer-installed dependencies. Unless your host allows running composer install (most shared hosts don't), you'll need to install these locally and upload the entire folder.
  • .env: Your production-specific configuration file (create a new one for production—don't use your local .env.example). Set APP_ENV=production and APP_DEBUG=false here for security.
  • artisan: Laravel's command-line tool—useful for running migrations, clearing caches, or other maintenance tasks on the host.
  • composer.json & composer.lock: These help track dependencies; useful if you ever need to update packages on the host (if allowed).
What You Can Safely Exclude

These files/folders are only for local development (Homestead/Vagrant/Git/testing) and have no place on your production server:

  • .vagrant/: Local Vagrant VM state files—completely irrelevant to production.
  • tests/: All your unit/feature test code—production doesn't need to run tests.
  • .env.example: A template for local environment configs; production uses your custom .env.
  • .gitattributes & .gitignore: Git repository configuration files—only needed if you're using Git locally.
  • after.sh, Homestead.yaml, Vagrantfile: Homestead/Vagrant-specific setup files—these are for your local dev environment only.
  • .git/: Your local Git repository folder—never upload this to production.
  • node_modules/: Frontend development dependencies (like npm packages). Once you've compiled your frontend assets to public/, this folder is redundant.
  • package.json, package-lock.json, webpack.mix.js: If you've already compiled frontend assets locally, these can be excluded. Only keep them if you need to compile assets on the host (unlikely on shared hosts).
  • phpunit.xml: PHPUnit test configuration—useless in production.
  • server.php: Local development server entry point—your shared host uses public/index.php instead.
Quick Deployment Tips
  • Double-check permissions on storage/ and bootstrap/cache/—most shared hosts require these folders to be writable (usually chmod 755 or 775, depending on the host's setup).
  • After uploading, run php artisan config:cache and php artisan route:cache via SSH (if your host allows) to optimize performance for production.
  • Never expose your .env file to the web—most shared hosts configure the document root to point to public/, which keeps .env safe by default.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 08:11:54