環境†CentOS release 6.7 (Final) Rubyのインストール†パッケージのインストール†# yum install gcc gcc-c++ make autoconf openssl-devel readline-devel mysql-devel wget git # yum install zlib zlib-devel openssl-devel sqlite-devel gcc-c++ glibc-headers libyaml-devel readline readline-devel zlib-devel libffi-devel rbenvのインストール†# yum install openssl-devel readline-devel zlib-devel libcurl-devel # cd /usr/local # git clone git://github.com/sstephenson/rbenv.git rbenv Initialized empty Git repository in /usr/local/rbenv/.git/ remote: Counting objects: 2325, done. remote: Total 2325 (delta 0), reused 0 (delta 0), pack-reused 2325 Receiving objects: 100% (2325/2325), 411.02 KiB | 260 KiB/s, done. Resolving deltas: 100% (1453/1453), done. # mkdir rbenv/shims rbenv/versions rbenv/plugins # groupadd rbenv # chgrp -R rbenv rbenv # chmod -R g+rwxXs rbenv rbenv-buildのインストール†# cd /usr/local/rbenv/plugins # git clone git://github.com/sstephenson/ruby-build.git ruby-build Initialized empty Git repository in /usr/local/rbenv/plugins/ruby-build/.git/ remote: Counting objects: 5249, done. remote: Total 5249 (delta 0), reused 0 (delta 0), pack-reused 5249 Receiving objects: 100% (5249/5249), 985.32 KiB | 930 KiB/s, done. Resolving deltas: 100% (2893/2893), done. # chgrp -R rbenv ruby-build # chmod -R g+rwxs ruby-build rbenv-default-gemsのインストール†# cd /usr/local/rbenv/plugins # git clone git://github.com/sstephenson/rbenv-default-gems.git rbenv-default-gems Initialized empty Git repository in /usr/local/rbenv/rbenv-default-gems/.git/ remote: Counting objects: 18, done. remote: Total 18 (delta 0), reused 0 (delta 0), pack-reused 18 Receiving objects: 100% (18/18), done. Resolving deltas: 100% (4/4), done. # chgrp -R rbenv rbenv-default-gems # chmod -R g+rwxs rbenv-default-gems 環境変数の設定†# vi /etc/profile.d/rbenv.sh export RBENV_ROOT="/usr/local/rbenv" export PATH="$RBENV_ROOT/bin:$PATH" eval "$(rbenv init -)" # source /etc/profile.d/rbenv.sh # rbenv -v rbenv 0.4.0-215-g90373d7 デフォルトでインストールするgemの指定†# vi /usr/local/rbenv/default-gems bundler rbenv-rehash インストールするrubyのバージョンを確認†# rbenv install -l rubyのインストール†# rbev install 2.2.4 Downloading ruby-2.2.4.tar.gz... -> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.4.tar.gz Installing ruby-2.2.4... Installed ruby-2.2.4 to /usr/local/rbenv/versions/2.2.4 Fetching: bundler-1.11.2.gem (100%) Successfully installed bundler-1.11.2 Parsing documentation for bundler-1.11.2 Installing ri documentation for bundler-1.11.2 Done installing documentation for bundler after 7 seconds 1 gem installed Fetching: rbenv-rehash-0.3.gem (100%) Successfully installed rbenv-rehash-0.3 Parsing documentation for rbenv-rehash-0.3 Installing ri documentation for rbenv-rehash-0.3 Done installing documentation for rbenv-rehash after 0 seconds # rbenv global 2.2.4 # ruby -v ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux] # bundle -v Bundler version 1.11.2 Railsのインストール†# gem search -r rails # gem install rails # rails -v Rails 4.2.5 参考URL:http://www.ken10.com/ruby/ruby_install.html Passengerのインストール†# gem install passenger --no-ri --no-rdoc -V # passenger -v Phusion Passenger 5.0.22 # rbenv rehash # passenger-install-apache2-module Welcome to the Phusion Passenger Apache 2 module installer, v5.0.22. This installer will guide you through the entire installation process. It shouldn't take more than 3 minutes in total. Here's what you can expect from the installation process: 1. The Apache 2 module will be installed for you. 2. You'll learn how to configure Apache. 3. You'll learn how to deploy a Ruby on Rails application. Don't worry if anything goes wrong. This installer will advise you on how to solve any problems. Press Enter to continue, or Ctrl-C to abort. -------------------------------------------- Which languages are you interested in? Use <space> to select. If the menu doesn't display correctly, press '!' ‣ ⬢ Ruby ⬢ Python ⬡ Node.js ⬡ Meteor -------------------------------------------- ~ インストーラーが走ります ~ Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-) https://www.phusionpassenger.com Phusion Passenger is a registered trademark of Hongli Lai & Ninh Bui. # passenger-install-apache2-module --snippet >> /etc/httpd/conf.d/passenger.conf LoadModule passenger_module /usr/local/rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/passenger-5.0.22/buildout/apache2/mod_passenger.so <IfModule mod_passenger.c> PassengerRoot /usr/local/rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/passenger-5.0.22 PassengerDefaultRuby /usr/local/rbenv/versions/2.2.4/bin/ruby </IfModule> # cd /etc/httpd/conf.d # vim ◯◯.conf --- [パターン1:Rails以外でAlias使いたい場合] Alias /test-rails /var/www/vhosts/test-rails/app/public <Location /test-rails> PassengerEnabled on RailsEnv development PassengerBaseURI /test-rails PassengerAppRoot /var/www/vhosts/test-rails/app/ </Location> <Directory " /var/www/vhosts/test-rails/app/public"> AllowOverride All Options -MultiViews </Directory> 参考URL:http://qiita.com/61503891/items/732d9c123c39e35e97eb --- [パターン2:Railsだけの場合] DocumentRoot /var/www/vhosts/test-rails/app/public RailsEnv development <Directory " /var/www/vhosts/test-rails/app/public"> AllowOverride All Options -MultiViews </Directory> --- # service httpd configtest # service httpd graceful # gem install sqlite3 # mkdir -p /var/www/vhosts/test-rails # cd /var/www/vhosts/test-rails # rails new app Bundle complete! 12 Gemfile dependencies, 54 gems now installed. Use `bundle show [gemname]` to see where a bundled gem is installed. run bundle exec spring binstub --all * bin/rake: spring inserted * bin/rails: spring inserted # cd app # vi Gemfile - #gem 'therubyracer', platforms: :ruby + gem 'therubyracer', platforms: :ruby # chown -R 一般ユーザー:一般ユーザー /var/www/vhosts/test-rails # su - 一般ユーザー # bundle install 参考URL:http://qiita.com/merrill/items/87bf1ecfac8aa49f06a7 |