在 mcrypt 扩展上使用 GitlabCI 部署 Laravel 失败

Posted

技术标签:

【中文标题】在 mcrypt 扩展上使用 GitlabCI 部署 Laravel 失败【英文标题】:Deploy Laravel with GitlabCI failed on mcrypt extension 【发布时间】:2018-05-18 22:42:35 【问题描述】:

我想用 GitLabCI 和 docker 部署我的 Laravel 项目。我有一个带有以下 before_script 的 yaml 文件:

docker-php-ext-install mbstring mcrypt pdo_mysql curl json intl gd xml zip bz2 opcache

它的回报是这样的:

error: /usr/src/php/ext/mcrypt does not exist

usage: /usr/local/bin/docker-php-ext-install [-jN] ext-name [ext-name ...]
   ie: /usr/local/bin/docker-php-ext-install gd mysqli
       /usr/local/bin/docker-php-ext-install pdo pdo_mysql
       /usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop

if custom ./configure arguments are necessary, see docker-php-ext-configure

Possible values for ext-name:
bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip

Some of the above modules are already compiled into PHP; please check
the output of "php -i" to see which modules are already loaded.
ERROR: Job failed: exit code 1

我尝试按照these 的答案使用 apt-get install 手动安装 mcrypt,但对我没有任何帮助。也查了this论坛帖子,但没有提到这个错误。

gitlab-ci.yaml 文件:

before_script:
  # Update packages 
  - apt-get update -yqq

  - apt-get install -my wget gnupg
  # Upgrade to Node 7
  - curl -sL https://deb.nodesource.com/setup_7.x | bash -

  # Install dependencies
  - apt-get install bzip2 git nodejs libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq

  # Install php extensions
  - docker-php-ext-install mbstring pdo_mysql curl json intl gd xml zip bz2 opcache

  # Install Node dependencies.
  # comment this out if you don't have a node dependency
  - npm install
  - npm install -g bower
  - npm install -g gulp-cli

  # Install Composer and project dependencies.
  - curl -sS https://getcomposer.org/installer | php
  - php composer.phar install 

使用 php7.0 和 Laravel 5.3.2

【问题讨论】:

【参考方案1】:

我遇到了这个问题。 Mcrypt 在 PHP 7.2 中被弃用。以下是如何绕过它:

  image: php:7.2

  before_script:
    # Update packages
    - apt-get update -yqq

    # Install dependencies
    - apt-get install git libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq

    # Install php extensions
    - docker-php-ext-install mbstring pdo_mysql curl json intl gd xml zip bz2 opcache pcntl

    ....    

    # PHP 7.2 Mcrypt & pcntl
    - pecl install mcrypt-1.0.1
    - docker-php-ext-enable mcrypt

    ....    

【讨论】:

我会试试的。谢谢 如果确实解决了您的问题,请标记为已解决。

以上是关于在 mcrypt 扩展上使用 GitlabCI 部署 Laravel 失败的主要内容,如果未能解决你的问题,请参考以下文章

如何在 CentOS 7.0 x64 上安装 MCrypt PHP 扩展

如何在 xampp linux 上启用 mcrypt php 扩展

在升级到 PHP 5.4.33 的 Centos VPS 上安装 mcrypt 扩展时出错

Homestead Laravel -- 需要 Mcrypt PHP 扩展

在 mac 上使用 PHP 安装 mcrypt

如何在 xampp 中安装 mcrypt 扩展