LoginSignup
2
5

More than 5 years have passed since last update.

EC2 の Laravel に Imagick をインストールする

Last updated at Posted at 2017-09-25

環境を確認します

スーパーユーザーにて行います

$ sudo su -

【 Fileinfo Extension 】

# php -r 'phpinfo();' > /var/www/laravel/info.log

結果が
fileinfo support => enabled
version => 1.0.5
ならデフォルトでOK

【 GD Library 】

# php -r 'var_dump(gd_info());'

結果が
array(**){
["GD VERSION"] => string(26) "bundled ..."
ならデフォルトでOK

【 Imagic 】

# php -r 'print_r(imagic::getVersion());'

結果が
["ver"] => ~~~
でなければ、Imagick のインストールへ

Imagick をインストールします

1. Memcached (yum)

# yum install -y memcached memcached-devel

2. php-pear (yum)

# yum install -y php-pear

3. php56-devel (yum)

# yum install -y php56-devel

4. memcache (pecl)

# yum install -y memcache

5. Image Magick (yum)

# yum install -y ImageMagick*

6. Imagick (pecl)

# pecl install imagick

※ please provide the prefix of imagemagick installation と出たらエンター

7. php.ini 修正

ファイルの最後に1行追加

extension = imagick.so

intervention/image をインストールします

$ cd laravel
$ composer require intervention/image

これでエラー出たら SWAP ファイルを作る

【 SWAP ファイルを作る 】

$ sudo su -
# dd if=/dev/zero of=/swapfile1 bs=1M count=512
> 512+0 records in
  512+0 records out
  536870912 bytes (537 MB) copied, 5.74393 s, 93.5 MB/s
# ll /swapfile1
> -rw-r--r-- 1 root root 536870912 Mar  3 00:52 /swapfile1
# chmod 600 /swapfile1
# mkswap /swapfile1
> Setting up swapspace version 1, size = 524284 KiB
  no label, UUID=0cf6e114-a01e-45e5-94f6-7c9adf75f5f2
# swapon /swapfile1
# swapon -s
> Filename                                Type            Size    Used    Priority
  /swapfile1                              file    524284  0       -1
# free
>              total       used       free     shared    buffers     cached
  Mem:       1020188     626832     393356          0       8272     556020
  -/+ buffers/cache:      62540     957648
  Swap:       524284          0     524284
# grep Swap /proc/meminfo
> SwapCached:            0 kB
  SwapTotal:        524284 kB
  SwapFree:         524284 kB

スワップファイルを無効化して Swap 領域のサイズを元に戻す

# swapoff /swapfile1
# rm -f /swapfile1

以上となります。

2
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5