Laravel环境文件未加载 [英] Laravel env file is not loading

查看:90
本文介绍了Laravel环境文件未加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将laravel项目从本地服务器移到了生产服务器centos vps. 我面对的奇怪的事情是laravel无法从.env文件读取,并且我已经测试了所有方法以使其正常运行,但没有成功.

I have moved my laravel project from local to production server which is centos vps. Strange thing I'm facing is laravel can't read from .env file, And I have tested everything to make it work but no success.

我已将其权限设置为777,并将其所有者设置为vps的所有者.

I have set it's permission to 777 and it's owner to the owner of vps.

仍然没有成功.

仅供参考:它在gitignore中,但是我已经在服务器上创建了.env文件,因此此问题与gitignore无关.

FYI : it is in gitignore but I have created .env file on server so this problem has nothing to do with gitignore.

有人可以引导我逐步在生产服务器上运行laravel吗? 到底应该做什么,我需要执行什么命令,应该在哪里放置项目,应该在哪里放置公共目录文件?

Can someone walk me through step by step running laravel on production server? Exactly what should be done and what commands do I need to execute, where should I put project and where should put public directory files ?

请帮帮我.

推荐答案

在生产环境中,您应该从不拥有.env文件.而是创建适当的环境变量,PHP将从那里读取它们.

In production environments you should never have a .env file. Instead, create the appropriate environment variables and PHP will read them from there.

摘自DotEnv官方文档:

Taken from the official DotEnv docs:

phpdotenv用于开发环境,通常应该 不可用于生产.在生产中,实际环境 应该设置变量,以免加载 每个请求上的.env文件.这可以通过自动完成 使用Vagrant,chef或Puppet之类的工具进行部署过程,或者可以 通过Pagodabox和Heroku等云主机手动设置.

phpdotenv is made for development environments, and generally should not be used in production. In production, the actual environment variables should be set so that there is no overhead of loading the .env file on each request. This can be achieved via an automated deployment process with tools like Vagrant, chef, or Puppet, or can be set manually with cloud hosts like Pagodabox and Heroku.

这篇关于Laravel环境文件未加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆