【问题标题】:What folders and files from Laravel project are required to be deployed to the server?需要将 Laravel 项目中的哪些文件夹和文件部署到服务器?
【发布时间】:2019-12-10 04:29:56
【问题描述】:

我有服务器,上面运行着 Laravel 项目。但是该项目仅包含原始 Laravel 项目(本地版本)中的一小部分文件和文件夹。两者(本地和部署)都可以正常工作。

这是我在服务器上的部署版本:

(app)
(bootstrap)
(config)
(public)
(resources)
(storage)
(vendor)
.env
appspec.yml
artisan

这是我在本地拥有的,作为开发版本:

(.git)
(app)
(bootstrap)
(config)
(database)
(public)
(resources)
(storage)
(tests)
(vendor)
.env.example
.env
.gitattributes
.gitignore
artisan
composer.json
composer.lock
gulpfilejs
package.json
phpspec.yml
phpunit.xml
readme.md
zserver.php

例如,目前服务器上没有“数据库”文件夹。部署的项目不需要迁移、工厂或种子。

那么,我想知道 Laravel 项目是否有推荐或需要的文件夹和文件列表,以便部署它?

【问题讨论】:

  • 你想达到什么目的?
  • 我需要知道什么应该在服务器上,什么不应该在服务器上。

标签: laravel apache nginx deployment web-deployment


【解决方案1】:

在项目中,您有一个名为 .gitignore 的文件,在此文件中,您将被告知当您上传到服务器时应该跳过哪些文件夹或文件,如果您明显使用 git,则更多信息。我总是忽略这一点:

/ node_modules
/ public / hot
/ public / storage
/storage/*.key
/ vendor
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log

然后我使用服务器所需的配置上传一次 .env 文件,然后我还将它包含在 .gitignore 中,一旦上传到服务器,您将必须执行以下命令:composer update、php artisan migrate 和所有必要的,以便您的项目在服务器上正常工作。

【讨论】:

  • 供应商仍然应该在服务器上,只是不在 git 中。 node_modules 和您的资产也是如此。
猜你喜欢
  • 2020-03-11
  • 1970-01-01
  • 2020-11-06
  • 2017-08-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多