Two Laravel projects on same server causing conflict

馋奶兔 提交于 2019-12-23 02:34:47

问题


I have two Laravel 5.1 projects on a same server. Operating on a single project is not giving me any troubles, but if I open the two projects on two browser tabs and alternate between them, I receive

The server encountered an internal error or misconfiguration and was unable to complete your request.

Made a research and found out that the server is remembering the first opened project .env file and tries to use it for the project B, which is causing the issue. The question is - how to solve this problem, without changing the server for one of my projects?


回答1:


I have come across this error before in my environments.

This is generally caused by the webserver process running as the same user for both of the projects. As the .env file is loaded for the running user, when you run two projects under the same user, the .env files are loaded for both projects and the variables keep overwriting each other in the user environment.

The solution is to rename the variables in your .env and config files (and everywhere else you use env() function).

PROJECT1_APP_KEY=foo

and then

app_key => env(PROJECT1_APP_KEY, '')

in your config.



来源:https://stackoverflow.com/questions/43789681/two-laravel-projects-on-same-server-causing-conflict

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!