php Laravel 5.3。如何配置生产环境?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39690819/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 01:58:51  来源:igfitidea点击:

Laravel 5.3. How to configure a production environment?

phplaravelproduction-environmentproductionlaravel-5.3

提问by Maximiliano Sosa

I got started with Laravel 5.3 and I got my development environment working on local, but now I need to upload the app to production server. I cant found nothing about configuring two environments on same app.

我开始使用 Laravel 5.3,我的开发环境在本地工作,但现在我需要将应用程序上传到生产服务器。我找不到关于在同一个应用程序上配置两个环境的任何信息。

I use Apache web server on both (local and production).

我在(本地和生产)上都使用 Apache Web 服务器。

Any guide/doc is well received!

任何指南/文档都受到好评!

采纳答案by Root -

The docs(as pointed by Marcin) suggest to use the .env file to configure your environment. Different environments = different .env files. Thus, on local machine you'd have an .env file with your local enviroment configuration, and on production you'd have a different .env file, and a diffrent one for staging, and so on... APP_ENV=production

文档(马尔辛为指向)建议使用.ENV文件来配置你的环境。不同的环境 = 不同的 .env 文件。因此,在本地机器上,你会有一个带有本地环境配置的 .env 文件,而在生产中你会有一个不同的 .env 文件,一个不同的用于暂存,等等......APP_ENV=production

Which can be brought forth with App::environment()

哪个可以带来 App::environment()

Remember to exclude the .env from versioning, cheers.

请记住从版本控制中排除 .env,干杯。

回答by user3856437

Better to follow this blog:

最好关注这个博客:

https://devmarketer.io/learn/deploy-laravel-5-app-lemp-stack-ubuntu-nginx/

https://devmarketer.io/learn/deploy-laravel-5-app-lemp-stack-ubuntu-nginx/

With that blog, if you're not using Nginx but Apache, that's fine because we are more concerned with the Laravel configuration and permissionings on files and folders than the web server.

有了那个博客,如果你不使用 Nginx 而是使用 Apache,那很好,因为我们更关心 Laravel 配置和文件和文件夹的权限,而不是 Web 服务器。