Last active
December 18, 2015 02:58
-
-
Save eduzera/5714680 to your computer and use it in GitHub Desktop.
DigitalOcean VPS with ruby 2.0.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#login by ssh | |
cat ~/.ssh/id_rsa.pub | ssh [machine-user]@[machine-ip] "cat >> ~/.ssh/authorized_keys" | |
#first login | |
ssh root@[machine-ip] | |
#update repository | |
sudo apt-get update | |
#install required softwares | |
sudo apt-get install build-essential zlib1g-dev libreadline6-dev libyaml-dev libcurl4-openssl-dev libssl-dev libxslt-dev libxml2-dev git curl nodejs | |
#install ruby 2.0.0 -> go to step 7 | |
#install bundler | |
gem install bundler --no-ri --no-rdoc | |
#install passenger | |
gem install passenger --no-ri --no-rdoc | |
#install nginx - with default configs | |
passenger-install-nginx-module | |
#nginx service commands | |
cd /tmp | |
wget -O init-deb.sh http://library.linode.com/assets/660-init-deb.sh | |
mv init-deb.sh /etc/init.d/nginx | |
#nginx servie change authorization | |
chmod 777 /etc/init.d/nginx | |
#create dir on nginx folder | |
mkdir /opt/nginx/sites-enabled | |
#config to start on init | |
/usr/sbin/update-rc.d -f nginx defaults | |
#install mongodb | |
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 | |
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list | |
sudo apt-get update | |
sudo apt-get install mongodb-10gen | |
#add deployer user | |
adduser deployer #define password and type ENTER for defaults configs and Y to confirm | |
#add root privileges | |
/usr/sbin/visudo | |
# User to privilege specification file | |
root ALL=(ALL:ALL) ALL | |
[machine-user] ALL=(ALL:ALL) ALL | |
#Disable the Password for Root Login | |
sudo nano /etc/ssh/sshd_config | |
PermitRootLogin without-password #change this setting on file | |
#logout | |
exit | |
#deployer user login by ssh | |
cat ~/.ssh/id_rsa.pub | ssh deployer@[machine-ip] "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys" | |
#for login with deployer | |
ssh deployer@[machine-ip] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Gemfile | |
gem "capistrano", :group => :development | |
gem "therubyracer", :group => :assets | |
#install | |
bundle install | |
#Adds a ./Capfile and a ./config/deploy.rb | |
capify . | |
#config deploy.rb and Capfile | |
#setup | |
cap deploy:setup | |
#deploy | |
cap deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/capistrano" | |
set :application, "your_app_name" | |
set :user , "deployer_user" | |
set :server_ip , 'server_ip' | |
set :scm , :git | |
set :repository , "repository_url" | |
set :branch , "master" | |
set :deploy_via, :remote_cache | |
set :deploy_to, "/home/#{user}/apps/#{application}" | |
set :use_sudo, false | |
default_run_options[:pty] = true | |
ssh_options[:forward_agent] = true | |
server server_ip, :web, :app, :db, primary: true | |
namespace :deploy do | |
task :setup_config, roles: :app do | |
sudo "ln -nfs #{current_path}/config/nginx.conf /opt/nginx/sites-enabled/#{application}" | |
run "mkdir -p #{shared_path}/uploads" | |
end | |
after "deploy:setup", "deploy:setup_config" | |
task :start do ; end | |
task :stop do ; end | |
task :restart, :roles => :app, :except => { :no_release => true } do | |
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}" | |
end | |
task :create_uploads_symlink, roles: :web do | |
puts "CREATING simlink to uploads folder" | |
run "ln -nfs #{shared_path}/uploads #{current_path}/public/uploads" | |
end | |
after "deploy", "deploy:create_uploads_symlink" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load 'deploy' | |
load 'deploy/assets' | |
load 'config/deploy' # remove this line to skip loading any of the default tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#user nobody; | |
worker_processes 1; | |
#error_log logs/error.log; | |
#error_log logs/error.log notice; | |
#error_log logs/error.log info; | |
#pid logs/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
passenger_root /var/lib/gems/1.9.1/gems/passenger-4.0.5; | |
passenger_ruby /usr/bin/ruby1.9.1; | |
include mime.types; | |
default_type application/octet-stream; | |
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
# '$status $body_bytes_sent "$http_referer" ' | |
# '"$http_user_agent" "$http_x_forwarded_for"'; | |
#access_log logs/access.log main; | |
sendfile on; | |
#tcp_nopush on; | |
#keepalive_timeout 0; | |
keepalive_timeout 65; | |
#gzip on; | |
server_names_hash_bucket_size 64; | |
include /opt/nginx/sites-enabled/*; | |
# another virtual host using mix of IP-, name-, and port-based configuration | |
# | |
#server { | |
# listen 8000; | |
# listen somename:8080; | |
# server_name somename alias another.alias; | |
# location / { | |
# root html; | |
# index index.html index.htm; | |
# } | |
#} | |
# HTTPS server | |
# | |
#server { | |
# listen 443; | |
# server_name localhost; | |
# ssl on; | |
# ssl_certificate cert.pem; | |
# ssl_certificate_key cert.key; | |
# ssl_session_timeout 5m; | |
# ssl_protocols SSLv2 SSLv3 TLSv1; | |
# ssl_ciphers HIGH:!aNULL:!MD5; | |
# ssl_prefer_server_ciphers on; | |
# location / { | |
# root html; | |
# index index.html index.htm; | |
# } | |
#} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name yourdomain.com; | |
root /home/deployer/apps/yourapp/current/public; # <--- be sure to point to 'public'! | |
passenger_enabled on; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1. remove ruby-stable or ruby-ichi | |
sudo apt-get remove ruby-stable | |
sudo apt-get remove ruby-ichi | |
#2. download ruby-ni | |
wget -O - http://apt.hellobits.com/hellobits.key | sudo apt-key add - | |
#2.1 add to repository | |
echo 'deb http://apt.hellobits.com/ precise main' | sudo tee /etc/apt/sources.list.d/hellobits.list | |
#3. install ruby package | |
sudo apt-get update | |
$ sudo apt-get install ruby-ni | |
#4. verify ruby version | |
ruby -v | |
#thanks nando viera :) | |
#i just copied it from: http://simplesideias.com.br/instalando-o-ruby-dois-ponto-zero-no-ubuntu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment