This is an old revision of the document!
First, update your package list
sudo apt update
Next, install the dependencies required to install Ruby:
sudo apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev
if anything breaks the installation, remove the particular dependency and install the other packages Once the dependencies download, you can install rbenv itself. Clone the rbenv repository from GitHub into the directory ~/.rbenv
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
Next, add ~/.rbenv/bin to your $PATH so that you can use the rbenv command line utility. Do this by altering your ~/.bashrc file so that it affects future login sessions:
echo 'export PATH=“$HOME/.rbenv/bin:$PATH”' » ~/.bashrc
Then add the command eval “$(rbenv init -)” to your ~/.bashrc file so rbenv loads automatically:
echo 'eval “$(rbenv init -)”' » ~/.bashrc
Next, apply the changes you made to your ~/.bashrc file to your current shell session:
source ~/.bashrc
Verify that rbenv is set up properly by using the type command, which will display more information about the rbenv command:
type rbenv
Your terminal window will display something starts with rbenv is a function
Next, install the ruby-build, plugin. This plugin adds therbenv install command, which simplifies the installation process for new versions of Ruby:
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
With the ruby-build plugin now installed, you can install versions of Ruby y may need through a simple command. First, let’s list all the available versions of Ruby:
rbenv install -l
if the above command throws error, you need to close the terminal and open the terminal again to load bashrc file, setting up rbenv
Let’s install Ruby 2.6.3
rbenv install 2.6.3
Once it’s done installing, set it as our default version of Ruby with the global sub-command
rbenv global 2.6.3
Verify that Ruby was properly installed by checking its version number:
ruby -v
Gems are the way Ruby libraries are distributed. You use the gem command to manage these gems
When you install a gem, the installation process generates local documentation. This can add a significant amount of time to each gem’s installation process, so turn off local documentation generation by creating a file called ~/.gemrc which contains a configuration setting to turn off this feature
echo “gem: –no-document” > ~/.gemrc
Bundler is a tool that manages gem dependencies for projects. Install the Bundler gem, particularly the version 2.1.4
gem install bundler -v 2.1.4
To install it, update the package index on your server with apt
sudo apt update
Then install the default package
sudo apt install mysql-server
This will install MySQL latest version. below will install mysql 5.7, As part of installation you provide necessary input to set password for the root user
create application deployment folder
mkdir performexa_production cd /home/expdev01/performexa_production
create 3 files inside 1. Capfile 2. config/deploy.rb 3. config/deploy/production.rb
Capfile
# Load DSL and set up stages
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/rbenv'
set :rbenv_type, :expdev01
set :rbenv_ruby, '2.6.3'
require 'capistrano/rbenv'
require 'capistrano/bundler'
require 'capistrano/rails/migrations'
require 'capistrano/passenger'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
config/deploy.rb
lock '3.16.0'
set :bundle_binstubs, -> { '/deploy/performance/shared/bundle/ruby/2.6.3/bin/' }
set :application, 'performexa'
set :log_level, :debug
set :pty, false
set :deploy_to, '/deploy/performance'
set :deploy_via, 'clone'
set :scm, :svn
set :repo_url, 'https://repos.exphosted.com/svnrepos/talent/trunks/performance/trunk'
#set :repo_url, 'https://repos.exphosted.com/svnrepos/talent/trunks/performance/branches/1.0.9.0-JACK'
#branch = (ENV["BRANCH"] || "")
#coreurl = 'https://repos.exphosted.com/svnrepos/talent/trunks/performance/'
#if branch == ""
# set :repo_url, "#{coreurl}/trunk"
#else
# set :repo_url, "#{coreurl}/branches/#{branch}"
#end
set :format, :pretty
set :log_level, :debug
set :linked_files, %w{config/api.yml config/database.yml config/chat.yml config/newrelic.yml}
#set :linked_dirs, %w{log }
set :linked_dirs, %w{config/environments public/system log tmp/pids}
#todo
before 'deploy:starting','deploy:svn_username'
before 'deploy:starting','deploy:remove_old_scm','deploy:verify_scm'
before 'deploy:starting','deploy:check_write_permissions'
before 'deploy:starting', 'god:stop', 'deploy:maint'
before "deploy:updated", "database:backup"
#after "deploy:updated", "static_assets:compile"
after "deploy:updated", "god:start","deploy:prod"
after "deploy:reverted", "god:start","deploy:prod"
#after 'deploy:publishing', 'deploy:restart'
#after 'deploy:finishing', 'deploy:cleanup'
#after 'deploy:publishing', 'deploy:restart'
config/deploy/production.rb
set :rails_env, "production"
set :user, "expdev01"
server 'localhost',user: fetch(:user),roles: %w{web app db search mastdb}
set :ssh_options, { :forward_agent => true }
install capistrano and dependent gems
gem install rails -v ‘6.0.0’ gem install capistrano gem install capistrano-rbenv gem install capistrano-rails gem install capistrano-bundler gem install capistrano3-puma
we used passenger with nginx in this application. So install passenger gem first
gem install passenger –no-rdoc –no-ri
we need to uninstall the nginx module that comes with os first then need to install nginx with passenger module
sudo apt-get purge nginx nginx-full nginx-light nginx-naxsi nginx-common sudo rm -rf /etc/nginx
above commands will completely uninstall the nginx
then install nginx with passenger module passenger-install-nginx-module
Next, need to validate nginx installation through below commands. rvmsudo passenger-config validate-install rvmsudo passenger-memory-stats these commands will list you nginx process with pid as well passenger process with pid
to restart nginx we need to kill the existing process and then start nginx service sudo kill $(cat /opt/nginx/logs/nginx.pid) sudo /opt/nginx/sbin/nginx