同一服务器上的两个Laravel项目导致冲突 [英] Two Laravel projects on same server causing conflict

查看:372
本文介绍了同一服务器上的两个Laravel项目导致冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一服务器上有两个Laravel 5.1项目.在单个项目上进行操作不会给我带来任何麻烦,但是如果我在两个浏览器选项卡上打开两个项目并在两个选项卡之间切换,则会收到

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.

进行了研究,发现服务器正在记住第一个打开的项目.env文件,并尝试将其用于项目B,这引起了问题.问题是-如何在不更改我的一个项目的服务器的情况下解决此问题?

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?

推荐答案

在我的环境中,我曾经遇到过此错误.

I have come across this error before in my environments.

这通常是由于两个项目的Web服务器进程以同一用户身份运行而引起的.当为正在运行的用户加载.env文件时,当您在同一用户下运行两个项目时,将同时为两个项目加载.env文件,并且变量在用户环境中保持彼此覆盖.

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.

解决方案是重命名.env和config文件(以及其他所有使用env()函数的位置)中的变量.

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

PROJECT1_APP_KEY=foo

然后

app_key => env(PROJECT1_APP_KEY, '')

在您的配置中.

这篇关于同一服务器上的两个Laravel项目导致冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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