LoginSignup
0
0

More than 5 years have passed since last update.

VPS(Cent6.5)を借りてNginx, Ruby on Rails, MySQLでサービスをつくる(1)

Last updated at Posted at 2018-11-29

とある事情でVPS借りてサービスを作ってみようと思ったのでその記録

セキュリティ周り

https://qiita.com/ktkiyoshi/items/bf920b4df02d98b570e3
を参考にsshの設定まで行った。

nginx

nginxをインストール
sudo yum install nginx

バージョンの確認
$ nginx -v

iptablesを許可する

iptablesを編集

vim /etc/sysconfig/iptables

80番ポートを許可

-A INPUT -p tcp --dport 80 -j ACCEPT

iptablesを再起動

service iptables restart

これでnginxを起動すると、

sudo service nginx start

これでipアドレスをブラウザから叩く(80番ポート)と
nginxのindex画面をみることができます。
スクリーンショット 2018-11-16 19.03.54.png

rbenvのインストール

gitのインストール

sudo yum -y install git

rbenv をcloneする

git clone https://github.com/sstephenson/rbenv.git ~/.rbenv

エラーが出たので
https://qiita.com/murai-taisuke/items/173b3cbbd697e630047d
を参考に、

yum update -y nss curl libcurl

を実行します。
cloneできました。

環境設定

# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
# echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
# 各種設定の再読み込み
# exec $SHELL -l
# rbenvのversion確認
# rbenv --version
rbenv 1.1.1-39-g59785f6

ruby-buildをcloneする

git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

rubyの最新版確認

rbenv install --list

rails5.2.1にしたかったのとrubyの安定版をみると2.5.3なので
https://www.ruby-lang.org/ja/downloads/
https://rubygems.org/gems/rails/versions/5.2.1

rbenv install -v 2.5.3

とすると

BUILD FAILED (CentOS release 6.5 (Final) using ruby-build 20181106-11-g648fc99)

Inspect or clean up the working tree at /tmp/ruby-build.20181116230340.14758
Results logged to /tmp/ruby-build.20181116230340.14758.log

Last 10 log lines:
The Ruby openssl extension was not compiled.
The Ruby readline extension was not compiled.
The Ruby zlib extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Try running `yum install -y openssl-devel readline-devel zlib-devel` to fetch missing dependencies.

もう一度rbenv install -v 2.5.3

再読み込み

 rbenv rehash

インストールされているrubyを確認

 rbenv versions
* system (set by /root/.rbenv/version)
  2.5.3

[root@v133-130-74-221 admin]# rbenv global 2.5.3
[root@v133-130-74-221 admin]# ruby -v
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]

rubyを2.5系にできました。

Railsのインストール

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

gem install rails

MySQLのインストール

MySQLが入っていなかったためインストールします。

yum install mysql-server

プロジェクトの作成

rails new [project_name] -d mysql -B

これでRailsのインストールができました。

続きは別の記事に書こうと思います。

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