Skip to content

Instantly share code, notes, and snippets.

@tadeuzagallo
Last active September 22, 2015 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadeuzagallo/addee7bf7fd62a4ae818 to your computer and use it in GitHub Desktop.
Save tadeuzagallo/addee7bf7fd62a4ae818 to your computer and use it in GitHub Desktop.
Install Ruby with RVM on cpanel
# ssh
ssh user@servidor.com
# install rvm
\curl -sSL https://get.rvm.io | bash -s stable
# load rvm
source ~/.profile
source ~/.rvm/source/rvm
# install rvm dependencies
rvm autolibs disable
rvm pkg install libyaml
rvm install 2.1.0 # ver a última versão com `rvm list`
rvm use 2.1.0 —-default
gem update bundler
# install fcgi
wget http://www.fastcgi.com/dist/fcgi.tar.gz
tar -zxvf fcgi.tar.gz
cd `ls | grep fcgi`
./configure --prefix=$HOME/usr/local/fcgi --exec-prefix=$HOME/usr/local/fcgi
make && make install
gem install fcgi -r -- --with-fcgi-lib=$HOME/usr/local/fcgi/lib --with-fcgi-include=$HOME/usr/local/fcgi/include
###########################
#
# !!! IMPORTANTE !!!
#
# No arquivo `Gemfile`
#
# A gem do banco de dados tem que ser `mysql2`
# Tem que ter a gem `therubyracer` (geralmente comentada, na linha 14)
# Rodar: `bundle install --without development test` dentro da pasta do projeto
# Rodar: `RAILS_ENV=production bundle exec rake db:migrate`
# Rodar: `bundle exec rake assets:precompile`
#
#
# NA PASTA `public` do projeto rails
# OBS: a pasta public tem que ficar fora do `public_html`, para os arquivos da aplicação não ficarem visíveis através do browser
# depois de todos os arquivos adicionados, criar um link simbólico para a pasta `public` da aplicação
# e.g.: ln -s ~/rails_app/public ~/public_html
# Adicionar o .htaccess
#
#
# <IfModule mod_fastcgi.c>
# AddHandler fastcgi-script .fcgi
# </IfModule>
# <IfModule mod_fcgid.c>
# AddHandler fcgid-script .fcgi
# </IfModule>
#
# Options +FollowSymLinks +ExecCGI
#
# RewriteEngine On
#
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L]
#
# ErrorDocument 500 "Rails application failed to start properly"
#
#
# E o dispatch.fcgi (adicionar permissão para execução com `chmod +x dispatch.fgi`)
#
#!/home/<NOME_DO_USUARIO>/.rvm/rubies/<RUBY_VERSION>/bin/ruby
#
## ver o NOME_DO_USUARIO com `whoami`
## ver o RUBY_VERSION com `rvm list`
## ver o NOME_DA_APLICACAO_RAILS no arquivo `config/application.rb`
#
# ENV['RAILS_ENV'] ||= 'production'
# ENV['HOME'] ||= `echo ~`.strip
# ENV['GEM_HOME'] = File.expand_path('~/.rvm/gems/<RUBY_VERSION>')
# ENV['GEM_PATH'] = File.expand_path('~/.rvm/gems/<RUBY_VERSION>') + ":" +
# File.expand_path('~/.rvm/gems/<RUBY_VERSION>@global')
#
# require 'fcgi'
# require File.join(ENV['HOME'], 'rails_app/config/environment.rb')
#
# class Rack::PathInfoRewriter
# def initialize(app)
# @app = app
# end
#
# def call(env)
# env.delete('SCRIPT_NAME')
# parts = env['REQUEST_URI'].split('?')
# env['PATH_INFO'] = parts[0]
# env['QUERY_STRING'] = parts[1].to_s
# @app.call(env)
# end
# end
# Rack::Handler::FastCGI.run Rack::PathInfoRewriter.new(<NOME_DA_APICACAO_RAILS>::Application)
#
#
###########################
@mdamaceno
Copy link

O meu teste estava dando erro 500 seguindo todo o tutorial.

Fiz um teste no meu servidor com Cpanel e, no final de todo tutorial, precisei rodar no terminal o comando dentro da pasta da aplicação:

rake secret

Depois disso, colei o resultado no arquivo ~/rails_app/config/initializers/secret_token.rb ficando assim:

<NOME_DA_APICACAO_RAILS>::Application.config.secret_token = '<CHAVE_GERADA_PELO_RAKE_SECRET>'

Com isso, deixou de dar erro 500.

@neohunter
Copy link

error: git was compiled without libcurl support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment