CentOS7のサーバでLaravel5のプロジェクトをcomposerでもって作成しようとしたら、
「PHPのmcrypt拡張がありゃしませんがな」
と怒られた。
$ composer create-project laravel/laravel <プロジェクト名> --prefer-dist
---ここから---
Installing laravel/laravel (v5.0.22)
- Installing laravel/laravel (v5.0.22)
Downloading: 100%
Created project in <プロジェクト名>
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for laravel/framework v5.0.16 -> satisfiable by laravel/framework[v5.0.16].
- laravel/framework v5.0.16 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
---ここまで---
しかし残念ながらCentOSのリポジトリに「php-mcrypt」はない。 仕方なく、EPELからインストールすることにする。
- EPELリポジトリを追加
$ wget http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-7 $ sudo rpm --import RPM-GPG-KEY-EPEL-7 $ rm -f RPM-GPG-KEY-EPEL-7 $ sudo vi /etc/yum.repos.d/epel.repo ---ここから--- [epel] name=Extra Packages for Enterprise Linux 7 - $basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch failovermethod=priority enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 ---ここまで---
- libmcryptインストール
$ sudo yum --enablerepo=epel install libmcrypt
- php-mcryptインストール
$ sudo yum -y --enablerepo=epel install php-mcrypt
Apache再起動
$ sudo systemctl restart httpd
- 再度Laravelプロジェクト作成
$ composer create-project laravel/laravel <プロジェクト名> --prefer-dist ---ここから--- Installing laravel/laravel (v5.0.22) - Installing laravel/laravel (v5.0.22) Loading from cache Created project in <プロジェクト名> Loading composer repositories with package information Installing dependencies (including require-dev) from lock file 【略】 Generating autoload files > php artisan clear-compiled > php artisan optimize Generating optimized class loader Compiling common classes > php -r "copy('.env.example', '.env');" > php artisan key:generate Application key [<アプリケーションキー>] set successfully. ---ここまで---
めでたし。