简体   繁体   English

Class 'Memcached' 在 Laravel Elastic Beanstalk 应用程序中找不到

[英]Class 'Memcached' not found in Laravel Elastic Beanstalk App

I am deploying a laravel 6 project to an amazon elastic beanstalk application.我正在将 laravel 6 项目部署到亚马逊弹性 beanstalk 应用程序。 It's running php7.3.它正在运行 php7.3。

During eb deployeb deploy期间

ERROR: ServiceError - Failed to deploy application.错误:ServiceError - 无法部署应用程序。

Looking at logs I see that it cannot find the class 'Memcached'查看日志我发现它找不到 class 'Memcached'

@php artisan package:discover --ansi @php 工匠 package:discover --ansi

 Symfony\Component\Debug\Exception\FatalThrowableError  : Class 'Memcached' not found

at /var/app/ondeck/vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php:69
  65|      * @return \Memcached
  66|      */
  67|     protected function createMemcachedInstance($connectionId)
  68|     {
> 69|         return empty($connectionId) ? new Memcached : new Memcached($connectionId);
  70|     }
  71| 
  72|     /**
  73|      * Set the SASL credentials on the Memcached connection.

Exception trace:

1   Illuminate\Cache\MemcachedConnector::createMemcachedInstance()
    /var/app/ondeck/vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php:48

2   Illuminate\Cache\MemcachedConnector::getMemcached([], [])
    /var/app/ondeck/vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php:21

The instances are running Amazon Linux 2.9.这些实例正在运行 Amazon Linux 2.9。

I have also added a config file to install memcache using the packages.我还添加了一个配置文件来使用这些包安装 memcache。 it's .ebextensions/memcache_installer.cfg.yml with the following content:它是.ebextensions/memcache_installer.cfg.yml ,内容如下:

packages: 
  yum:
    memcached: [] 
    php-pecl-memcached: []

The error still doesn't go away.错误仍然没有 go 消失。 They do however get installed because if i try to install them from within the instance I get the package is already installed.但是它们确实会安装,因为如果我尝试从实例中安装它们,我会得到 package 已经安装。

We solved it (at least on our repo).我们解决了它(至少在我们的回购中)。 Remove the php-pecl-memchached because the amazon yum version has php 5 as a dependency (we saw this in the error logs).删除php-pecl-memchached ,因为 amazon yum 版本具有 php 5 作为依赖项(我们在错误日志中看到了这一点)。

What we added to our .ebextensions :我们添加到.ebextensions的内容:

memcached.config : memcached.config

packages: 
  yum:
    memcached: []
container_commands:
  01_memcached_start:
    command: "/sbin/service memcached restart"

elasticache_01.config

files:
  "/tmp/AmazonElastiCacheClusterClient-2.0.1-PHP73.tar.gz" :
    mode: "000777"
    owner: ec2-user
    group: ec2-user
    source: http://elasticache-downloads.s3.amazonaws.com/ClusterClient/PHP-7.3/latest-64bit

elasticache_02.config : elasticache_02.config

commands:
  01unzip:
    command: "tar -zxvf /tmp/AmazonElastiCacheClusterClient-2.0.1-PHP73.tar.gz -C /usr/lib64/php/7.3/modules"
files:
  /etc/php.d/project.ini:
    content: |
      extension=amazon-elasticache-cluster-client.so
    group: ec2-user
    mode: "000644"
    owner: ec2-user

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM