CentOS6.7にpassengre+sinatra
を、なるべく、一括でできるようにまとめてみました
必要なアプリをインストール
yum -y install git gcc gcc-c++ libcurl-devel httpd httpd-devel openssl-devel readline-devel zlib-devel
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"'>> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc source ~/.bashrc mkdir ~/.rbenv/plugins cd ~/.rbenv/plugins git clone git://github.com/sstephenson/ruby-build.git
rbenv install 2.2.5
rbenv shell 2.2.5 gem install bundler
cd mkdir sina cd sina mkdir vendor mkdir vendor/bundle mkdir public mkdir tmp touch tmp/always_restart.txt bundle init echo 'gem "sinatra"' >> Gemfile echo 'gem "passenger"' >> Gemfile bundle install --path vendor/bundle
bundle exec passenger-install-apache2-module
・結果表示 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. : : Press Enter to continue, or Ctrl-C to abort. 1を、選択 ・結果表示 Use <space> to select. If the menu doesn't display correctly, press '!' ‣ ⬢ Ruby ⬢ Python ⬡ Node.js ⬡ Meteor entrで、進んで行く
bundle exec passenger-install-apache2-module --snippet >> /etc/httpd/conf/httpd.conf echo "DocumentRoot /root/sina/public" >> /etc/httpd/conf/httpd.conf
echo "#coding: utf-8" >app.rb echo "require 'sinatra'" >>app.rb echo "get '/' do" >>app.rb echo "'Hello World'" >>app.rb echo "end" >>app.rb echo "require File.expand_path(File.dirname(__FILE__)) + '/app'" >config.ru echo "run Sinatra::Application" >>config.ru
/etc/rc.d/init.d/httpd restart
getenforce Enforcing setenforce 0 getenforce Permissive
curl 'http://localhost/' chmod o+x "/root" curl 'http://localhost/' Hello World
■確認
いまく、いかない時には
以下の内容を確認してください。
path
cd cd sina pwd ・結果表示 /root/sina
ファイルの内容1
cd cd sina ls ・結果表示 Gemfile Gemfile.lock app.rb config.ru public tmp vendor
ファイルの内容2
ls tmp ・結果表示 always_restart.txt
appの内容
cat app.rb ・結果表示 #coding: utf-8 require 'sinatra' get '/' do 'Hello World' end
config.ruの内容
cat config.ru ・結果表示 require File.expand_path(File.dirname(__FILE__)) + '/app' run Sinatra::Application
httpd.confの内容
cat /etc/httpd/conf/httpd.conf ・結果表示(終わりの行) : #</VirtualHost> DocumentRoot /root/sina/public LoadModule passenger_module /root/sina/vendor/bundle/ruby/2.2.0/gems/passenger-5.0.28/buildout/apache2/mod_passenger.so <IfModule mod_passenger.c> PassengerRoot /root/sina/vendor/bundle/ruby/2.2.0/gems/passenger-5.0.28 PassengerDefaultRuby /root/.rbenv/versions/2.2.5/bin/ruby </IfModule>
SELinuxの内容
getenforce ・結果表示 Permissive
/rootの権限
ls /root -l ・結果表示 drwxr-xr-x. 6 root root 4096 6月 22 09:17 2016 sina