LoginSignup
7
10

More than 5 years have passed since last update.

Network APIを作成するための環境構築(Ruby、Sinatra、ActiveRecord)

Last updated at Posted at 2015-10-30

マシン環境

cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)

Rubyインストール

CentOSのdefaultのrubyのバージョンは一旦古いため、削除 :triumph:
yum remove ruby

Rubyソースのコンパイルのために下記をインストール
yum -y install gcc zlib-devel openssl-devel sqlite sqlite-devel mysql-devel readline-devel libffi-devel

Ruby2.2.3をインストール(結構時間かかる :sleeping:

cd /usr/local/src
wget https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.gz
tar zxvf ruby-2.2.3.tar.gz
cd ruby-2.2.3
./configure
make
make install

確認 :laughing:

ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]

MySQLインストール

yum -y install mysql
確認(MariaDBになってる :laughing:

mysql --version
mysql  Ver 15.1 Distrib 5.5.44-MariaDB, for Linux (x86_64) using readline 5.1

これも必要っぽい。
yum install mariadb-server

systemctl enable mariadb.service
systemctl start mariadb.service

初期パスワード設定
/usr/bin/mysqladmin -u root password 'new-password'

初期設定
mysql_secure_installation

Sinatra、Nokogiri、Netconfなどなどのインストール

そこそこ時間かかります :sleeping:

gem install sinatra
gem install netconf
gem install nokogiri
gem install activerecord
gem install mysql2
gem install netaddr
gem install sinatra-contrib
gem update
gem update --system
gem uninstall mysql2  #(0.4.1)
gem install mysql2 -v 0.3.20

mysql2のバージョンが新しいと上手く動かなかったので、0.3.20に落とした :astonished:
updateも一応した :dash:
NetAddrはあんまり使ってる人いなさそうな感じですが、すごく便利 :kissing_heart:

こちらのQiita記事もご参考に

7
10
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
7
10