sudo adduser deploy
sudo adduser deploy sudo
su deploy
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
curl -L https://get.rvm.io | bash -s stable
source /home/deploy/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm
rvm install 2.1.2
rvm use 2.1.2 --default
gem install rails --no-rdoc --no-ri
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
sudo apt-get install apt-transport-https ca-certificates
sudo sh -c "echo 'deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main' >> /etc/apt/sources.list.d/passenger.list"
sudo chown root: /etc/apt/sources.list.d/passenger.list
sudo chmod 600 /etc/apt/sources.list.d/passenger.list
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install nginx-full passenger
sudo service nginx restart
sudo vi /etc/nginx/nginx.conf
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/deploy/.rvm/wrappers/ruby-2.1.2/ruby;
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
mysql -u root -p
select user,host,password from mysql.user;
create database testdb;
grant all on testdb.* to 'root'@'localhost';
cd deploy
rails new myapp -d mysql
cd myapp
vi Gemfile
gem 'capistrano', '~> 3.1.0'
gem 'capistrano-bundler', '~> 1.1.2'
gem 'capistrano-rails', '~> 1.1.1'
gem 'capistrano-rvm', github: "capistrano/rvm"
bundle --binstubs
cap install STAGES=production
vi Capfile
require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/rvm'
vi config/deploy.rb
set :application, 'myapp'
set :repo_url, 'https://github.com/bobanuk/myapp.git'
set :deploy_to, '/home/deploy/myapp'
set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
after :publishing, 'deploy:restart'
after :finishing, 'deploy:cleanup'
vi config/deploy/production.rb
server 'ip.ip.ip.ip', user: 'deploy', roles: %w{web app}
sudo vi /etc/nginx/sites-enabled/default
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name domainame.ru;
passenger_enabled on;
rails_env production;
root /home/deploy/myapp/public;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
sudo service nginx restart
vi config/database.yml
root
12345
testdb
-------------Запуск
cd /home/deploy/myapp
RAILS_ENV=production bundle exec rake db:create
rails server -p 3000 -e production