在不重新启动服务器的情况下重载.env变量(Laravel 5,共享主机) [英] Reloading .env variables without restarting server (Laravel 5, shared hosting)

查看:264
本文介绍了在不重新启动服务器的情况下重载.env变量(Laravel 5,共享主机)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Laravel 5运行正常,直到配置了数据库,然后发现此错误:

My Laravel 5 has run OK until the database was configured, then found this error:

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

进行一些研究,看来我配置MySQL访问为时已晚,所以我应该重新启动服务器以获取正确的环境变量.好吧,我正在使用Dreamhost的共享服务器,但我做不到.

Doing some research it seems that I configured MySQL access too late, so I should restart the server in order to get the correct environment variables. Well, I'm using Dreamhost's shared server and I just can't do that.

我应该如何解决此问题?

How should I fix this issue?

谢谢

推荐答案

config/database.php中,我将默认的数据库连接从mysql更改为sqlite.我删除了.env文件(实际上已将其重命名),并使用touch storage/database.sqlite创建了sqlite文件.迁移使用了sqlite.

In config/database.php I changed the default DB connection from mysql to sqlite. I deleted the .env file (actually renamed it) and created the sqlite file with touch storage/database.sqlite. The migration worked with sqlite.

然后,我将config/database.php的默认数据库连接切换回mysql,并恢复了.env文件.迁移是在mysql上完成的.

Then I switched back the config/database.php default DB connection to mysql and recovered the .env file. The migration worked with mysql.

我猜这没有任何意义.也许是服务器端的东西.

It doesn't make sense I guess. Maybe was something serverside.

这篇关于在不重新启动服务器的情况下重载.env变量(Laravel 5,共享主机)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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