Improving the interactions and relationship between development and IT operations gives us more effective delivery and
production systems that are more stable and maintainable. Creating a DevOps culture requires attention to team
organization, work practices, reporting lines, and incentives - leading to joint responsibility for faster and safer delivery.
Due to our team size, I did not have no other choice than integrating devops principles and apply them all along my development process.
This tutorial assumes that you already have a working installation of an Apache server.
Install Phusion Passenger
Phusion Passenger has been by far the easiest way I’ve found for managing multiple Rails application instances on top of either Apache or Nginx. It comes as a gem and has custom modules for both major web servers.
Then you will need to update your apache configuration (as in the passenger instructions).
First, create a file called /etc/apache2/mods-available/passenger.load and input the following code :
Second, create a file called /etc/apache2/mods-available/passenger.conf and input the following code :
Then, enable the passenger module in Apache and restart the server.
PostgreSQL
Last but not least, you will need a DB engine. I mainly use PostgreSQL. Here is the installation process.
Capistrano
First create and init a new remote on your server
Capistrano needs git to update your code source. You can use any git repository as it is accessible from your server. Sometimes you could have a repository inside your local network and a server outside this network. In this case, your server will not be able to pull your code source. You can still create a git repository on your server, add it as a remote and push to it for capistrano. Here is how :
On server
On local
Capify your application
Add this following code into your Gemfile
And then :
And finally :
Capistrano settings
Capistrano is very well documented. By following the comments, first edit your /config/deploy.rb and then your specific environments settings in config/deploy/my_env.rb
Setup Apache
You need to create and setup permissions for the folder which will be used to deploy your app.
Then you need to create a virtual host to your current folder. Create a new file called myapp.conf in /etc/apache2/site-available
Don’t forget the .conf extension. Without this extension Apache is not able to treat it.
This article shows how to install ruby and rails on Ubuntu through rbenv
Install ruby
We are going to install Ruby through rbenv.
Install some dependencies for Ruby
The following set of dependencies just below contains everything you need to run Rails application on Ubuntu server.
Look at them carefully.
Install rbenv
We prefer here to use rbenv instead of RVM to its permissions management.
Let’s clone rbenv in home_dir
Now we will add ~/.rbenv/bin to our $PATH for access to the rbenv command-line utility.
Add rbenv init to your shell to enable shims and autocompletion.
Install ruby-build
Installing ruby-build as an rbenv plugin will give you access to the rbenv install command.
Install Ruby versions
rbenv offers some useful command like list or install. Install the ruby version that suits you as simple
as that :
Set the global version of Ruby
Installs shims for all Ruby executables known to rbenv (i.e., ~/.rbenv/versions//bin/).
Run this command after you install a new version of Ruby, or install a gem that provides commands.
$> rbenv rehash
Install rails
Now Ruby is installed, you can install rails by typing :
Note
You don’t need to specify --no-ri--no-rdoc every time you install a gem in production: just
add gem: --no-rdoc --no-ri to ~/.gemrc (create that file if it doesn’t already exist) and don’t worry about ri or rdoc again in production.
It is really useful to use a SSH connection through public key instead of having to type the password each time (especially if you are using a very complex password).
Create a .ssh folder on your server
First of all, server side, you need to create an .ssh folder in your home dir.
This is where you will keep your public keys.
Copy your ssh key on the server
Then, you need to copy your public RSA key on the server. Remember that this public key belongs to a machine.
If you plan on connecting to your server through several computers, you will need to reproduce this step for each of them.