【问题标题】:Multiple Laravel Site conflicting in Apache with MSSql and Redis on Apache serverApache 中的多个 Laravel 站点与 Apache 服务器上的 MSSql 和 Redis 冲突
【发布时间】:2020-10-23 20:57:48
【问题描述】:

我在同一个服务器上托管了两个 Laravel 应用程序。

例如。 dev.example.com 和 staging.example.com 这两个站点都提供了可供 VUEJS 站点 devfh.example.com 和 stagingfh.example.com 访问的 API。 这两个站点都运行良好,但是,偶尔/随机我们会在开发站点中获取暂存数据并在暂存站点中获取开发数据。

我们正在使用以下技术栈:

  • Apache 3.2.2.2
  • PHP 7.3.12
  • 适用于 MSSQL 的 AWS RDS(两个数据库开发和暂存在同一个实例上)
  • Redis 用于存储会话缓存(我们尝试禁用 Redis 缓存 开发网站问题仍然存在)。

我觉得这可能是 Apache、Redis 或 MSSql 端的缓存问题,或者可能是 PHP OpCode 缓存不确定。

我们不确定如何进一步调试此问题。

Apache 虚拟主机设置

<VirtualHost *:80>
    ServerName stagingfh.example.com
    DocumentRoot "c:/wamp64/www/staging/frontend/dist"
    <Directory  "c:/wamp64/www/staging/frontend/dist/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
        Header unset ETag
        Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
        Header set Pragma "no-cache"
        Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</VirtualHost>

<VirtualHost *:80>
    ServerName staging.example.com
    DocumentRoot "c:/wamp64/www/staging/backend/public"
    <Directory  "c:/wamp64/www/staging/backend/public/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName devfh.example.com
    DocumentRoot "c:/wamp64/www/staging/development/dist"
    <Directory  "c:/wamp64/www/staging/development/dist/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
        Header unset ETag
        Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
        Header set Pragma "no-cache"
        Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</VirtualHost>

<VirtualHost *:80>
    ServerName dev.corigami.com
    DocumentRoot "c:/wamp64/www/staging/development/public"
    <Directory  "c:/wamp64/www/staging/development/public/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

【问题讨论】:

  • 您能否提供更多有关服务器设置和站点部署方式的详细信息?是手动部署还是自动部署?是否有可能正在为一个 API 编译 Vue 代码但部署到错误的域?默认情况下会话应该是分开的,如果域设置正确,我认为浏览器缓存不会成为问题,但是当这种情况发生时,可以尝试在浏览器中进行硬刷新,看看是否可以识别问题?跨度>
  • @Spudly 所有四个站点都配置在 apache 虚拟主机中,两个 VueJs 站点分别编译,冲突随机发生,比如说当我们访问站点时它正在工作我们导航到另一个页面我们得到另一个站点数据,我们再次导航并获得正确的站点数据
  • @Spudly 站点托管在 AWS EC2 Windows 服务器上,其技术堆栈定义为问题

标签: php sql-server laravel apache redis


【解决方案1】:

如果它在页面之间导航时自行解决,这听起来像是浏览器缓存问题。

你是否使用 Mix 来编译 Vue 代码?确保您使用 version() 以防止共享脚本可能相互冲突的缓存问题。

https://laravel.com/docs/7.x/mix#versioning-and-cache-busting

mix.js('resources/js/app.js', 'public/js')
    .version();

如果这不起作用,你也可以尝试运行这些命令来清除 Laravel 缓存。

php artisan clear-compile
php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan cache:clear

【讨论】:

  • 我们没有使用 Mix,我们的 Vue 应用在 laravel 之外
  • 另外,浏览器缓存也不是问题,因为对于从未使用过开发站点的人来说,我们也面临这个问题
  • 为什么推荐cache:clear?如果您截断 @DharmeshCorigami 的整个 redis 实例会怎样?
  • @Ersoy 将尝试为这两个站点禁用 Redis,我确实禁用了一个,但仍然有问题
  • @Spudly 我们发现了问题,实际上是 .env 文件在 Windows 中为 Apache 创建了问题。这条评论帮助我解决了这个问题github.com/laravel/framework/issues/…
猜你喜欢
  • 1970-01-01
  • 2015-07-29
  • 2019-05-14
  • 2014-02-22
  • 2017-09-22
  • 1970-01-01
  • 2021-10-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多