问题
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