LoginSignup
0
4

More than 5 years have passed since last update.

AWSでpdftotextを使えるようにする

Posted at

前提

  • AWSのアカウントを作成済み

事前準備

  • AWSにログインし、EC2のインスタンスを作成する
  • 開発したRailsアプリを作成したEC2に配置する

必要なパッケージをインストール

Amazon LinuxにRuby on Rails環境構築(rbenv + ruby-build + Ruby 2.2.1 + Rails 4.2.1インストール)
を参考にさせていただきました。

$ sudo su -
# yum -y install git
# yum -y install gcc-c++ glibc-headers openssl-devel readline libyaml-devel readline-devel zlib zlib-devel libffi-devel libxml2 libxslt libxml2-devel libxslt-devel
  • rbenvのインストール
git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
# cp -p /etc/profile /etc/profile.ORG
# diff /etc/profile /etc/profile.ORG
#

# echo 'export RBENV_ROOT="/usr/local/rbenv"' >> /etc/profile
# echo 'export PATH="${RBENV_ROOT}/bin:${PATH}"' >> /etc/profile
# echo 'eval "$(rbenv init -)"' >> /etc/profile

# source /etc/profile
  • ruby-buildインストール
# git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build
  • ruby 2.4.0をインストール
# rbenv install -v 2.4.0
# rbenv rehash
# rbenv global 2.4.0
  • bundlerをインストール
# rbenv exec gem install bundler

Railsアプリを配置したディレクトリに移動

# cd /home/ec2-user/sample/

bundle installを実行

# bundle install 

pgでエラーが。。。

postgresqlをインストールして起動してから再度bundle install

# yum install -y postgresql postgresql-devel postgresql-server postgresql-libs
# service postgresql initdb
# /sbin/chkconfig postgresql on
# service postgresql start
# bundle install

今度はglib2でエラーが。。。。

追加でパッケージをインストールして再実行

# yum -y install glib2-devel
# bundle install

今度は成功

pdftotextのインストール

# yum -y install poppler poppler-utils

poppler-utilsをインストールすることで、pdftotextが使用できるようになる。

あとは、前回作成したタスクを実行

# bundle exec rails read_pdf:read

前回はこちら

0
4
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
0
4