久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

同一臺服務器上的兩個 Laravel 應用程序相互沖突

Two Laravel applications on the same server conflicting with one another(同一臺服務器上的兩個 Laravel 應用程序相互沖突)
本文介紹了同一臺服務器上的兩個 Laravel 應用程序相互沖突的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我在同一臺服務器上運行了 2 個 Laravel 應用程序.服務器是 Apache 2.4,我設置了虛擬主機來為不同域上的每個應用程序提供服務.

I have 2 Laravel applications running on the same server. The server is Apache 2.4 and I have vhosts set up to serve each application on a different domain.

第一個應用程序是一個 API,它的 .env 文件設置如下:

The first application is an API and it's .env file is set up like this:

APP_ENV=production
APP_KEY=YYYYYYYYYYYYYYYYYY
APP_DEBUG=false
APP_LOG_LEVEL=debug
APP_URL=https://notify.mysite.com
APP_DOMAIN=notify.mysite.com


DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=notify
DB_USERNAME=YYYYYYYYYYYYYYYYYY
DB_PASSWORD=YYYYYYYYYYYYYYYYYY

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

第二個應用程序是一個 UI,其中使用了第一個應用程序的 API.它的 .env 文件是這樣設置的:

The second application is a UI that among other things, utilizes the API from the first application. Its .env file is set up like this:

APP_ENV=local
APP_KEY=XXXXXXXXXXXXXX
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=https://asapps.mysite.com
APP_DOMAIN=asapps.mysite.com
APP_VERSION=1


DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=asapps
DB_NOTIFY_DATABASE=notify
DB_FLIGHT_DATABASE=flights
DB_USERNAME=XXXXXXXXXXXXXX
DB_PASSWORD=XXXXXXXXXXXXXX

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

我可以從 Swagger 編輯器、Postman 和其他服務器向我的 API 發送消息,一切都按預期進行.

I can send messages to my API from my Swagger editor, from Postman, and from other servers and everything works as expected.

我的第二個應用程序本身也按預期工作.

My second application by itself also works as expected.

但是,如果我的第二個應用程序向 API 發送請求,則 API 應用程序會拋出此錯誤:

However, if my second application sends a request to the API, the API application throws this error:

帶有消息SQLSTATE[42S02]"的異常PDOException":未找到基表或視圖:1146 表asapps.preprocessor_config"不存在"在 C: otifyvendorlaravelframeworksrcIlluminateDatabaseConnection.php:332

exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'asapps.preprocessor_config' doesn't exist' in C: otifyvendorlaravelframeworksrcIlluminateDatabaseConnection.php:332

什么?

API 的數據庫設置為DB_DATABASE=notify,當我從其他服務器發送消息時,它肯定會正確使用該連接.那么為什么要嘗試使用第二個應用程序的數據庫當我從該應用程序調用 API 時連接???它幾乎就像在緩存數據庫連接并試圖繼續使用相同的連接......我該如何阻止?

The database for the API is set to DB_DATABASE=notify and it definitely does properly use that connection when I send messages from other servers. So why the heck is it trying to use the second application's database connection when I call the API from that app??? Its almost like it's caching the DB connection and trying to keep using that same one.... How do I stop that?

表'asapps.preprocessor_config'不存在'

Table 'asapps.preprocessor_config' doesn't exist'

推薦答案

經過更多的挖掘(閱讀瘋狂的谷歌搜索),我找到了 問題和解決方案在這里

After more digging (read frantic googling), I found the problem and solution here

最重要的是,當站點 A 接受請求時,php 會在 http 請求的整個長度內加載它的 .env 變量.在該請求期間,當站點 A 調用站點 B 時,由于它們在運行相同 php 的同一臺服務器上,php 仍在使用站點 A 的 .env 并且根本不單獨加載站點 B 的 .env 文件.

The bottom line, when site A accepts a request, php loads it's .env variables for the entire length of the http request. During that request, when site A calls site B, since they are on the same server running the same php, php is still using the .env from site A and does not separately load site B's .env file at all.

作者更好的解釋:

創建了包含變量的 .env 文件,這樣人們就不會將他們的憑據推送到 github 存儲庫和其他可能共享源的地方.

The .env file with the variables was created so that people would not push their credentials to github repositories and other places where they may share the source.

現在,作為環境變量,它們在 http 請求的整個持續時間內(在本例中為腳本執行)成為系統范圍內的變量.關鍵是你有一個長時間運行的腳本.

Now, being environment variables they become system wide for the entire duration of the http request (in this case script execution). The point is that you got a long running script.

要找到最終解決方案,您可以采用以下三種方法之一.

To find a definitive solution you could go one of the three ways.

....

'namespace' ENV 變量.

'namespace' the ENV variables.

這篇關于同一臺服務器上的兩個 Laravel 應用程序相互沖突的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

add new element in laravel collection object(在 Laravel 集合對象中添加新元素)
Creating an edit modal in Laravel 5(在 Laravel 5 中創建編輯模式)
Laravel 5.5 API resources for collections (standalone data)(用于集合的 Laravel 5.5 API 資源(獨立數據))
What is the best practice to create a custom helper function in php Laravel 5?(在 php Laravel 5 中創建自定義輔助函數的最佳實踐是什么?)
No #39;Access-Control-Allow-Origin#39; header - Laravel(沒有“Access-Control-Allow-Origin標頭 - Laravel)
Laravel Passport Route redirects to login page(Laravel Passport Route 重定向到登錄頁面)
主站蜘蛛池模板: 欧美在线不卡 | 久久成人人人人精品欧 | 日韩中文字幕视频在线观看 | 国产二区三区 | 色婷婷九月 | 久久久久国产精品www | 91在线一区二区三区 | 中文字幕99 | 亚洲精品视频在线观看免费 | 亚洲高清在线 | 国产一区二区电影网 | 综合色婷婷 | 久久av一区二区三区 | 黄色片免费看 | 久久福利电影 | 国产精品久久久久久久免费大片 | 日韩中文字幕视频在线 | 精品一级| 在线免费黄色小视频 | 欧美午夜一区二区三区免费大片 | 欧美男人天堂 | 成人国产精品久久久 | 亚洲精品一区二三区不卡 | 自拍视频国产 | 亚洲一区在线观看视频 | 日韩一区二区在线播放 | 亚洲成人天堂 | 亚洲精品日韩视频 | 国产亚洲一区二区三区在线 | 作爱视频免费看 | 亚洲精品 在线播放 | 中文字幕亚洲免费 | 国产精品美女久久久久久久久久久 | 久久久久久亚洲精品 | 欧美日韩亚洲国产综合 | 91文字幕巨乱亚洲香蕉 | 国产精品96久久久久久 | 男女免费在线观看视频 | 欧美日韩一区二区三区视频 | 欧美黄色绿像 | 成人免费福利视频 |