=============================================
The tutorial work with server by digitalocean.com
ssh [email protected]
sudo apt-get install aptitude
sudo apt-get update
sudo aptitude update
sudo aptitude safe-upgrade
sudo locale-gen el_GR.UTF-8
ssh-copy-id [email protected]
sudo adduser deploy
sudo adduser deploy sudo
ssh-copy-id [email protected]
sudo vim /etc/ssh/sshd_config
PermitRootLogin yes
PermitRootLogin no
Port 22
Port 4323
service ssh restart
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 libffi-dev nodejs
sudo apt-get install curl git-core nginx -y
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install -l
rbenv install 2.4.0
rbenv global 2.4.0
rbenv rehash
ruby -v
You just add following line to your local ~/.gemrc
file (it is in your home folder)
gem: --no-document
gem install bundler
rbenv rehash
gem install rails -V --no-ri --no-rdoc
rbenv rehash
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub
ssh -T [email protected]
sudo aptitude update
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
sudo mysql_install_db
sudo mysql_secure_installation
Create mysql database
mysql -u root -p
CREATE DATABASE `app` CHARACTER SET utf8 COLLATE utf8_general_ci;
Add additional gem into Gemfile
group :development do
gem 'capistrano', require: false
gem 'capistrano-rbenv', require: false
gem 'capistrano-rails', require: false
gem 'capistrano-bundler', require: false
gem 'capistrano3-puma', require: false
end
gem 'puma'
bundle
rbenv rehash
cap install
Copy config/deploy.rb & Capfile files and paste in your rails app
git add -A
git commit -m "Set up Puma, Nginx & Capistrano"
git push origin master
Run capistrano init
cap production deploy:initial
production:
adapter: mysql2
pool: 5
timeout: 5000
encoding: utf8
database: app
username: root
password: xxxxxxxxx
rails secret
sudo vim /etc/environment
export SECRET_KEY_BASE=abb2e9e094bb8fb1aa216defed455caa0f9
At first time run in apps/app/release/2017456534
RAILS_ENV=production bundle exec rake db:create
Example config/nginx.conf file, paste in your rails app
sudo rm /etc/nginx/sites-enabled/default
sudo ln -nfs "/home/deploy/apps/app/current/config/nginx.conf" "/etc/nginx/sites-enabled/app"
sudo service nginx restart
At the end, run
If you want only to restart puma server
cap production deploy:restart
After deploy, publish change
git add -A
git commit -m "Deploy Message"
git push origin master
cap production deploy
####How to install let's encrypt #1
if you have some problem, create new issue in this repo
##Happy coding...