LoginSignup
5
5

More than 5 years have passed since last update.

VirtualBox+CentOS7(+Windows)でrubyの開発環境を作る 其の四

Last updated at Posted at 2016-02-05

記事の目次

VirtualBox+CentOS7(+Windows)でruby on railsの開発環境を作るのまとめ


railsをインストールする

  • railsをインストール

    
    gem install rails
    
  • インストール確認

    
    rails -v
    
  • 最新(2016/02/04時点で『4.2.5.1』)になっていればOK

rails newでプロジェクトを作る

  • どっかにプロジェクトのディレクトリを作る
    • 適当なので、自身のディレクトリ直下に作ってます
      
      mkdir [project_name]
      cd [project_name]
      

  • そのままだとrails newしてもエラーが出るので、必要なパッケージをインストールする
    
    sudo yum -y install sqlite-devel gcc-c++
    

  • railsの新規プロジェクトを作成
    
    rails new [project_name]
    

  • rails sでエラーになるためGemfile/therubyracerのコメントを外す
    
    vi Gemfile
    
    
    …
    # See https://github.com/rails/execjs#readme for more supported runtimes
    # gem 'therubyracer', platforms: :ruby ←これのコメントを外す
    …
    

  • bundle installする
    
    bundle install
    

  • ホスト側からブラウザでアクセスするため、CentOSのファイアーウォールを停止する
    • 本番はちゃんと設定せなあかんで!
      
      systemctl stop firewalld
      

  • rails serverを立ち上げる
    
    bundle exec rails s -b 0.0.0.0
    

  • 問題なく立ち上がったら、ホスト側のブラウザでアクセスしてみる
    
    http://192.168.1.xxx:3000/
    

  • コンソールにアクセスログが表示、ブラウザに以下の画面が表示されればOK

あとは適当に開発を進めて下さいやせ(´ω`)

参考

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