LoginSignup
2

More than 3 years have passed since last update.

RMagickの環境構築

Last updated at Posted at 2018-10-09

WSL(Debian GNU/Linux)でRMagickの環境構築をする方法を記載します。

環境:
Windows10
WSL(Debian GNU/Linux)
Ruby 2.5.1

参考:
https://qiita.com/yusuke_konishi/items/bb99faceada542ce2017
https://gist.github.com/ryderstorm/e3bc3ffc2903adc6f9bc0fe822af76f0

yum 使用する場合は↓参考に
https://qiita.com/gifu_w/items/173bb5c258198e941ecd

WSLでDebianのインストール

まずは、Microsoft StoreでDebian GNU/Linuxのインストール。

image.png

インストールが完了したら、Windowsボタンを押して、「最近追加されたもの」からDebian GNU/Linuxをダブルクリックしてください。下記のように任意のusernameとpasswordを入力してください(usernameとpasswordはどこかにわかるように保管しておいてください)。インストールが完了し、Bash が起動すると、プロンプトが $ になります。これだけでDebian使えるようになります。

Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: hoge
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Installation successful!

作業用フォルダの作成

Windows側のファイルシステム配下に作業用のディレクトリ (C:\workspace) を作成し、WSLから扱いやすいようにシンボリックリンクを作成します。

$ mkdir /mnt/c/workspace
$ ln -s /mnt/c/workspace ~/workspace

Rubyのインストール

パッケージの更新をします。

$ sudo apt-get update
$ sudo apt-get upgrade

必要なパッケージをインストールします。
※Railsに必要なものも含まれています。

$ sudo apt-get install git nodejs build-essential zlib1g-dev libssl-dev libreadline-dev libyaml-dev libxslt-dev libcurl4-openssl-dev libffi-dev sqlite3 libsqlite3-dev

rbenvをインストールします。

$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$ source ~/.bashrc

ruby-buildをインストールします。

$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
$ echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
$ source ~/.bashrc

Rubyをインストールします。2.5.1の場合です。

$ rbenv install 2.5.1
$ rbenv global 2.5.1
$ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]

RMagickのインストール

$ sudo apt-get purge graphicsmagick graphicsmagick-dbg imagemagick-common imagemagick imagemagick-6.q16 libmagickcore-6-headers libmagickwand-dev graphicsmagick-libmagick-dev-compat
$ sudo apt-get autoremove
$ sudo apt-get install imagemagick libmagickwand-dev
$ sudo ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/Magick-config /usr/bin/Magick-config
$ export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig
$ gem install rmagick

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