
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
capistrano3-ubuntu-server-prepare
Advanced tools
This Capistrano (v3) task helps you to configure your blank ubuntu server before your first deploy.
It can:
You can run configuration wizard, which will ask you what to do and for some additional settings, and will do all the work, so you can go and drink some coffee. Or you can look at the source and run any of the tasks on its own.
Note! It requires nginx, redis and unicorn config files in 'config/production' folder of your project. You can get them by running rake ubuntu_server_prepare:copy_config
Attention! My nginx and unicorn configuration files are made for your application running from /var/www/application/current. So add set :application, 'application'
to your config/deploy.rb
before first deploy or edit the configs.
For a complete usage instructions see usage
Add this line to your application's Gemfile:
group :development do
gem 'capistrano'
gem 'capistrano3-ubuntu-server-prepare'
end
And then execute:
$ bundle
Run
rake ubuntu_server_prepare:copy_config
and edit config files in config/production
Add
require 'capistrano3/ubuntu-server-prepare'
to your Capfile
(If non exists run cap install
).
Just imagine: you have some blank Ubuntu server. All you need to do manually is creating not root user, visudo
ing it and copying ssh keys, so you can login from your local machine without password.
So login as root to your server and do the following:
adduser deployer
(name can be anything)echo "deployer ALL=(ALL) ALL" >> /etc/sudoers
(change deployer to your name)On your local machine:
ssh-copy-id deployer@111.111.111.111
(change deployer to your username and 111.111.111.111 to your server ip)group :development do
gem 'capistrano'
gem 'capistrano3-ubuntu-server-prepare'
end
to your project Gemfile
bundle install
from your project folderrake ubuntu_server_prepare:copy_config
config/production
config files, if you wantrequire 'capistrano3/ubuntu-server-prepare'
to your Capfile
(cap install
if there isn't any)require 'capistrano/rvm'
in your Capfile
is commented.You can uncomment it after the process finishes.config/deploy/production.rb
so the only uncommented line will looks likeserver '111.111.111.111', user: 'deployer', roles: %w{web app db}
cap production ubuntu_server_prepare
to run configuration wizardAttention! My nginx and unicorn configuration files are made for your application running from /var/www/application/current. So add set :application, 'application'
to your config/deploy.rb
before first deploy or edit the configs.
So your server is configured, what to do next? How to deploy your app? OK, it is really easy:
db/database.yml
Gemfile
and be sure you have these gems:group :development do
gem 'capistrano'
gem 'capistrano-rails'
gem 'capistrano-bundler'
gem 'capistrano3-unicorn'
gem 'capistrano-rvm'
gem 'capistrano3-ubuntu-server-prepare'
gem 'capistrano3-git-push'
end
group :production do
gem 'unicorn'
end
Capfile
and be sure you have these lines:# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
require 'capistrano3/ubuntu-server-prepare'
require 'capistrano3/unicorn'
require 'capistrano3/git-push'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails'
config/deploy.rb
and paste your git server address in set :repo_url
(You can use BitBucket for a good free private repository)set :unicorn_config_path, "#{current_path}/config/production/unicorn/unicorn.rb"
set :linked_dirs, fetch(:linked_dirs, []).push('bin', 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
task :setup do
before "deploy:migrate", :create_db
invoke :deploy
end
task :create_db do
on roles(:all) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :rake, "db:create"
end
end
end
end
right after namespace :deploy do
line
before :deploy, 'git:push'
before 'deploy:setup', 'git:push'
after 'deploy:publishing', 'deploy:restart'
namespace :deploy do
task :restart do
invoke 'unicorn:legacy_restart'
end
end
to the end of the file
cap production deploy:setup
for the first time (it will run rake db:create), next times use cap production deploy
/usr/local/nginx/conf/nginx.conf # NGINX conf
/etc/redis/ # Redis conf
/var/www/
-- log/ # Nginx and Redis log files here
-- run/ # Nginx and Redis pid files here
-- application/
---- current/ # Your Rails app
------ log/ # Rails and Unicorn log file here
------ tmp/pids/ # Unicorn pid files here
------ tmp/sockets/ # Unicorn socket files here
Take a look at my capistrano3-delayed-job (delayed-job daemon management) and capistrano3-git-push (automated git add, commit, push before each deploy) Capistrano (v3) gems.
FAQs
Unknown package
We found that capistrano3-ubuntu-server-prepare demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.